|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
using System.Data; |
|
|
|
|
using SqlSugar; |
|
|
|
|
using System.Data; |
|
|
|
|
using System.Drawing.Drawing2D; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services.BASE; |
|
|
|
|
|
|
|
|
@ -743,10 +745,11 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ |
|
|
|
|
filter.pageSize = 10000; |
|
|
|
|
|
|
|
|
|
Type entityType = typeof(TEntity); |
|
|
|
|
var properties = entityType.GetGenericProperties(); |
|
|
|
|
|
|
|
|
|
var countSql = @$" SELECT COUNT(1) FROM {entityType.GetEntityTableName()}"; |
|
|
|
|
var countSql = @$" SELECT COUNT(1) FROM {entityType.GetEntityTableName()} A"; |
|
|
|
|
var sql1 = @$"DECLARE @langId INT = {filter.langId};"; |
|
|
|
|
var sql = @$" SELECT *,
|
|
|
|
|
var sql = @$" SELECT A.*,
|
|
|
|
|
ISNULL ((SELECT CASE WHEN @langId = 1 THEN UserName ELSE UserEname END |
|
|
|
|
FROM Ghrs_User B |
|
|
|
|
WHERE B.UserId = A.CreateBy), |
|
|
|
@ -756,9 +759,11 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ |
|
|
|
|
WHERE B.UserId = A.UpdateBy), |
|
|
|
|
'') UpdateDataInfo, ISNULL(A.UpdateTime, A.CreateTime) CreateTime1 |
|
|
|
|
FROM {entityType.GetEntityTableName()} A";
|
|
|
|
|
|
|
|
|
|
string conditions = " WHERE 1=1 "; |
|
|
|
|
|
|
|
|
|
if (properties.Any(x => x.Name == "DataBelongID")) |
|
|
|
|
conditions += $" AND dbo.FUserDataBelongPriv ({App.User.ID}, A.DataBelongID, NULL) = 1"; |
|
|
|
|
|
|
|
|
|
if (IsEnable == true) |
|
|
|
|
conditions += " AND IsEnable = 1"; |
|
|
|
|
else if (IsEnable == false) |
|
|
|
@ -767,7 +772,6 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ |
|
|
|
|
if (!string.IsNullOrWhiteSpace(condition)) |
|
|
|
|
conditions += " AND " + condition; |
|
|
|
|
|
|
|
|
|
var properties = entityType.GetGenericProperties(); |
|
|
|
|
|
|
|
|
|
if (filter.jsonParam != null) |
|
|
|
|
foreach (JProperty jProperty in filter.jsonParam.Properties()) |
|
|
|
@ -791,6 +795,23 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ |
|
|
|
|
sql = sql1 + sql; |
|
|
|
|
var entitys = await Db.Ado.SqlQueryAsync<TEntityDto>(sql); |
|
|
|
|
|
|
|
|
|
if (entitys != null) |
|
|
|
|
{ |
|
|
|
|
var dyDataBelongID = entityType.GetProperty("DataBelongID"); |
|
|
|
|
var entityTypeDto = typeof(TEntityDto); |
|
|
|
|
var propertieDtos = entityTypeDto.GetGenericProperties(); |
|
|
|
|
if (propertieDtos.Any(x => x.Name == "DataBelongName")) |
|
|
|
|
for (int i = 0; i < entitys.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var dataBelongID = dyDataBelongID.GetValue(entitys[i]); |
|
|
|
|
if (dataBelongID != null) |
|
|
|
|
{ |
|
|
|
|
var propertie = entityTypeDto.GetProperty("DataBelongName"); |
|
|
|
|
propertie.SetValue(entitys[i], await GetDataBelongName(dataBelongID.ObjToInt())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return new ServicePageResult<TEntityDto>(filter.pageNum, total, filter.pageSize, entitys); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -1463,22 +1484,36 @@ ORDER BY SortNo ASC"; |
|
|
|
|
return label; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public async Task<string> DataBelongName(int? id) |
|
|
|
|
//{ |
|
|
|
|
// string label = string.Empty; |
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="id"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<string> GetDataBelongName(int? id) |
|
|
|
|
{ |
|
|
|
|
string label = string.Empty; |
|
|
|
|
|
|
|
|
|
// if(_caching != null) |
|
|
|
|
// { |
|
|
|
|
if (id == null) |
|
|
|
|
return null; |
|
|
|
|
if (_caching != null) |
|
|
|
|
{ |
|
|
|
|
var list = await _caching.GetAsync<List<Ghrs_DataBelong>>("DataBelong"); |
|
|
|
|
if (list == null || (list != null && !list.Any())) |
|
|
|
|
{ |
|
|
|
|
list = await Db.Queryable<Ghrs_DataBelong>().ToListAsync(); |
|
|
|
|
if (list.Any()) |
|
|
|
|
await _caching.SetAsync("DataBelong", list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
// else |
|
|
|
|
// { |
|
|
|
|
// label = await Db.Queryable<Ghra_LegalCompany>().Where(x=>x.LegalCompanyID) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// return label; |
|
|
|
|
//} |
|
|
|
|
if (list.Any(x => x.DataBelongId == id)) |
|
|
|
|
label = list.FirstOrDefault(x => x.DataBelongId == id)?.DataBelongName; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
label = await Db.Queryable<Ghrs_DataBelong>().Where(x => x.DataBelongId == id).Select(x => x.DataBelongName).FirstAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return label; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 处理json查询条件 |
|
|
|
|