|
|
|
|
using Furion;
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Service.Fee.Dto;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application.Service.TaskManagePlat
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务API配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "TaskAPI", Order = 10)]
|
|
|
|
|
public class TaskAPIService : IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<TaskAPIInfo> _rep;
|
|
|
|
|
public TaskAPIService(SqlSugarRepository<TaskAPIInfo> rep)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询任务API配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Page")]
|
|
|
|
|
public async Task<SqlSugarPagedList<TaskAPIInfo>> Page(TaskAPIInput input)
|
|
|
|
|
{
|
|
|
|
|
var query = _rep.AsQueryable()
|
|
|
|
|
.Select(u => new TaskAPIInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = u.PK_ID,
|
|
|
|
|
APIName = u.APIName,
|
|
|
|
|
URL = u.URL,
|
|
|
|
|
RequestMethod = u.RequestMethod,
|
|
|
|
|
Key = u.Key,
|
|
|
|
|
SecretKey = u.SecretKey,
|
|
|
|
|
SYSTEM_CODE = u.SYSTEM_CODE,
|
|
|
|
|
SYSTEM_NAME = u.SYSTEM_NAME
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return await query.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加任务API配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Add")]
|
|
|
|
|
public async Task Add(AddTaskAPIInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<TaskAPIInfo>();
|
|
|
|
|
entity.PK_ID = IDGen.NextID().ToString();
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除任务API配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Delete")]
|
|
|
|
|
public async Task Delete(DeleteTaskAPIInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _rep.FirstOrDefaultAsync(u => u.PK_ID == input.PK_ID) ?? throw Oops.Oh("数据不存在");
|
|
|
|
|
entity.IsDeleted = true;
|
|
|
|
|
await _rep.UpdateAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新任务API配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Update")]
|
|
|
|
|
public async Task Update(UpdateTaskAPIInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<TaskAPIInfo>();
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取任务API配置详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Detail")]
|
|
|
|
|
public async Task<TaskAPIInfo> Get(GetTaskApiInfoInput input)
|
|
|
|
|
{
|
|
|
|
|
return await _rep.FirstOrDefaultAsync(u => u.PK_ID == input.PK_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取任务API配置列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[ApiDescriptionSettings(Name = "List")]
|
|
|
|
|
public async Task<List<TaskAPIInfo>> List([FromQuery] TaskAPIInput input)
|
|
|
|
|
{
|
|
|
|
|
return await _rep.AsQueryable().Select<TaskAPIInfo>().ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|