2021-04-15 00:40:30 +08:00
|
|
|
|
using System;
|
2025-04-06 02:02:30 +08:00
|
|
|
|
using System.Collections.Generic;
|
2021-04-15 00:40:30 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2025-04-06 02:02:30 +08:00
|
|
|
|
using Infrastructure;
|
2021-04-15 00:40:30 +08:00
|
|
|
|
using OpenAuth.App.Interface;
|
|
|
|
|
using OpenAuth.App.Request;
|
|
|
|
|
using OpenAuth.App.Response;
|
|
|
|
|
using OpenAuth.Repository.Domain;
|
2025-04-06 21:24:18 +08:00
|
|
|
|
using SqlSugar;
|
2021-04-15 00:40:30 +08:00
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App
|
|
|
|
|
{
|
2025-04-06 21:24:18 +08:00
|
|
|
|
public class FlowSchemeApp :SqlSugarBaseApp<FlowScheme>
|
2021-04-15 00:40:30 +08:00
|
|
|
|
{
|
|
|
|
|
public void Add(FlowScheme flowScheme)
|
|
|
|
|
{
|
2025-04-06 21:24:18 +08:00
|
|
|
|
if (Repository.IsAny(u => u.SchemeName == flowScheme.SchemeName))
|
2021-04-15 00:40:30 +08:00
|
|
|
|
{
|
|
|
|
|
throw new Exception("流程名称已经存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var user = _auth.GetCurrentUser().User;
|
|
|
|
|
flowScheme.CreateUserId = user.Id;
|
|
|
|
|
flowScheme.CreateUserName = user.Name;
|
2025-04-06 21:24:18 +08:00
|
|
|
|
Repository.Insert(flowScheme);
|
2021-04-15 00:40:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FlowScheme FindByCode(string code)
|
|
|
|
|
{
|
2025-04-06 21:24:18 +08:00
|
|
|
|
return Repository.GetFirst(u => u.SchemeCode == code);
|
2021-04-15 00:40:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(FlowScheme flowScheme)
|
|
|
|
|
{
|
2025-04-06 21:24:18 +08:00
|
|
|
|
if (Repository.IsAny(u => u.SchemeName == flowScheme.SchemeName && u.Id != flowScheme.Id))
|
2021-04-15 00:40:30 +08:00
|
|
|
|
{
|
|
|
|
|
throw new Exception("流程名称已经存在");
|
|
|
|
|
}
|
2025-04-06 21:24:18 +08:00
|
|
|
|
|
|
|
|
|
Repository.Update(u => new FlowScheme
|
2021-04-15 00:40:30 +08:00
|
|
|
|
{
|
2025-04-11 01:22:53 +08:00
|
|
|
|
SchemeContent = flowScheme.SchemeContent,
|
2021-04-15 00:40:30 +08:00
|
|
|
|
SchemeName = flowScheme.SchemeName,
|
|
|
|
|
ModifyDate = DateTime.Now,
|
|
|
|
|
FrmId = flowScheme.FrmId,
|
|
|
|
|
FrmType = flowScheme.FrmType,
|
2025-04-06 21:24:18 +08:00
|
|
|
|
FrmUrlTemplate = flowScheme.FrmUrlTemplate,
|
2021-04-15 00:40:30 +08:00
|
|
|
|
Disabled = flowScheme.Disabled,
|
|
|
|
|
Description = flowScheme.Description,
|
|
|
|
|
OrgId = flowScheme.OrgId
|
2025-04-06 21:24:18 +08:00
|
|
|
|
},u => u.Id == flowScheme.Id);
|
2021-04-15 00:40:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-04-06 02:02:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载所有流程表单为URL表单的流程模板
|
|
|
|
|
/// <para>
|
|
|
|
|
/// 目前业务系统只挂载URL表单,后期优化挂载其他表单类型
|
|
|
|
|
/// </para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<FlowScheme> LoadUrlFormFlowScheme()
|
|
|
|
|
{
|
2025-04-06 21:24:18 +08:00
|
|
|
|
return Repository.GetList(u => u.FrmType == Define.FORM_TYPE_URL);
|
2025-04-06 02:02:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-04-15 00:40:30 +08:00
|
|
|
|
public async Task<TableData> Load(QueryFlowSchemeListReq request)
|
|
|
|
|
{
|
|
|
|
|
var result = new TableData();
|
|
|
|
|
var objs = GetDataPrivilege("u");
|
|
|
|
|
if (!string.IsNullOrEmpty(request.key))
|
|
|
|
|
{
|
|
|
|
|
objs = objs.Where(u => u.SchemeName.Contains(request.key) || u.Id.Contains(request.key));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-18 00:42:29 +08:00
|
|
|
|
result.data = await objs.OrderByDescending(u => u.CreateDate)
|
2021-04-15 00:40:30 +08:00
|
|
|
|
.Skip((request.page - 1) * request.limit)
|
2021-10-18 00:42:29 +08:00
|
|
|
|
.Take(request.limit).ToListAsync();
|
|
|
|
|
result.count = await objs.CountAsync();
|
2021-04-15 00:40:30 +08:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-06 21:24:18 +08:00
|
|
|
|
public FlowSchemeApp(ISqlSugarClient client, IAuth auth) : base(client, auth)
|
2021-04-15 00:40:30 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|