You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.9 KiB

3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
  1. using AutoMapper.Internal.Mappers;
  2. using Microsoft.AspNetCore.Authorization;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Shentun.Peis.Enums;
  5. using Shentun.Peis.GuideTypes;
  6. using Shentun.Peis.HelperDto;
  7. using Shentun.Peis.Models;
  8. using Shentun.Peis.Sexs;
  9. using Shentun.Peis.Units;
  10. using SqlSugar;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using Volo.Abp;
  17. using Volo.Abp.Application.Dtos;
  18. using Volo.Abp.Application.Services;
  19. using Volo.Abp.Domain.Repositories;
  20. using Volo.Abp.ObjectMapping;
  21. namespace Shentun.Peis.MaritalStatuses
  22. {
  23. /// <summary>
  24. /// 婚姻状况
  25. /// </summary>
  26. [ApiExplorerSettings(GroupName = "Work")]
  27. [Authorize]
  28. public class MaritalStatusesAppService : ApplicationService
  29. {
  30. private readonly IRepository<MaritalStatus> _repository;
  31. private readonly MaritalStatusManager _manager;
  32. public MaritalStatusesAppService(
  33. IRepository<MaritalStatus> repository,
  34. MaritalStatusManager Manager
  35. )
  36. {
  37. this._repository = repository;
  38. this._manager = Manager;
  39. }
  40. /// <summary>
  41. /// 获取婚姻状况表数据列表
  42. /// </summary>
  43. /// <returns></returns>
  44. [RemoteService(false)]
  45. public async Task<PagedResultDto<MaritalStatusDto>> GetListAsync(PagedAndSortedResultRequestDto input)
  46. {
  47. var totalCount = await _repository.CountAsync();
  48. var entlist = await _repository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, input.Sorting);
  49. entlist = entlist.OrderBy(o => o.DisplayOrder).ToList();
  50. var entdto = ObjectMapper.Map<List<MaritalStatus>, List<MaritalStatusDto>>(entlist);
  51. return new PagedResultDto<MaritalStatusDto>(totalCount, entdto);
  52. }
  53. /// <summary>
  54. /// 查询婚姻状况列表
  55. /// </summary>
  56. /// <param name="input"></param>
  57. /// <returns></returns>
  58. [HttpGet("api/app/MaritalStatus/GetMaritalStatusList")]
  59. public async Task<List<MaritalStatusDto>> GetMaritalStatusListAsync(GetListInFilterDto input)
  60. {
  61. var entlist = await _repository.GetQueryableAsync();
  62. if (!string.IsNullOrEmpty(input.Filter))
  63. entlist = entlist.Where(m => m.DisplayName.Contains(input.Filter));
  64. var entdto = entlist.Select(s => new MaritalStatusDto
  65. {
  66. DisplayName = s.DisplayName,
  67. DisplayOrder = s.DisplayOrder,
  68. Id = s.Id,
  69. SimpleCode = s.SimpleCode
  70. }).OrderBy(o => o.DisplayOrder).ToList();
  71. return entdto;
  72. }
  73. [HttpPost("api/app/MaritalStatus/GetForMaritalStatusList")]
  74. public async Task<List<MaritalStatusDto>> GetForMaritalStatusListAsync()
  75. {
  76. var entlist = await _repository.GetListAsync(o => o.Id == MaritalStatusFlag.UnMarried || o.Id == MaritalStatusFlag.Married);
  77. entlist = entlist.OrderBy(o => o.DisplayOrder).ToList();
  78. //增加全部
  79. entlist.Add(new MaritalStatus()
  80. {
  81. Id = MaritalStatusFlag.All,
  82. DisplayName = "全部",
  83. DisplayOrder = 100
  84. });
  85. var entdto = ObjectMapper.Map<List<MaritalStatus>, List<MaritalStatusDto>>(entlist);
  86. return entdto;
  87. }
  88. /// <summary>
  89. /// 修改
  90. /// </summary>
  91. /// <param name="Id">主键ID</param>
  92. /// <param name="input">修改参数</param>
  93. /// <returns></returns>
  94. public async Task<MaritalStatusDto> UpdateAsync(char Id, UpdateMaritalStatusDto input)
  95. {
  96. var entity = await _repository.GetAsync(m => m.Id == Id);
  97. var sourceEntity = ObjectMapper.Map<UpdateMaritalStatusDto, MaritalStatus>(input);
  98. await _manager.UpdateAsync(sourceEntity, entity);
  99. entity = await _repository.UpdateAsync(entity);
  100. return ObjectMapper.Map<MaritalStatus, MaritalStatusDto>(entity);
  101. }
  102. /// <summary>
  103. /// 修改排序 置顶,置底
  104. /// </summary>
  105. /// <param name="id">需要修改的ID</param>
  106. /// <param name="SortType">修改方式:1 置顶 2 置底</param>
  107. /// <returns></returns>
  108. [HttpPut("api/app/maritalstatus/updatemanysort")]
  109. public async Task UpdateManySortAsync(char id, int SortType)
  110. {
  111. await _manager.UpdateManySortAsync(id, SortType);
  112. }
  113. /// <summary>
  114. /// 修改排序 拖拽
  115. /// </summary>
  116. /// <param name="input"></param>
  117. /// <returns></returns>
  118. [HttpPut("api/app/maritalstatus/updatesortmany")]
  119. public async Task UpdateSortManyAsync(UpdateSortManyCharDto input)
  120. {
  121. await _manager.UpdateSortManyAsync(input);
  122. }
  123. }
  124. }