diff --git a/OpenAuth.App/FlowApproverApp/FlowApproverApp.cs b/OpenAuth.App/FlowApproverApp/FlowApproverApp.cs index 4df7f088..ed7d8e28 100644 --- a/OpenAuth.App/FlowApproverApp/FlowApproverApp.cs +++ b/OpenAuth.App/FlowApproverApp/FlowApproverApp.cs @@ -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 + public class FlowApproverApp : SqlSugarBaseApp { - - /// - /// 加载列表 - /// - public async Task 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(); 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(); + Repository.Update(updateobj); + } + + /// + /// 加载当前节点的加签人 + /// + public async Task> Load(QueryApproverReq request) + { + var objs = await Repository.GetListAsync(u => + u.InstanceId == request.FlowInstanceId && u.ActivityId == request.ActivityId); + return new TableResp() + { + data = objs + }; } - public void Update(AddOrUpdateFlowApproverReq obj) - { - UnitWork.Update(u => u.Id == obj.Id, u => new FlowApprover - { - //todo:要修改的字段赋值 - }); - - } - - public FlowApproverApp(IUnitWork unitWork, IRepository repository, IAuth auth) : base(unitWork, repository, auth) + public FlowApproverApp(ISqlSugarClient client, IAuth auth) : base(client, auth) { } } diff --git a/OpenAuth.App/FlowApproverApp/Request/AddApproverReq.cs b/OpenAuth.App/FlowApproverApp/Request/AddApproverReq.cs new file mode 100644 index 00000000..2f46bd39 --- /dev/null +++ b/OpenAuth.App/FlowApproverApp/Request/AddApproverReq.cs @@ -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 +{ + /// + /// 创建或修改加签信息 + /// + public class AddApproverReq + { + /// + ///Id + /// + public string Id { get; set; } + + /// + ///加签原因 + /// + public string Reason { get; set; } + + /// + ///审批人 + /// + public string ApproverName { get; set; } + + /// + ///工作流实例Id + /// + public string InstanceId { get; set; } + + /// + ///审批人ID + /// + public string ApproverId { get; set; } + + /// + ///类型(0顺序,1并行且,2并行或) + /// + public int ApproveType { get; set; } + + /// + ///父节点ID,应对多次加签 + /// + public string ParentId { get; set; } + + /// + ///当前节点ID + /// + public string ActivityId { get; set; } + + /// + ///顺序号(当类型为0时) + /// + public int? OrderNo { get; set; } + } +} \ No newline at end of file diff --git a/OpenAuth.App/FlowApproverApp/Request/AddOrUpdateFlowApproverReq.cs b/OpenAuth.App/FlowApproverApp/Request/AddOrUpdateFlowApproverReq.cs deleted file mode 100644 index ea562f31..00000000 --- a/OpenAuth.App/FlowApproverApp/Request/AddOrUpdateFlowApproverReq.cs +++ /dev/null @@ -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 -{ - /// - /// - /// - - public class AddOrUpdateFlowApproverReq - { - /// - ///Id - /// - public string Id { get; set; } - - /// - ///加签原因 - /// - public string Reason { get; set; } - - /// - ///审批人 - /// - public string ApproverName { get; set; } - - /// - ///工作流实例Id - /// - public string InstanceId { get; set; } - - /// - ///审批意见 - /// - public string VerifyComment { get; set; } - - /// - ///审批人ID - /// - public string ApproverId { get; set; } - - /// - ///类型(0顺序,1并行且,2并行或) - /// - public int ApproveType { get; set; } - - /// - ///父节点ID,应对多次加签 - /// - public string ParentId { get; set; } - - /// - ///审批日期 - /// - public DateTime? VerifyDate { get; set; } - - /// - ///状态(0未处理,1通过,2未通过,3驳回) - /// - public int Status { get; set; } - - /// - ///当前节点ID - /// - public string ActivityId { get; set; } - - /// - ///顺序号(当类型为0时) - /// - public int? OrderNo { get; set; } - - } -} \ No newline at end of file diff --git a/OpenAuth.App/FlowApproverApp/Request/QueryApproverReq.cs b/OpenAuth.App/FlowApproverApp/Request/QueryApproverReq.cs new file mode 100644 index 00000000..47520042 --- /dev/null +++ b/OpenAuth.App/FlowApproverApp/Request/QueryApproverReq.cs @@ -0,0 +1,16 @@ +namespace OpenAuth.App.Request +{ + public class QueryApproverReq + { + /// + /// 获取或设置流程实例ID + /// + public string FlowInstanceId { get;set; } + + /// + /// 节点Id + /// + public string ActivityId{ get;set; } + + } +} diff --git a/OpenAuth.App/FlowApproverApp/Request/QueryFlowApproverListReq.cs b/OpenAuth.App/FlowApproverApp/Request/QueryFlowApproverListReq.cs deleted file mode 100644 index df5e58fa..00000000 --- a/OpenAuth.App/FlowApproverApp/Request/QueryFlowApproverListReq.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace OpenAuth.App.Request -{ - public class QueryFlowApproverListReq : PageReq - { - - } -} diff --git a/OpenAuth.App/FlowApproverApp/Request/VerifyApproverReq.cs b/OpenAuth.App/FlowApproverApp/Request/VerifyApproverReq.cs new file mode 100644 index 00000000..f0cf193f --- /dev/null +++ b/OpenAuth.App/FlowApproverApp/Request/VerifyApproverReq.cs @@ -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 +{ + /// + /// 审批加签节点 + /// + public class VerifyApproverReq + { + /// + ///Id + /// + public string Id { get; set; } + + /// + ///审批意见 + /// + public string VerifyComment { get; set; } + + /// + ///审批日期 + /// + public DateTime? VerifyDate { get; set; } + + /// + ///状态(0未处理,1通过,2未通过,3驳回) + /// + public int Status { get; set; } + } +} \ No newline at end of file diff --git a/OpenAuth.Repository/OpenAuthDBContext.cs b/OpenAuth.Repository/OpenAuthDBContext.cs index 2efa22be..d73864dd 100644 --- a/OpenAuth.Repository/OpenAuthDBContext.cs +++ b/OpenAuth.Repository/OpenAuthDBContext.cs @@ -112,7 +112,6 @@ namespace OpenAuth.Repository public virtual DbSet Categories { get; set; } public virtual DbSet CategoryTypes { get; set; } public virtual DbSet FlowInstances { get; set; } - public virtual DbSet FlowApprovers { get; set; } public virtual DbSet FlowInstanceOperationHistorys { get; set; } public virtual DbSet FlowInstanceTransitionHistorys { get; set; } public virtual DbSet FlowSchemes { get; set; } diff --git a/OpenAuth.WebApi/Controllers/FlowApproversController.cs b/OpenAuth.WebApi/Controllers/FlowApproversController.cs index b2a89a45..d3ba6fd0 100644 --- a/OpenAuth.WebApi/Controllers/FlowApproversController.cs +++ b/OpenAuth.WebApi/Controllers/FlowApproversController.cs @@ -18,34 +18,15 @@ namespace OpenAuth.WebApi.Controllers public class FlowApproversController : ControllerBase { private readonly FlowApproverApp _app; - - //获取详情 - [HttpGet] - public Response Get(string id) - { - var result = new Response(); - 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 /// 加载列表 /// [HttpGet] - public async Task Load([FromQuery]QueryFlowApproverListReq request) + public async Task> Load([FromQuery] QueryApproverReq request) { return await _app.Load(request); } @@ -87,14 +67,13 @@ namespace OpenAuth.WebApi.Controllers /// /// 批量删除 /// - [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; } } -} +} \ No newline at end of file