OpenAuth.Net/OpenAuth.App/FlowApproverApp/FlowApproverApp.cs

61 lines
1.7 KiB
C#
Raw Normal View History

2024-09-22 21:22:18 +08:00
using System;
using System.Threading.Tasks;
using Infrastructure;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;
2024-09-25 21:30:56 +08:00
using SqlSugar;
2024-09-22 21:22:18 +08:00
namespace OpenAuth.App
{
2024-09-25 21:30:56 +08:00
public class FlowApproverApp : SqlSugarBaseApp<FlowApprover>
2024-09-22 21:22:18 +08:00
{
2024-09-25 21:30:56 +08:00
public void Add(AddApproverReq obj)
2024-09-22 21:22:18 +08:00
{
2024-09-25 21:30:56 +08:00
if (string.IsNullOrEmpty(obj.Id))
2024-09-22 21:22:18 +08:00
{
2024-09-25 21:30:56 +08:00
obj.Id = Guid.NewGuid().ToString();
2024-09-22 21:22:18 +08:00
}
var loginContext = _auth.GetCurrentUser();
if (loginContext == null)
{
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
}
2024-09-25 21:30:56 +08:00
2024-09-22 21:22:18 +08:00
var addObj = obj.MapTo<FlowApprover>();
CaculateCascade(addObj);
addObj.CreateDate = DateTime.Now;
addObj.CreateUserId = loginContext.User.Id;
addObj.CreateUserName = loginContext.User.Name;
addObj.Name = addObj.Id;
2024-09-25 21:30:56 +08:00
Repository.Insert(addObj);
2024-09-22 21:22:18 +08:00
}
2024-09-25 21:30:56 +08:00
public void Update(AddApproverReq application)
{
var updateobj = application.MapTo<FlowApprover>();
Repository.Update(updateobj);
2024-09-22 21:22:18 +08:00
}
2024-09-25 21:30:56 +08:00
/// <summary>
/// 加载当前节点的加签人
/// </summary>
public async Task<TableResp<FlowApprover>> Load(QueryApproverReq request)
{
var objs = await Repository.GetListAsync(u =>
u.InstanceId == request.FlowInstanceId && u.ActivityId == request.ActivityId);
return new TableResp<FlowApprover>()
{
data = objs
};
}
public FlowApproverApp(ISqlSugarClient client, IAuth auth) : base(client, auth)
2024-09-22 21:22:18 +08:00
{
}
}
}