fix #I9J6WS 增加加签逻辑

This commit is contained in:
yubaolee 2024-09-25 21:30:56 +08:00
parent 68e6b46e55
commit 13ba107c73
8 changed files with 152 additions and 166 deletions

View File

@ -1,78 +1,60 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Infrastructure;
using Microsoft.EntityFrameworkCore;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
using SqlSugar;
namespace OpenAuth.App
{
public class FlowApproverApp : BaseTreeApp<FlowApprover,OpenAuthDBContext>
public class FlowApproverApp : SqlSugarBaseApp<FlowApprover>
{
/// <summary>
/// 加载列表
/// </summary>
public async Task<TableData> Load(QueryFlowApproverListReq request)
public void Add(AddApproverReq obj)
{
var loginContext = _auth.GetCurrentUser();
if (loginContext == null)
if (string.IsNullOrEmpty(obj.Id))
{
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
}
var result = new TableData();
var objs = GetDataPrivilege("u");
if (!string.IsNullOrEmpty(request.key))
{
//增加筛选条件,如:
//objs = objs.Where(u => u.Name.Contains(request.key));
obj.Id = Guid.NewGuid().ToString();
}
result.data = objs.OrderBy(u => u.Id)
.Skip((request.page - 1) * request.limit)
.Take(request.limit);
result.count =await objs.CountAsync();
return result;
}
public void Add(AddOrUpdateFlowApproverReq obj)
{
var loginContext = _auth.GetCurrentUser();
if (loginContext == null)
{
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
}
//程序类型取入口应用的名称,可以根据自己需要调整
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;
Repository.Add(addObj);
Repository.Insert(addObj);
}
public void Update(AddApproverReq application)
{
var updateobj = application.MapTo<FlowApprover>();
Repository.Update(updateobj);
}
/// <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 void Update(AddOrUpdateFlowApproverReq obj)
{
UnitWork.Update<FlowApprover>(u => u.Id == obj.Id, u => new FlowApprover
{
//todo:要修改的字段赋值
});
}
public FlowApproverApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<FlowApprover,OpenAuthDBContext> repository, IAuth auth) : base(unitWork, repository, auth)
public FlowApproverApp(ISqlSugarClient client, IAuth auth) : base(client, auth)
{
}
}

View File

@ -0,0 +1,61 @@
//------------------------------------------------------------------------------
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
//------------------------------------------------------------------------------
namespace OpenAuth.App.Request
{
/// <summary>
/// 创建或修改加签信息
/// </summary>
public class AddApproverReq
{
/// <summary>
///Id
/// </summary>
public string Id { get; set; }
/// <summary>
///加签原因
/// </summary>
public string Reason { get; set; }
/// <summary>
///审批人
/// </summary>
public string ApproverName { get; set; }
/// <summary>
///工作流实例Id
/// </summary>
public string InstanceId { get; set; }
/// <summary>
///审批人ID
/// </summary>
public string ApproverId { get; set; }
/// <summary>
///类型0顺序1并行且2并行或
/// </summary>
public int ApproveType { get; set; }
/// <summary>
///父节点ID应对多次加签
/// </summary>
public string ParentId { get; set; }
/// <summary>
///当前节点ID
/// </summary>
public string ActivityId { get; set; }
/// <summary>
///顺序号当类型为0时
/// </summary>
public int? OrderNo { get; set; }
}
}

View File

@ -1,82 +0,0 @@
//------------------------------------------------------------------------------
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using OpenAuth.Repository.Core;
namespace OpenAuth.App.Request
{
/// <summary>
///
/// </summary>
public class AddOrUpdateFlowApproverReq
{
/// <summary>
///Id
/// </summary>
public string Id { get; set; }
/// <summary>
///加签原因
/// </summary>
public string Reason { get; set; }
/// <summary>
///审批人
/// </summary>
public string ApproverName { get; set; }
/// <summary>
///工作流实例Id
/// </summary>
public string InstanceId { get; set; }
/// <summary>
///审批意见
/// </summary>
public string VerifyComment { get; set; }
/// <summary>
///审批人ID
/// </summary>
public string ApproverId { get; set; }
/// <summary>
///类型0顺序1并行且2并行或
/// </summary>
public int ApproveType { get; set; }
/// <summary>
///父节点ID应对多次加签
/// </summary>
public string ParentId { get; set; }
/// <summary>
///审批日期
/// </summary>
public DateTime? VerifyDate { get; set; }
/// <summary>
///状态0未处理1通过2未通过3驳回
/// </summary>
public int Status { get; set; }
/// <summary>
///当前节点ID
/// </summary>
public string ActivityId { get; set; }
/// <summary>
///顺序号当类型为0时
/// </summary>
public int? OrderNo { get; set; }
}
}

