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.
159 lines
5.4 KiB
159 lines
5.4 KiB
using AutoMapper.Internal.Mappers;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shentun.Peis.DiagnosisLevels;
|
|
using Shentun.Peis.HelperDto;
|
|
using Shentun.Peis.Models;
|
|
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.Identity;
|
|
|
|
namespace Shentun.Peis.DiagnosisLevels
|
|
{
|
|
|
|
/// <summary>
|
|
/// 诊断级别
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class DiagnosisLevelAppService : CrudAppService<
|
|
DiagnosisLevel, //The Book entity
|
|
DiagnosisLevelDto, //Used to show books
|
|
short, //Primary key of the book entity
|
|
PagedAndSortedResultRequestDto, //Used for paging/sorting
|
|
CreateDiagnosisLevelDto,
|
|
UpdateDiagnosisLevelDto>
|
|
{
|
|
private readonly IRepository<IdentityUser, Guid> _userRepository;
|
|
private readonly DiagnosisLevelManager _manager;
|
|
private readonly CacheService _cacheService;
|
|
public DiagnosisLevelAppService(
|
|
IRepository<DiagnosisLevel, short> repository,
|
|
IRepository<IdentityUser, Guid> userRepository,
|
|
DiagnosisLevelManager manager,
|
|
CacheService cacheService)
|
|
: base(repository)
|
|
{
|
|
_userRepository = userRepository;
|
|
_manager = manager;
|
|
_cacheService = cacheService;
|
|
}
|
|
/// <summary>
|
|
/// 获取通过主键
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public override async Task<DiagnosisLevelDto> GetAsync(short id)
|
|
{
|
|
return await base.GetAsync(id);
|
|
}
|
|
/// <summary>
|
|
/// 获取列表 诊断级别
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public override async Task<PagedResultDto<DiagnosisLevelDto>> GetListAsync(PagedAndSortedResultRequestDto input)
|
|
{
|
|
return await base.GetListAsync(input);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取列表 诊断级别 带搜索
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<DiagnosisLevelDto>> GetListInFilterAsync(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 DiagnosisLevelDto
|
|
{
|
|
CreationTime = s.CreationTime,
|
|
CreatorId = s.CreatorId,
|
|
DisplayName = s.DisplayName,
|
|
DisplayOrder = s.DisplayOrder,
|
|
Id = s.Id,
|
|
LastModificationTime = s.LastModificationTime,
|
|
LastModifierId = s.LastModifierId,
|
|
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
|
|
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
|
|
return entdto;
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public override async Task<DiagnosisLevelDto> CreateAsync(CreateDiagnosisLevelDto input)
|
|
{
|
|
return await base.CreateAsync(input);
|
|
}
|
|
/// <summary>
|
|
/// 更新
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public override async Task<DiagnosisLevelDto> UpdateAsync(short id, UpdateDiagnosisLevelDto input)
|
|
{
|
|
var entity = await Repository.GetAsync(id);
|
|
var sourceEntity = ObjectMapper.Map<UpdateDiagnosisLevelDto, DiagnosisLevel>(input);
|
|
await _manager.UpdateAsync(sourceEntity, entity);
|
|
entity = await Repository.UpdateAsync(entity);
|
|
return ObjectMapper.Map<DiagnosisLevel, DiagnosisLevelDto>(entity);
|
|
}
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public override Task DeleteAsync(short id)
|
|
{
|
|
return base.DeleteAsync(id);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 修改排序 置顶,置底
|
|
/// </summary>
|
|
/// <param name="id">需要修改的ID</param>
|
|
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/diagnosislevel/updatemanysort")]
|
|
public async Task UpdateManySortAsync(short id, int SortType)
|
|
{
|
|
await _manager.UpdateManySortAsync(id, SortType);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改排序 拖拽
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/diagnosislevel/updatesortmany")]
|
|
public async Task UpdateSortManyAsync(UpdateSortManyShortDto input)
|
|
{
|
|
await _manager.UpdateSortManyAsync(input);
|
|
}
|
|
}
|
|
}
|