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 { /// /// 第三方接口 /// [ApiExplorerSettings(GroupName = "Work")] [Authorize] public class ThirdInterfaceAppService : ApplicationService { private readonly IRepository _thirdInterfaceRepository; private readonly CacheService _cacheService; private readonly ThirdInterfaceManager _thirdInterfaceManager; public ThirdInterfaceAppService( IRepository thirdInterfaceRepository, CacheService cacheService, ThirdInterfaceManager thirdInterfaceManager) { _thirdInterfaceRepository = thirdInterfaceRepository; _cacheService = cacheService; _thirdInterfaceManager = thirdInterfaceManager; } /// /// 查询列表 /// /// [HttpPost("api/app/ThirdInterface/GetList")] public async Task> 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(); } /// /// 创建 /// /// [HttpPost("api/app/ThirdInterface/Create")] public async Task CreateAsync(CreateThirdInterfaceDto input) { var createEntity = ObjectMapper.Map(input); var entity = await _thirdInterfaceManager.CreateAsync(createEntity); entity = await _thirdInterfaceRepository.InsertAsync(entity); var dto = ObjectMapper.Map(entity); dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); return dto; } /// /// 更新 /// /// /// [HttpPost("api/app/ThirdInterface/Update")] public async Task UpdateAsync(UpdateThirdInterfaceDto input) { var entity = await _thirdInterfaceRepository.GetAsync(input.Id); var sourceEntity = ObjectMapper.Map(input); _thirdInterfaceManager.UpdateAsync(sourceEntity, entity); entity = await _thirdInterfaceRepository.UpdateAsync(entity); var dto = ObjectMapper.Map(entity); dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); return dto; } /// /// 删除 /// /// /// [HttpPost("api/app/ThirdInterface/Update")] public async Task DeleteAsync(DeleteThirdInterfaceDto input) { await _thirdInterfaceManager.CheckAndDeleteAsync(input.Id); } /// /// 修改排序 置顶,置底 /// /// 需要修改的ID /// 修改方式:1 置顶 2 置底 /// [HttpPut("api/app/ThirdInterface/UpdateManySort")] public async Task UpdateManySortAsync(Guid id, int SortType) { await _thirdInterfaceManager.UpdateManySortAsync(id, SortType); } /// /// 修改排序 拖拽 /// /// /// [HttpPut("api/app/ThirdInterface/UpdateSortMany")] public async Task UpdateSortManyAsync(UpdateSortManyDto input) { await _thirdInterfaceManager.UpdateSortManyAsync(input); } } }