Browse Source

适用性别

bjmzak
wxd 2 years ago
parent
commit
8c35a49a6e
  1. 15
      src/Shentun.Peis.Application.Contracts/ForSexs/UpdateForSexDto.cs
  2. 25
      src/Shentun.Peis.Application/ForSexs/ForSexAppService.cs
  3. 1
      src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
  4. 2
      src/Shentun.Peis.Domain/ForSexs/ForSex.cs
  5. 27
      src/Shentun.Peis.Domain/ForSexs/ForSexManager.cs

15
src/Shentun.Peis.Application.Contracts/ForSexs/UpdateForSexDto.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Shentun.Peis.ForSexs
{
public class UpdateForSexDto
{
[Required(ErrorMessage = "名称不能为空")]
public string DisplayName { get; set; }
[Required(ErrorMessage = "快捷码不能为空")]
public string SimpleCode { get; set; }
}
}

25
src/Shentun.Peis.Application/ForSexs/ForSexAppService.cs

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using Shentun.Peis.HelperDto;
using Shentun.Peis.Models;
using Shentun.Peis.Sexs;
using System;
using System.Collections.Generic;
using System.Linq;
@ -20,14 +21,34 @@ namespace Shentun.Peis.ForSexs
public class ForSexAppService : ApplicationService
{
private readonly IRepository<ForSex> _forSexRepository;
private readonly ForSexManager _manager;
public ForSexAppService(
IRepository<ForSex> forSexRepository
IRepository<ForSex> forSexRepository,
ForSexManager manager
)
{
this._forSexRepository = forSexRepository;
this._manager = manager;
}
/// <summary>
/// 修改
/// </summary>
/// <param name="Id">主键ID</param>
/// <param name="input">修改参数</param>
/// <returns></returns>
[HttpPost("api/app/forsex/update")]
public async Task<ForSexDto> UpdateAsync(char Id, UpdateForSexDto input)
{
var entity = await _forSexRepository.GetAsync(m => m.Id == Id);
var sourceEntity = ObjectMapper.Map<UpdateForSexDto, ForSex>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await _forSexRepository.UpdateAsync(entity);
return ObjectMapper.Map<ForSex, ForSexDto>(entity);
}
/// <summary>
/// 获取适用性别列表
/// </summary>

1
src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs

@ -367,6 +367,7 @@ public class PeisApplicationAutoMapperProfile : Profile
CreateMap<UpdateRegisterAsbitemDto, RegisterAsbitem>();
CreateMap<ForSex, ForSexDto>();
CreateMap<UpdateForSexDto, ForSex>();
CreateMap<RegisterCheckItem, RegisterCheckItemDto>();
CreateMap<UpdateRegisterCheckItemManyDto, RegisterCheckItem>().ForMember(d => d.CheckDate, opt => opt.MapFrom(src => PageHelper.ConvertDate(src.CheckDate)));

2
src/Shentun.Peis.Domain/ForSexs/ForSex.cs

@ -12,7 +12,7 @@ namespace Shentun.Peis.Models
/// 适用性别设置,固定编码
/// </summary>
[Table("for_sex")]
public class ForSex : AuditedEntity, IHasConcurrencyStamp
public class ForSex : AuditedEntity, IHasConcurrencyStamp, ICharId, IDisplayName, IDisplayOrder
{
[Key]
[Column("id")]

27
src/Shentun.Peis.Domain/ForSexs/ForSexManager.cs

@ -18,6 +18,33 @@ namespace Shentun.Peis.ForSexs
this._forSexRepository = forSexRepository;
}
/// <summary>
/// 更新
/// </summary>
/// <param name="sourceEntity"></param>
/// <param name="targetEntity"></param>
/// <returns></returns>
public async Task UpdateAsync(
ForSex sourceEntity,
ForSex targetEntity
)
{
DataHelper.CheckEntityIsNull(sourceEntity);
DataHelper.CheckEntityIsNull(targetEntity);
DataHelper.CheckStringIsNull(sourceEntity.DisplayName, "名称");
DataHelper.CheckStringIsNull(sourceEntity.SimpleCode, "自定义简码");
if (sourceEntity.DisplayName != targetEntity.DisplayName)
{
await EntityHelper.CheckSameName<ForSex>(_forSexRepository, sourceEntity.DisplayName, targetEntity);
targetEntity.DisplayName = sourceEntity.DisplayName;
}
if (sourceEntity.SimpleCode != targetEntity.SimpleCode)
targetEntity.SimpleCode = sourceEntity.SimpleCode;
}
/// <summary>
/// 获取适用性别名称
/// </summary>

Loading…
Cancel
Save