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.
136 lines
5.2 KiB
136 lines
5.2 KiB
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shentun.Peis.HelperDto;
|
|
using Shentun.Peis.Items;
|
|
using Shentun.Peis.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.ObjectMapping;
|
|
using Volo.Abp.Users;
|
|
|
|
namespace Shentun.Peis.ThirdInterfaces
|
|
{
|
|
/// <summary>
|
|
/// 第三方接口
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class ThirdInterfaceAppService : ApplicationService
|
|
{
|
|
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository;
|
|
private readonly CacheService _cacheService;
|
|
private readonly ThirdInterfaceManager _thirdInterfaceManager;
|
|
|
|
public ThirdInterfaceAppService(
|
|
IRepository<ThirdInterface, Guid> thirdInterfaceRepository,
|
|
CacheService cacheService,
|
|
ThirdInterfaceManager thirdInterfaceManager)
|
|
{
|
|
_thirdInterfaceRepository = thirdInterfaceRepository;
|
|
_cacheService = cacheService;
|
|
_thirdInterfaceManager = thirdInterfaceManager;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 查询列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ThirdInterface/GetList")]
|
|
public async Task<List<ThirdInterfaceDto>> GetListAsync()
|
|
{
|
|
var thirdInterfaceList = await _thirdInterfaceRepository.GetQueryableAsync();
|
|
return thirdInterfaceList.Select(s => new ThirdInterfaceDto
|
|
{
|
|
CreationTime = s.CreationTime,
|
|
CreatorId = s.CreatorId,
|
|
DisplayName = s.DisplayName,
|
|
DisplayOrder = s.DisplayOrder,
|
|
Id = s.Id,
|
|
IsActive = s.IsActive,
|
|
LastModificationTime = s.LastModificationTime,
|
|
LastModifierId = s.LastModifierId,
|
|
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
|
|
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result,
|
|
MedicalCenterId = s.MedicalCenterId,
|
|
ParmValue = s.ParmValue,
|
|
ThirdInterfaceType = s.ThirdInterfaceType
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 创建
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ThirdInterface/Create")]
|
|
public async Task<ThirdInterfaceDto> CreateAsync(CreateThirdInterfaceDto input)
|
|
{
|
|
var createEntity = ObjectMapper.Map<CreateThirdInterfaceDto, ThirdInterface>(input);
|
|
var entity = await _thirdInterfaceManager.CreateAsync(createEntity);
|
|
entity = await _thirdInterfaceRepository.InsertAsync(entity);
|
|
var dto = ObjectMapper.Map<ThirdInterface, ThirdInterfaceDto>(entity);
|
|
dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId);
|
|
dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId);
|
|
return dto;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ThirdInterface/Update")]
|
|
public async Task<ThirdInterfaceDto> UpdateAsync(UpdateThirdInterfaceDto input)
|
|
{
|
|
var entity = await _thirdInterfaceRepository.GetAsync(input.Id);
|
|
var sourceEntity = ObjectMapper.Map<UpdateThirdInterfaceDto, ThirdInterface>(input);
|
|
_thirdInterfaceManager.UpdateAsync(sourceEntity, entity);
|
|
entity = await _thirdInterfaceRepository.UpdateAsync(entity);
|
|
var dto = ObjectMapper.Map<ThirdInterface, ThirdInterfaceDto>(entity);
|
|
dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId);
|
|
dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId);
|
|
return dto;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ThirdInterface/Update")]
|
|
public async Task DeleteAsync(DeleteThirdInterfaceDto input)
|
|
{
|
|
await _thirdInterfaceManager.CheckAndDeleteAsync(input.Id);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改排序 置顶,置底
|
|
/// </summary>
|
|
/// <param name="id">需要修改的ID</param>
|
|
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/ThirdInterface/UpdateManySort")]
|
|
public async Task UpdateManySortAsync(Guid id, int SortType)
|
|
{
|
|
await _thirdInterfaceManager.UpdateManySortAsync(id, SortType);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改排序 拖拽
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("api/app/ThirdInterface/UpdateSortMany")]
|
|
public async Task UpdateSortManyAsync(UpdateSortManyDto input)
|
|
{
|
|
await _thirdInterfaceManager.UpdateSortManyAsync(input);
|
|
}
|
|
}
|
|
}
|