mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-31 22:26:36 +08:00
简化对象映射Mapper,简化自定义仓储
This commit is contained in:
@@ -23,11 +23,15 @@ namespace Yi.RBAC.Application.Dictionary
|
||||
private IDictionaryRepository _dictionaryRepository { get; set; }
|
||||
public override async Task<PagedResultDto<DictionaryGetListOutputDto>> GetListAsync(DictionaryGetListInputVo input)
|
||||
{
|
||||
var data = await _dictionaryRepository.SelectGetListAsync(await MapToEntityAsync(input), input);
|
||||
int total = 0;
|
||||
var entities = await _DbQueryable.WhereIF(input.DictType is not null, x => x.DictType == input.DictType)
|
||||
.WhereIF(input.DictLabel is not null, x => x.DictLabel!.Contains(input.DictLabel!))
|
||||
.WhereIF(input.State is not null, x => x.State == input.State)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
return new PagedResultDto<DictionaryGetListOutputDto>
|
||||
{
|
||||
Total = data.Total,
|
||||
Items = await MapToGetListOutputDtosAsync(data.Items)
|
||||
Total = total,
|
||||
Items = await MapToGetListOutputDtosAsync(entities)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Yi.RBAC.Domain.Dictionary.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Yi.RBAC.Domain.Dictionary.Repositories;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Yi.RBAC.Application.Dictionary
|
||||
{
|
||||
@@ -21,11 +22,18 @@ namespace Yi.RBAC.Application.Dictionary
|
||||
|
||||
public async override Task<PagedResultDto<DictionaryTypeGetListOutputDto>> GetListAsync(DictionaryTypeGetListInputVo input)
|
||||
{
|
||||
var data = await _dictionaryTypeRepository.SelectGetListAsync(await MapToEntityAsync(input), input);
|
||||
|
||||
int total = 0;
|
||||
var entities = await _DbQueryable.WhereIF(input.DictName is not null, x => x.DictName.Contains(input.DictName!))
|
||||
.WhereIF(input.DictType is not null, x => x.DictType!.Contains(input.DictType!))
|
||||
.WhereIF(input.State is not null, x => x.State == input.State)
|
||||
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
|
||||
return new PagedResultDto<DictionaryTypeGetListOutputDto>
|
||||
{
|
||||
Total = data.Total,
|
||||
Items = await MapToGetListOutputDtosAsync(data.Items)
|
||||
Total = total,
|
||||
Items = await MapToGetListOutputDtosAsync(entities)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.RBAC.Application.Contracts.Dictionary.Dtos;
|
||||
using Yi.RBAC.Domain.Dictionary.Entities;
|
||||
|
||||
namespace Yi.RBAC.Application.Dictionary.MapperConfig
|
||||
{
|
||||
public class DictionaryProfile: Profile
|
||||
{
|
||||
public DictionaryProfile()
|
||||
{
|
||||
CreateMap<DictionaryGetListInputVo, DictionaryEntity>();
|
||||
CreateMap<DictionaryCreateInputVo, DictionaryEntity>();
|
||||
CreateMap<DictionaryUpdateInputVo, DictionaryEntity>();
|
||||
CreateMap<DictionaryEntity, DictionaryGetListOutputDto>();
|
||||
CreateMap<DictionaryEntity, DictionaryGetOutputDto>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.RBAC.Application.Contracts.Dictionary.Dtos;
|
||||
using Yi.RBAC.Domain.Dictionary.Entities;
|
||||
|
||||
namespace Yi.RBAC.Application.Dictionary.MapperConfig
|
||||
{
|
||||
public class DictionaryTypeProfile: Profile
|
||||
{
|
||||
public DictionaryTypeProfile()
|
||||
{
|
||||
CreateMap<DictionaryTypeGetListInputVo, DictionaryTypeEntity>();
|
||||
CreateMap<DictionaryTypeCreateInputVo, DictionaryTypeEntity>();
|
||||
CreateMap<DictionaryTypeUpdateInputVo, DictionaryTypeEntity>();
|
||||
CreateMap<DictionaryTypeEntity, DictionaryTypeGetListOutputDto>();
|
||||
CreateMap<DictionaryTypeEntity, DictionaryTypeGetOutputDto>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user