mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 02:29:24 +08:00
fix #I9J6WS 增加加签逻辑
This commit is contained in:
79
OpenAuth.App/FlowApproverApp/FlowApproverApp.cs
Normal file
79
OpenAuth.App/FlowApproverApp/FlowApproverApp.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
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;
|
||||
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class FlowApproverApp : BaseTreeApp<FlowApprover,OpenAuthDBContext>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public async Task<TableData> Load(QueryFlowApproverListReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 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; }
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace OpenAuth.App.Request
|
||||
{
|
||||
public class QueryFlowApproverListReq : PageReq
|
||||
{
|
||||
|
||||
}
|
||||
}
|
120
OpenAuth.Repository/Domain/FlowApprover.cs
Normal file
120
OpenAuth.Repository/Domain/FlowApprover.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 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.Repository.Domain
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Table("FlowApprover")]
|
||||
public class FlowApprover : TreeEntity
|
||||
{
|
||||
public FlowApprover()
|
||||
{
|
||||
this.Reason = "";
|
||||
this.ApproverName = "";
|
||||
this.InstanceId = "";
|
||||
this.VerifyComment = "";
|
||||
this.CascadeId = "";
|
||||
this.ApproverId = "";
|
||||
this.ApproveType = 0;
|
||||
this.CreateDate = DateTime.Now;
|
||||
this.CreateUserName = "";
|
||||
this.ParentId = "";
|
||||
this.VerifyDate = DateTime.Now;
|
||||
this.Status = 0;
|
||||
this.ActivityId = "";
|
||||
this.OrderNo = 0;
|
||||
this.CreateUserId = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///加签原因
|
||||
/// </summary>
|
||||
[Description("加签原因")]
|
||||
public string Reason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///审批人
|
||||
/// </summary>
|
||||
[Description("审批人")]
|
||||
public string ApproverName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///工作流实例Id
|
||||
/// </summary>
|
||||
[Description("工作流实例Id")]
|
||||
public string InstanceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///审批意见
|
||||
/// </summary>
|
||||
[Description("审批意见")]
|
||||
public string VerifyComment { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
///审批人ID
|
||||
/// </summary>
|
||||
[Description("审批人ID")]
|
||||
public string ApproverId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///类型(0顺序,1并行且,2并行或)
|
||||
/// </summary>
|
||||
[Description("类型(0顺序,1并行且,2并行或)")]
|
||||
public int ApproveType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///加签时间
|
||||
/// </summary>
|
||||
[Description("加签时间")]
|
||||
public DateTime? CreateDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///加签人
|
||||
/// </summary>
|
||||
[Description("加签人")]
|
||||
public string CreateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///审批日期
|
||||
/// </summary>
|
||||
[Description("审批日期")]
|
||||
public DateTime? VerifyDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///状态(0未处理,1通过,2未通过,3驳回)
|
||||
/// </summary>
|
||||
[Description("状态(0未处理,1通过,2未通过,3驳回)")]
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///当前节点ID
|
||||
/// </summary>
|
||||
[Description("当前节点ID")]
|
||||
public string ActivityId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///顺序号(当类型为0时)
|
||||
/// </summary>
|
||||
[Description("顺序号(当类型为0时)")]
|
||||
public int? OrderNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///加签人Id
|
||||
/// </summary>
|
||||
[Description("加签人Id")]
|
||||
public string CreateUserId { get; set; }
|
||||
}
|
||||
}
|
@@ -112,6 +112,7 @@ 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; }
|
||||
|
113
OpenAuth.WebApi/Controllers/FlowApproversController.cs
Normal file
113
OpenAuth.WebApi/Controllers/FlowApproversController.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 加签接口
|
||||
/// </summary>
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = "加签接口_FlowApprovers")]
|
||||
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)
|
||||
{
|
||||
var result = new Response();
|
||||
try
|
||||
{
|
||||
_app.Add(obj);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//修改
|
||||
[HttpPost]
|
||||
public Response Update(AddOrUpdateFlowApproverReq obj)
|
||||
{
|
||||
var result = new Response();
|
||||
try
|
||||
{
|
||||
_app.Update(obj);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public async Task<TableData> Load([FromQuery]QueryFlowApproverListReq request)
|
||||
{
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public Response Delete([FromBody]string[] ids)
|
||||
{
|
||||
var result = new Response();
|
||||
try
|
||||
{
|
||||
_app.Delete(ids);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public FlowApproversController(FlowApproverApp app)
|
||||
{
|
||||
_app = app;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user