update HouseCodeList
This commit is contained in:
@@ -41,9 +41,18 @@ namespace Ewide.Application.Service.HouseCode.Dto
|
|||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeleteProjectInput
|
public class DeleteHouseCodeInput
|
||||||
{
|
{
|
||||||
[Required(ErrorMessage = "房屋编码ID不可为空")]
|
[Required(ErrorMessage = "房屋编码ID不可为空")]
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class QueryHouseCodeInput : PageInputBase
|
||||||
|
{
|
||||||
|
public string HouseCode { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
public string ProjectId { get; set; }
|
||||||
|
public string ZoonId { get; set; }
|
||||||
|
public int Type { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using Ewide.Core;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Ewide.Application.Service.HouseCode.Dto
|
||||||
|
{
|
||||||
|
public class HouseCodeOutput : PageInputBase
|
||||||
|
{
|
||||||
|
public string HouseCode { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
public string ProjectId { get; set; }
|
||||||
|
public string ZoonId { get; set; }
|
||||||
|
public int Type { get; set; }
|
||||||
|
public int ProjectFullName { get; set; }
|
||||||
|
public int ProjectName { get; set; }
|
||||||
|
public int AreaName { get; set; }
|
||||||
|
public int RoadName { get; set; }
|
||||||
|
public int CommName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,10 +9,6 @@ using Furion.FriendlyException;
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using Ewide.Core.Extension;
|
using Ewide.Core.Extension;
|
||||||
@@ -51,26 +47,21 @@ namespace Ewide.Application.Service.HouseCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/houseCode/delete")]
|
[HttpPost("/houseCode/delete")]
|
||||||
public async Task DeleteHouseCode(DeleteProjectInput input)
|
public async Task DeleteHouseCode(DeleteHouseCodeInput input)
|
||||||
{
|
{
|
||||||
var houseCode = _houseCodeRep.FirstOrDefault(p => p.Id == input.Id);
|
var houseCode = _houseCodeRep.FirstOrDefault(p => p.Id == input.Id);
|
||||||
await houseCode.DeleteNowAsync();
|
await houseCode.DeleteNowAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
//public async Task<dynamic> QueryHouseCodePageList([FromBody] AddHouseCodeInput input)
|
[HttpPost("/houseCode/page")]
|
||||||
//{
|
public async Task<dynamic> QueryPage([FromBody] QueryHouseCodeInput input)
|
||||||
// var areaCodeRep = Db.GetRepository<SysAreaCode>();
|
|
||||||
// var projectCodeRep = Db.GetRepository<BsHouseProjectInfo>();
|
|
||||||
// var houseCodes = await _houseCodeRep.DetachedEntities
|
|
||||||
// .Join(projectCodeRep.DetachedEntities, c => c.ProjectId, p => p.Id, (c, p) => new { c, p })
|
|
||||||
// .Join(areaCodeRep.DetachedEntities, cp => cp.p.AreaCode, a => a.Code, (cp, a) => new { cp, a })
|
|
||||||
// .Where(!string.IsNullOrEmpty(input.HouseCode), cpa => cpa.cp.c.HouseCode.Contains(input.HouseCode))
|
|
||||||
//}
|
|
||||||
|
|
||||||
public async Task<dynamic> QueryPage()
|
|
||||||
{
|
{
|
||||||
var sql = "SELECT * FROM bs_house_code";
|
var sql = @"SELECT HC.*,HP.Note,AA.Name AreaName,RA.Name RoadName,CA.Name CommName FROM bs_house_code HC
|
||||||
return await _dapperRepository.QueryPageData(sql, new PageInputBase());
|
LEFT JOIN bs_house_projectinfo HP ON HP.Id=HC.ProjectId
|
||||||
|
LEFT JOIN sys_area_code CA ON CA.Code = HP.AreaCode
|
||||||
|
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
|
||||||
|
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6) WHERE HC.Address like @Address";
|
||||||
|
return await _dapperRepository.QueryPageData(sql, input, param: new { Address = '%' + input.Address + '%' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,17 @@ namespace Ewide.Core.Extension
|
|||||||
{
|
{
|
||||||
public static class PageExtensions
|
public static class PageExtensions
|
||||||
{
|
{
|
||||||
public static string OrderBuilder<T>(PageInputBase pageInput, bool descSort = true)
|
private static string OrderBuilder(PageInputBase pageInput)
|
||||||
|
{
|
||||||
|
var orderStr = string.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(pageInput.SortField))
|
||||||
|
{
|
||||||
|
orderStr = $"{pageInput.SortField} {(pageInput.SortOrder == pageInput.DescStr ? "Desc" : "Asc")}";
|
||||||
|
}
|
||||||
|
return orderStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string OrderBuilder<T>(PageInputBase pageInput, bool descSort = true)
|
||||||
{
|
{
|
||||||
var type = typeof(T);
|
var type = typeof(T);
|
||||||
var hasId = type.GetProperty("Id") != null;
|
var hasId = type.GetProperty("Id") != null;
|
||||||
@@ -24,12 +34,12 @@ namespace Ewide.Core.Extension
|
|||||||
var defaultField = hasSort ? "Sort" : (hasId ? "Id" : "");
|
var defaultField = hasSort ? "Sort" : (hasId ? "Id" : "");
|
||||||
|
|
||||||
// 约定默认每张表都有Id排序
|
// 约定默认每张表都有Id排序
|
||||||
var orderStr = string.IsNullOrEmpty(defaultField) ? "" : defaultField + (descSort ? " Asc" : " Desc");
|
var orderStr = string.IsNullOrEmpty(defaultField) ? "" : defaultField + (descSort ? " Desc" : " Asc");
|
||||||
|
|
||||||
// 排序是否可用-排序字段和排序顺序都为非空才启用排序
|
// 排序是否可用-排序字段和排序顺序都为非空才启用排序
|
||||||
if (!string.IsNullOrEmpty(pageInput.SortField) && !string.IsNullOrEmpty(pageInput.SortOrder))
|
if (!string.IsNullOrEmpty(pageInput.SortField))
|
||||||
{
|
{
|
||||||
orderStr = $"{pageInput.SortField} {(pageInput.SortOrder == pageInput.DescStr ? "Asc" : "Desc")}";
|
orderStr = OrderBuilder(pageInput);
|
||||||
}
|
}
|
||||||
return orderStr;
|
return orderStr;
|
||||||
}
|
}
|
||||||
@@ -46,7 +56,7 @@ namespace Ewide.Core.Extension
|
|||||||
|
|
||||||
public static Task<IEnumerable<dynamic>> QueryPageData(this IDapperRepository source, string sql, PageInputBase input, object param = null, System.Data.IDbTransaction transaction = null, int? commandTimeout = null, System.Data.CommandType? commandType = null)
|
public static Task<IEnumerable<dynamic>> QueryPageData(this IDapperRepository source, string sql, PageInputBase input, object param = null, System.Data.IDbTransaction transaction = null, int? commandTimeout = null, System.Data.CommandType? commandType = null)
|
||||||
{
|
{
|
||||||
return source.QueryAsync(sql,
|
return source.QueryAsync(PageSqlBuild(sql,input),
|
||||||
param: param,
|
param: param,
|
||||||
transaction: transaction,
|
transaction: transaction,
|
||||||
commandTimeout: commandTimeout,
|
commandTimeout: commandTimeout,
|
||||||
@@ -63,5 +73,12 @@ namespace Ewide.Core.Extension
|
|||||||
commandType: commandType
|
commandType: commandType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string PageSqlBuild(string sql , PageInputBase input)
|
||||||
|
{
|
||||||
|
var orderStr = OrderBuilder(input);
|
||||||
|
var r = "SELECT * FROM (" + sql + ") T " + (string.IsNullOrEmpty(orderStr) ? string.Empty : "Order by " + orderStr) + " LIMIT " + ((input.PageNo - 1) * input.PageSize).ToString() + "," + input.PageSize.ToString();
|
||||||
|
return r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,6 @@ namespace Ewide.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 降序排序(不要问我为什么是descend不是desc,前端约定参数就是这样)
|
/// 降序排序(不要问我为什么是descend不是desc,前端约定参数就是这样)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string DescStr { get; set; } = "descend";
|
public virtual string DescStr => "descend";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user