View File

@ -0,0 +1,16 @@
namespace OpenAuth.App.Request
{
public class QueryApproverReq
{
/// <summary>
/// 获取或设置流程实例ID
/// </summary>
public string FlowInstanceId { get;set; }
/// <summary>
/// 节点Id
/// </summary>
public string ActivityId{ get;set; }
}
}

View File

@ -1,7 +0,0 @@
namespace OpenAuth.App.Request
{
public class QueryFlowApproverListReq : PageReq
{
}
}

View File

@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
//------------------------------------------------------------------------------
using System;
namespace OpenAuth.App.Request
{
/// <summary>
/// 审批加签节点
/// </summary>
public class VerifyApproverReq
{
/// <summary>
///Id
/// </summary>
public string Id { get; set; }
/// <summary>
///审批意见
/// </summary>
public string VerifyComment { get; set; }
/// <summary>
///审批日期
/// </summary>
public DateTime? VerifyDate { get; set; }
/// <summary>
///状态0未处理1通过2未通过3驳回
/// </summary>
public int Status { get; set; }
}
}

View File

@ -112,7 +112,6 @@ namespace OpenAuth.Repository
public virtual DbSet<Category> Categories { get; set; }
public virtual DbSet<CategoryType> CategoryTypes { get; set; }
public virtual DbSet<FlowInstance> FlowInstances { get; set; }
public virtual DbSet<FlowApprover> FlowApprovers { get; set; }
public virtual DbSet<FlowInstanceOperationHistory> FlowInstanceOperationHistorys { get; set; }
public virtual DbSet<FlowInstanceTransitionHistory> FlowInstanceTransitionHistorys { get; set; }
public virtual DbSet<FlowScheme> FlowSchemes { get; set; }

View File

@ -18,34 +18,15 @@ namespace OpenAuth.WebApi.Controllers
public class FlowApproversController : ControllerBase
{
private readonly FlowApproverApp _app;
//获取详情
[HttpGet]
public Response<FlowApprover> Get(string id)
{
var result = new Response<FlowApprover>();
try
{
result.Result = _app.Get(id);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
//添加
[HttpPost]
public Response Add(AddOrUpdateFlowApproverReq obj)
[HttpPost]
public Response Add(AddApproverReq obj)
{
var result = new Response();
try
{
_app.Add(obj);
}
catch (Exception ex)
{
@ -57,14 +38,13 @@ namespace OpenAuth.WebApi.Controllers
}
//修改
[HttpPost]
public Response Update(AddOrUpdateFlowApproverReq obj)
[HttpPost]
public Response Update(AddApproverReq obj)
{
var result = new Response();
try
{
_app.Update(obj);
}
catch (Exception ex)
{
@ -79,7 +59,7 @@ namespace OpenAuth.WebApi.Controllers
/// 加载列表
/// </summary>
[HttpGet]
public async Task<TableData> Load([FromQuery]QueryFlowApproverListReq request)
public async Task<TableResp<FlowApprover>> Load([FromQuery] QueryApproverReq request)
{
return await _app.Load(request);
}
@ -87,14 +67,13 @@ namespace OpenAuth.WebApi.Controllers
/// <summary>
/// 批量删除
/// </summary>
[HttpPost]
public Response Delete([FromBody]string[] ids)
[HttpPost]
public Response Delete([FromBody] string[] ids)
{
var result = new Response();
try
{
_app.Delete(ids);
}
catch (Exception ex)
{
@ -105,9 +84,9 @@ namespace OpenAuth.WebApi.Controllers
return result;
}
public FlowApproversController(FlowApproverApp app)
public FlowApproversController(FlowApproverApp app)
{
_app = app;
}
}
}
}