|
|
|
@ -34,14 +34,17 @@ namespace Shentun.Peis.CommonChars |
|
|
|
{ |
|
|
|
private readonly IRepository<IdentityUser, Guid> _userRepository; |
|
|
|
private readonly CommonCharManager _manager; |
|
|
|
private readonly CacheService _cacheService; |
|
|
|
public CommonCharAppService( |
|
|
|
IRepository<CommonChar, Guid> repository, |
|
|
|
IRepository<IdentityUser, Guid> userRepository, |
|
|
|
CommonCharManager manager) |
|
|
|
CommonCharManager manager, |
|
|
|
CacheService cacheService) |
|
|
|
: base(repository) |
|
|
|
{ |
|
|
|
_userRepository = userRepository; |
|
|
|
_manager = manager; |
|
|
|
_cacheService = cacheService; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 获取通过主键
|
|
|
|
@ -69,31 +72,25 @@ namespace Shentun.Peis.CommonChars |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表 常用字符 带搜索
|
|
|
|
/// 获取列表 常用字符 带搜索 可按常用字符类别搜索
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<PagedResultDto<CommonCharDto>> GetListInFilterAsync(GetListInFilterDto input) |
|
|
|
[HttpPost("api/app/CommonChar/GetCommonCharList")] |
|
|
|
public async Task<List<CommonCharDto>> GetCommonCharListAsync(GetCommonCharListRequestDto input) |
|
|
|
{ |
|
|
|
int totalCount = 0; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.Filter)) |
|
|
|
totalCount = (await Repository.GetListAsync()).Where(m => m.DisplayName.Contains(input.Filter)).Count(); |
|
|
|
else |
|
|
|
totalCount = await Repository.CountAsync(); |
|
|
|
var query = (await Repository.GetQueryableAsync()).Include(x => x.CommonCharType).AsQueryable(); |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.Filter)) |
|
|
|
query = query.Where(m => (!string.IsNullOrEmpty(m.DisplayName) && m.DisplayName.Contains(input.Filter)) |
|
|
|
|| (!string.IsNullOrEmpty(m.SimpleCode) && m.SimpleCode.Contains(input.Filter))); |
|
|
|
|
|
|
|
var entlist = Repository.GetDbSetAsync().Result.Include(c => c.CommonCharType).ToList(); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.Filter)) |
|
|
|
entlist = entlist.Where(m => m.DisplayName.Contains(input.Filter)).ToList(); |
|
|
|
|
|
|
|
//分页
|
|
|
|
entlist = entlist.OrderBy(m => m.DisplayOrder).Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList(); |
|
|
|
|
|
|
|
var userList = await _userRepository.GetListAsync(); |
|
|
|
|
|
|
|
var entdto = entlist.Select(s => new CommonCharDto |
|
|
|
if (input.CommonCharTypeId != null) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.CommonCharTypeId == input.CommonCharTypeId); |
|
|
|
} |
|
|
|
var entListDto = query.Select(s => new CommonCharDto |
|
|
|
{ |
|
|
|
CreationTime = s.CreationTime, |
|
|
|
CreatorId = s.CreatorId, |
|
|
|
@ -104,12 +101,12 @@ namespace Shentun.Peis.CommonChars |
|
|
|
LastModifierId = s.LastModifierId, |
|
|
|
SimpleCode = s.SimpleCode, |
|
|
|
CommonCharTypeId = s.CommonCharTypeId, |
|
|
|
CommonCharName = s.CommonCharType.DisplayName, |
|
|
|
CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId), |
|
|
|
LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId) |
|
|
|
CommonCharTypeName = s.CommonCharType.DisplayName, |
|
|
|
CreatorName = _cacheService.GetUserNameAsync(s.CreatorId).Result, |
|
|
|
LastModifierName = _cacheService.GetUserNameAsync(s.LastModifierId).Result |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return new PagedResultDto<CommonCharDto>(totalCount, entdto); |
|
|
|
return entListDto; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -151,7 +148,7 @@ namespace Shentun.Peis.CommonChars |
|
|
|
return base.DeleteAsync(id); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改排序 置顶,置底
|
|
|
|
|