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.
177 lines
5.8 KiB
177 lines
5.8 KiB
using AutoMapper.Internal.Mappers;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shentun.Peis.GuideTypes;
|
|
using Shentun.Peis.HelperDto;
|
|
using Shentun.Peis.Models;
|
|
using Shentun.Peis.Sexs;
|
|
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;
|
|
|
|
namespace Shentun.Peis.MaritalStatuses
|
|
{
|
|
|
|
/// <summary>
|
|
/// 婚姻状况
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class MaritalStatusesAppService : ApplicationService
|
|
{
|
|
private readonly IRepository<MaritalStatus> _repository;
|
|
|
|
public MaritalStatusesAppService(IRepository<MaritalStatus> repository)
|
|
{
|
|
this._repository = repository;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取婚姻状况表数据列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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="Id">主键ID</param>
|
|
/// <param name="input">修改参数</param>
|
|
/// <returns></returns>
|
|
public async Task<MaritalStatusDto> UpdateAsync(char Id, UpdateMaritalStatusDto input)
|
|
{
|
|
var ent = await _repository.GetAsync(m => m.Id == Id);
|
|
|
|
ent.SimpleCode = input.SimpleCode;
|
|
ent.DisplayName = input.DisplayName;
|
|
|
|
var newent = await _repository.UpdateAsync(ent);
|
|
|
|
return ObjectMapper.Map<MaritalStatus, MaritalStatusDto>(newent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 修改排序 相邻之间
|
|
/// </summary>
|
|
/// <param name="id">需要修改的ID</param>
|
|
/// <param name="targetid">目标ID</param>
|
|
[HttpPut("api/app/maritalstatus/updatesort")]
|
|
[RemoteService(false)]
|
|
public async Task UpdateSortAsync(char id, char targetid)
|
|
{
|
|
var entity = await _repository.GetAsync(m => m.Id == id);
|
|
var targetentity = await _repository.GetAsync(m => m.Id == targetid);
|
|
|
|
int olddisplaynum = entity.DisplayOrder;
|
|
entity.DisplayOrder = targetentity.DisplayOrder;
|
|
targetentity.DisplayOrder = olddisplaynum;
|
|
|
|
List<MaritalStatus> entlist = new List<MaritalStatus>();
|
|
entlist.Add(entity);
|
|
entlist.Add(targetentity);
|
|
|
|
await _repository.UpdateManyAsync(entlist);
|
|
}
|
|
|
|
/// <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)
|
|
{
|
|
var entity = await _repository.GetAsync(m => m.Id == id);
|
|
|
|
List<MaritalStatus> UptList = new List<MaritalStatus>();
|
|
|
|
if (SortType == 2)
|
|
{
|
|
UptList = (await _repository.GetListAsync(o => o.DisplayOrder > entity.DisplayOrder)).OrderBy(o => o.DisplayOrder).ToList();
|
|
|
|
if (UptList.Count > 0)
|
|
{
|
|
|
|
int indexnum = entity.DisplayOrder; //原有值
|
|
|
|
entity.DisplayOrder = UptList[UptList.Count - 1].DisplayOrder; //修改当前排序值为最大
|
|
|
|
//置顶操作,往上一行开始,逐渐替换
|
|
foreach (var item in UptList)
|
|
{
|
|
int dqnum = item.DisplayOrder;
|
|
item.DisplayOrder = indexnum;
|
|
indexnum = dqnum;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UptList = (await _repository.GetListAsync(o => o.DisplayOrder < entity.DisplayOrder)).OrderByDescending(o => o.DisplayOrder).ToList(); ;
|
|
|
|
int indexnum = entity.DisplayOrder; //原有值
|
|
|
|
entity.DisplayOrder = UptList[UptList.Count - 1].DisplayOrder; //修改当前排序值为最小
|
|
|
|
//置底操作,往下一行开始,逐渐替换
|
|
foreach (var item in UptList)
|
|
{
|
|
int dqnum = item.DisplayOrder;
|
|
item.DisplayOrder = indexnum;
|
|
indexnum = dqnum;
|
|
}
|
|
}
|
|
|
|
|
|
UptList.Add(entity);
|
|
|
|
|
|
await _repository.UpdateManyAsync(UptList);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 修改排序 拖拽
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/maritalstatus/updatesortmany")]
|
|
public async Task UpdateSortManyAsync(UpdateSortManyNokeyDto input)
|
|
{
|
|
var entitylist = await _repository.GetListAsync(o => input.ItemList.Select(s => s.Id).Contains(o.Id.ToString()));
|
|
foreach (var entity in entitylist)
|
|
{
|
|
foreach (var item in input.ItemList)
|
|
{
|
|
if (item.Id == entity.Id.ToString())
|
|
entity.DisplayOrder = item.DisplayOrder;
|
|
}
|
|
}
|
|
|
|
await _repository.UpdateManyAsync(entitylist);
|
|
}
|
|
|
|
}
|
|
}
|