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

using AutoMapper.Internal.Mappers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Shentun.Peis.Enums;
using Shentun.Peis.GuideTypes;
using Shentun.Peis.HelperDto;
using Shentun.Peis.Models;
using Shentun.Peis.Sexs;
using Shentun.Peis.Units;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.ObjectMapping;
namespace Shentun.Peis.MaritalStatuses
{
/// <summary>
/// 婚姻状况
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class MaritalStatusesAppService : ApplicationService
{
private readonly IRepository<MaritalStatus> _repository;
private readonly MaritalStatusManager _manager;
public MaritalStatusesAppService(
IRepository<MaritalStatus> repository,
MaritalStatusManager Manager
)
{
this._repository = repository;
this._manager = Manager;
}
/// <summary>
/// 获取婚姻状况表数据列表
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task<PagedResultDto<MaritalStatusDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
var totalCount = await _repository.CountAsync();
var entlist = await _repository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, input.Sorting);
entlist = entlist.OrderBy(o => o.DisplayOrder).ToList();
var entdto = ObjectMapper.Map<List<MaritalStatus>, List<MaritalStatusDto>>(entlist);
return new PagedResultDto<MaritalStatusDto>(totalCount, entdto);
}
/// <summary>
/// 查询婚姻状况列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("api/app/MaritalStatus/GetMaritalStatusList")]
public async Task<List<MaritalStatusDto>> GetMaritalStatusListAsync(GetListInFilterDto input)
{
var entlist = await _repository.GetQueryableAsync();
if (!string.IsNullOrEmpty(input.Filter))
entlist = entlist.Where(m => m.DisplayName.Contains(input.Filter));
var entdto = entlist.Select(s => new MaritalStatusDto
{
DisplayName = s.DisplayName,
DisplayOrder = s.DisplayOrder,
Id = s.Id,
SimpleCode = s.SimpleCode
}).OrderBy(o => o.DisplayOrder).ToList();
return entdto;
}
[HttpPost("api/app/MaritalStatus/GetForMaritalStatusList")]
public async Task<List<MaritalStatusDto>> GetForMaritalStatusListAsync()
{
var entlist = await _repository.GetListAsync(o => o.Id == MaritalStatusFlag.UnMarried || o.Id == MaritalStatusFlag.Married);
entlist = entlist.OrderBy(o => o.DisplayOrder).ToList();
//增加全部
entlist.Add(new MaritalStatus()
{
Id = MaritalStatusFlag.All,
DisplayName = "全部",
DisplayOrder = 100
});
var entdto = ObjectMapper.Map<List<MaritalStatus>, List<MaritalStatusDto>>(entlist);
return entdto;
}
/// <summary>
/// 修改
/// </summary>
/// <param name="Id">主键ID</param>
/// <param name="input">修改参数</param>
/// <returns></returns>
public async Task<MaritalStatusDto> UpdateAsync(char Id, UpdateMaritalStatusDto input)
{
var entity = await _repository.GetAsync(m => m.Id == Id);
var sourceEntity = ObjectMapper.Map<UpdateMaritalStatusDto, MaritalStatus>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await _repository.UpdateAsync(entity);
return ObjectMapper.Map<MaritalStatus, MaritalStatusDto>(entity);
}
/// <summary>
/// 修改排序 置顶,置底
/// </summary>
/// <param name="id">需要修改的ID</param>
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
/// <returns></returns>
[HttpPut("api/app/maritalstatus/updatemanysort")]
public async Task UpdateManySortAsync(char id, int SortType)
{
await _manager.UpdateManySortAsync(id, SortType);
}
/// <summary>
/// 修改排序 拖拽
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPut("api/app/maritalstatus/updatesortmany")]
public async Task UpdateSortManyAsync(UpdateSortManyCharDto input)
{
await _manager.UpdateSortManyAsync(input);
}
}
}