Browse Source

常用字符类别

bjmzak
wxd 2 years ago
parent
commit
b1cfb2673d
  1. 2
      src/Shentun.Peis.Application.Contracts/CommonChars/CommonCharDto.cs
  2. 19
      src/Shentun.Peis.Application.Contracts/CommonChars/GetCommonCharListRequestDto.cs
  3. 45
      src/Shentun.Peis.Application/CommonChars/CommonCharAppService.cs

2
src/Shentun.Peis.Application.Contracts/CommonChars/CommonCharDto.cs

@ -19,7 +19,7 @@ namespace Shentun.Peis.CommonChars
public string SimpleCode { get; set; }
public int DisplayOrder { get; set; }
public string CommonCharName { get; set; }
public string CommonCharTypeName { get; set; }
}

19
src/Shentun.Peis.Application.Contracts/CommonChars/GetCommonCharListRequestDto.cs

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.CommonChars
{
public class GetCommonCharListRequestDto
{
/// <summary>
/// 搜索名称 支持名称跟简码
/// </summary>
public string Filter { get; set; }
/// <summary>
/// 常用字符类别ID
/// </summary>
public Guid? CommonCharTypeId { get; set; }
}
}

45
src/Shentun.Peis.Application/CommonChars/CommonCharAppService.cs

@ -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>
/// 修改排序 置顶,置底

Loading…
Cancel
Save