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.
196 lines
7.4 KiB
196 lines
7.4 KiB
using AutoMapper.Internal.Mappers;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shentun.Peis.ItemResultTemplates;
|
|
using Shentun.Peis.GuidTypes;
|
|
using Shentun.Peis.HelperDto;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Application.Dtos;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Identity;
|
|
using Shentun.Peis.SexHormoneReferenceRanges;
|
|
using Shentun.Peis.Models;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace Shentun.Peis.ItemResultTemplates
|
|
{
|
|
|
|
/// <summary>
|
|
/// 项目结果模板
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class ItemResultTemplateAppService : CrudAppService<
|
|
ItemResultTemplate, //The Book entity
|
|
ItemResultTemplateDto, //Used to show books
|
|
Guid, //Primary key of the book entity
|
|
PagedAndSortedResultRequestDto, //Used for paging/sorting
|
|
CreateItemResultTemplateDto,
|
|
UpdateItemResultTemplateDto>
|
|
{
|
|
private readonly IRepository<IdentityUser, Guid> _userRepository;
|
|
private readonly ItemResultTemplateManager _manager;
|
|
public ItemResultTemplateAppService(
|
|
IRepository<ItemResultTemplate, Guid> repository,
|
|
IRepository<IdentityUser, Guid> userRepository,
|
|
ItemResultTemplateManager manager)
|
|
: base(repository)
|
|
{
|
|
this._userRepository = userRepository;
|
|
_manager = manager;
|
|
}
|
|
/// <summary>
|
|
/// 获取通过主键
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public override async Task<ItemResultTemplateDto> GetAsync(Guid id)
|
|
{
|
|
var entity = await Repository.FindAsync(o => o.Id == id);
|
|
//throw new Exception("标准异常测试");
|
|
//throw new BusinessException("业务异常测试");
|
|
//throw new UserFriendlyException("友好异常测试");
|
|
//throw new EntityNotFoundException("未发现实体异常测试");
|
|
//return null;
|
|
if (entity == null)
|
|
return null;
|
|
return ObjectMapper.Map<ItemResultTemplate, ItemResultTemplateDto>(entity);
|
|
|
|
}
|
|
/// <summary>
|
|
/// 获取列表 项目结果模板
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public override async Task<PagedResultDto<ItemResultTemplateDto>> GetListAsync(PagedAndSortedResultRequestDto input)
|
|
{
|
|
int totalCount = await Repository.CountAsync();
|
|
|
|
var entlist = await Repository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, input.Sorting);
|
|
var userList = await _userRepository.GetListAsync();
|
|
var entdto = entlist.Select(s => new ItemResultTemplateDto
|
|
{
|
|
CreationTime = s.CreationTime,
|
|
CreatorId = s.CreatorId,
|
|
ItemId = s.ItemId,
|
|
Id = s.Id,
|
|
LastModificationTime = s.LastModificationTime,
|
|
LastModifierId = s.LastModifierId,
|
|
DiagnosisId = s.DiagnosisId,
|
|
SimpleCode = s.SimpleCode,
|
|
ResultStatusId = s.ResultStatusId,
|
|
Result = s.Result,
|
|
IsResultIntoSummary = s.IsResultIntoSummary,
|
|
DisplayOrder = s.DisplayOrder,
|
|
IsNameIntoSummary = s.IsNameIntoSummary,
|
|
CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId),
|
|
LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId)
|
|
}).ToList();
|
|
|
|
return new PagedResultDto<ItemResultTemplateDto>(totalCount, entdto);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取项目结果模板列表 根据项目ID
|
|
/// </summary>
|
|
/// <param name="ItemId">项目ID</param>
|
|
/// <returns></returns>
|
|
public async Task<List<ItemResultTemplateDto>> GetListInItemIdAsync(Guid ItemId)
|
|
{
|
|
|
|
var entlist = await Repository.GetListAsync(m => m.ItemId == ItemId);
|
|
|
|
var userList = await _userRepository.GetListAsync();
|
|
|
|
var entdto = entlist.Select(s => new ItemResultTemplateDto
|
|
{
|
|
CreationTime = s.CreationTime,
|
|
CreatorId = s.CreatorId,
|
|
ItemId = s.ItemId,
|
|
Id = s.Id,
|
|
LastModificationTime = s.LastModificationTime,
|
|
LastModifierId = s.LastModifierId,
|
|
DiagnosisId = s.DiagnosisId,
|
|
SimpleCode = s.SimpleCode,
|
|
ResultStatusId = s.ResultStatusId,
|
|
Result = s.Result,
|
|
IsResultIntoSummary = s.IsResultIntoSummary,
|
|
DisplayOrder = s.DisplayOrder,
|
|
IsNameIntoSummary = s.IsNameIntoSummary,
|
|
CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId),
|
|
LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId)
|
|
}).ToList();
|
|
|
|
return entdto;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 创建
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public override async Task<ItemResultTemplateDto> CreateAsync(CreateItemResultTemplateDto input)
|
|
{
|
|
var createEntity = ObjectMapper.Map<CreateItemResultTemplateDto, ItemResultTemplate>(input);
|
|
var entity = await _manager.CreateAsync(createEntity);
|
|
entity = await Repository.InsertAsync(entity);
|
|
var dto = ObjectMapper.Map<ItemResultTemplate, ItemResultTemplateDto>(entity);
|
|
return dto;
|
|
}
|
|
/// <summary>
|
|
/// 更新
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public override async Task<ItemResultTemplateDto> UpdateAsync(Guid id, UpdateItemResultTemplateDto input)
|
|
{
|
|
var entity = await Repository.GetAsync(id);
|
|
var sourceEntity = ObjectMapper.Map<UpdateItemResultTemplateDto, ItemResultTemplate>(input);
|
|
_manager.UpdateAsync(sourceEntity, entity);
|
|
entity = await Repository.UpdateAsync(entity);
|
|
return ObjectMapper.Map<ItemResultTemplate, ItemResultTemplateDto>(entity);
|
|
}
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public override Task DeleteAsync(Guid id)
|
|
{
|
|
return base.DeleteAsync(id);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改排序 置顶,置底
|
|
/// </summary>
|
|
/// <param name="id">需要修改的ID</param>
|
|
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/itemresulttemplate/updatemanysort")]
|
|
public async Task UpdateManySortAsync(Guid id, int SortType)
|
|
{
|
|
await _manager.UpdateManySortAsync(id, SortType);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改排序 拖拽
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/itemresulttemplate/updatesortmany")]
|
|
public async Task UpdateSortManyAsync(UpdateSortManyDto input)
|
|
{
|
|
await _manager.UpdateSortManyAsync(input);
|
|
}
|
|
}
|
|
}
|