using Furion.DependencyInjection;
using Furion.DistributedIDGenerator;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Myshipping.Application.Entity;
using Myshipping.Core;
using System;
using System.Collections.Generic;
using System.DirectoryServices.ActiveDirectory;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.TaskManagePlat
{
///
/// 租户任务流程配置
///
[ApiDescriptionSettings("Application", Name = "TaskFlowTenant", Order = 10)]
public class TaskFlowTenantService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository _rep;
public TaskFlowTenantService(SqlSugarRepository rep)
{
_rep = rep;
}
///
/// 分页查询租户任务流程配置
///
///
///
[HttpPost]
[ApiDescriptionSettings(Name = "Page")]
public async Task> Page(TaskFlowTenantInput input)
{
var query = _rep.AsQueryable()
.Select(u => new TaskFlowTenant
{
PK_ID = u.PK_ID,
FlowCode = u.FlowCode,
MethodName = u.MethodName,
PId = u.PId,
IsMain = u.IsMain,
IsBoolReturn = u.IsBoolReturn,
TrueMethod = u.TrueMethod,
FalseMethod = u.FalseMethod,
TaskApiId = u.TaskApiId,
SYSTEM_CODE = u.SYSTEM_CODE,
SYSTEM_NAME = u.SYSTEM_NAME
});
return await query.ToPagedListAsync(input.PageNo, input.PageSize);
}
///
/// 增加租户任务流程配置
///
///
///
[HttpPost]
[ApiDescriptionSettings(Name = "Add")]
public async Task Add(AddTaskFlowTenantInput input)
{
var entity = input.Adapt();
entity.PK_ID = IDGen.NextID().ToString();
await _rep.InsertAsync(entity);
}
///
/// 删除租户任务流程配置
///
///
///
[HttpPost]
[ApiDescriptionSettings(Name = "Delete")]
public async Task Delete(DeleteTaskFlowTenantInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.PK_ID == input.PK_ID) ?? throw Oops.Oh("数据不存在");
entity.IsDeleted = true;
await _rep.UpdateAsync(entity);
}
///
/// 更新租户任务流程配置
///
///
///
[HttpPost]
[ApiDescriptionSettings(Name = "Update")]
public async Task Update(UpdateTaskFlowTenantInput input)
{
var entity = input.Adapt();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
///
/// 获取租户任务流程配置
///
///
///
[HttpPost]
[ApiDescriptionSettings(Name = "Detail")]
public async Task Get(GetTaskFlowTenantInfoInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.PK_ID == input.PK_ID);
}
///
/// 获取租户任务流程配置
///
///
///
[HttpGet]
[ApiDescriptionSettings(Name = "List")]
public async Task> List([FromQuery] TaskFlowTenantInput input)
{
return await _rep.AsQueryable().Select().ToListAsync();
}
}
}