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
{
///
/// 婚姻状况
///
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class MaritalStatusesAppService : ApplicationService
{
private readonly IRepository _repository;
private readonly MaritalStatusManager _manager;
public MaritalStatusesAppService(
IRepository repository,
MaritalStatusManager Manager
)
{
this._repository = repository;
this._manager = Manager;
}
///
/// 获取婚姻状况表数据列表
///
///
[RemoteService(false)]
public async Task> 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>(entlist);
return new PagedResultDto(totalCount, entdto);
}
///
/// 查询婚姻状况列表
///
///
///
[HttpGet("api/app/MaritalStatus/GetMaritalStatusList")]
public async Task> 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> 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>(entlist);
return entdto;
}
///
/// 修改
///
/// 主键ID
/// 修改参数
///
public async Task UpdateAsync(char Id, UpdateMaritalStatusDto input)
{
var entity = await _repository.GetAsync(m => m.Id == Id);
var sourceEntity = ObjectMapper.Map(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await _repository.UpdateAsync(entity);
return ObjectMapper.Map(entity);
}
///
/// 修改排序 置顶,置底
///
/// 需要修改的ID
/// 修改方式:1 置顶 2 置底
///
[HttpPut("api/app/maritalstatus/updatemanysort")]
public async Task UpdateManySortAsync(char id, int SortType)
{
await _manager.UpdateManySortAsync(id, SortType);
}
///
/// 修改排序 拖拽
///
///
///
[HttpPut("api/app/maritalstatus/updatesortmany")]
public async Task UpdateSortManyAsync(UpdateSortManyCharDto input)
{
await _manager.UpdateSortManyAsync(input);
}
}
}