表单字段复制模板

master
ZR20090193-陈敬勇 9 months ago
parent 22ac514a70
commit c6d8650fc1

@ -268,5 +268,8 @@ public static class MultiLanguageConst
[Description("表单设置已存在")]
public const string FormSetExist = "Form_Set_Exist";
[Description("表单复制字段设置已存在")]
public const string FormCopyExist = "Form_Copy_Exist";
#endregion
}

@ -0,0 +1,57 @@
using DS.Module.Core;
using FluentValidation;
namespace DS.WMS.Core.Code.Dtos;
/// <summary>
/// 租户表单字段复制设置请求实体
/// </summary>
public class CodeFormCopyReq
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 权限Id
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 字段复制设置
/// </summary>
public string Content { get; set; }
/// <summary>
/// 排序
/// </summary>
public int? OrderNo { get; set; } = 100;
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
}
/// <summary>
/// 验证
/// </summary>
public class CodeFormCopyReqValidator : AbstractValidator<CodeFormCopyReq>
{
/// <summary>
/// 构造函数
/// </summary>
public CodeFormCopyReqValidator()
{
this.RuleFor(o => o.PermissionId)
.NotEmpty().WithName("权限模块Id");
this.RuleFor(o => o.Content)
.NotEmpty().WithName("字段复制设置");
}
}

@ -0,0 +1,54 @@
using DS.Module.Core;
namespace DS.WMS.Core.Code.Dtos;
/// <summary>
/// 租户表单字段复制设置返回实体
/// </summary>
public class CodeFormCopyRes
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 权限Id
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 字段设置
/// </summary>
public string Content { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string TemplateName { get; set; }
/// <summary>
/// 是否公共标识
/// </summary>
public bool IsPublic { get; set; } = false;
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 排序
/// </summary>
public int? OrderNo { get; set; } = 100;
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}

@ -18,6 +18,16 @@ public class CodeFormSetReq
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string TemplateName { get; set; }
/// <summary>
/// 是否公共标识
/// </summary>
public bool IsPublic { get; set; } = false;
/// <summary>
/// 表单设置
/// </summary>
@ -51,7 +61,9 @@ public class FormSetReqValidator : AbstractValidator<CodeFormSetReq>
{
this.RuleFor(o => o.PermissionId)
.NotEmpty().WithName("权限模块Id");
this.RuleFor(o => o.TemplateName)
.NotEmpty().WithName("模板名称");
this.RuleFor(o => o.Content)
.NotEmpty().WithName("中文视图名");
.NotEmpty().WithName("表单设置");
}
}

@ -0,0 +1,44 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Code.Entity;
/// <summary>
/// 租户表单字段复制模板
/// </summary>
[SqlSugar.SugarTable("op_code_form_copy")]
public class CodeFormCopy : BaseOrgModel<long>
{
/// <summary>
/// 权限Id
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string TemplateName { get; set; }
/// <summary>
/// 是否公共标识
/// </summary>
public bool IsPublic { get; set; } = false;
/// <summary>
/// 表单字段复制设置
/// </summary>
[SugarColumn(ColumnDescription = "表单字段复制设置", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string Content { get; set; }
/// <summary>
/// 排序号
/// </summary>
public string OrderNo { get; set; }
/// <summary>
/// 状态
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "状态")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
}

@ -0,0 +1,30 @@
using DS.Module.Core;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.System.Dtos;
namespace DS.WMS.Core.Code.Interface;
public interface IFormCopyService
{
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<CodeFormCopyRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult EditFormCopy(CodeFormCopyReq model);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<CodeFormCopyRes> GetFormCopyInfo(string id);
}

@ -0,0 +1,100 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.Code.Method;
public class CodeFormCopyService : IFormCopyService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public CodeFormCopyService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<CodeFormCopyRes>> GetListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeFormCopy>()
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Where(whereList)
.Select<CodeFormCopyRes>().ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult EditFormCopy(CodeFormCopyReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
if (tenantDb.Queryable<CodeFormCopy>()
.Where(x => x.OrgId == long.Parse(user.OrgId) && x.PermissionId == req.PermissionId && x.CreateBy == user.UserId).Any())
{
return DataResult.Failed("表单复制字段设置已存在!", MultiLanguageConst.FormCopyExist);
}
var data = req.Adapt<CodeFormCopy>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = tenantDb.Queryable<CodeFormCopy>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<CodeFormCopyRes> GetFormCopyInfo(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeFormCopy>()
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Where(x => x.Id == long.Parse(id))
.Select<CodeFormCopyRes>()
.First();
return DataResult<CodeFormCopyRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
}

@ -1,5 +1,6 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity;
@ -13,21 +14,22 @@ using SqlSugar;
namespace DS.WMS.Core.Code.Method;
public class FormSetService : IFormSetService
public class CodeFormSetService : IFormSetService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public FormSetService(IServiceProvider serviceProvider)
public CodeFormSetService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
/// <summary>
@ -37,9 +39,10 @@ public class FormSetService : IFormSetService
/// <returns></returns>
public DataResult<List<CodeFormSetRes>> GetListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<CodeFormSet>()
var data = tenantDb.Queryable<CodeFormSet>()
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Where(whereList)
.Select<CodeFormSetRes>().ToQueryPage(request.PageCondition);
@ -53,9 +56,10 @@ public class FormSetService : IFormSetService
/// <returns></returns>
public DataResult EditFormSet(CodeFormSetReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
if (db.Queryable<CodeFormSet>()
if (tenantDb.Queryable<CodeFormSet>()
.Where(x => x.OrgId == long.Parse(user.OrgId) && x.PermissionId == req.PermissionId).Any())
{
return DataResult.Failed("表单设置已存在!", MultiLanguageConst.FormSetExist);
@ -63,17 +67,17 @@ public class FormSetService : IFormSetService
var data = req.Adapt<CodeFormSet>();
var entity = db.Insertable(data).ExecuteReturnEntity();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = db.Queryable<CodeFormSet>().Where(x => x.Id == req.Id).First();
var info = tenantDb.Queryable<CodeFormSet>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
@ -85,7 +89,8 @@ public class FormSetService : IFormSetService
/// <returns></returns>
public DataResult<CodeFormSetRes> GetFormSetInfo(string id)
{
var data = db.Queryable<CodeFormSet>()
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeFormSet>()
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Where(x => x.Id == long.Parse(id))
.Select<CodeFormSetRes>()

@ -0,0 +1,64 @@
using DS.Module.Core;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.MainApi.Controllers;
/// <summary>
/// 表单字段复制设置 模块
/// </summary>
public class FormCopyController : ApiController
{
private readonly IFormCopyService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public FormCopyController(IFormCopyService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetFormCopyList")]
public DataResult<List<CodeFormCopyRes>> GetFormCopyList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("EditFormCopy")]
public DataResult EditFormCopy([FromBody] CodeFormCopyReq req)
{
var res = _invokeService.EditFormCopy(req);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="permissionId">权限Id</param>
/// <returns></returns>
[HttpGet]
[Route("GetFormCopyInfo")]
public DataResult<CodeFormCopyRes> GetFormCopyInfo([FromQuery] string permissionId)
{
var res = _invokeService.GetFormCopyInfo(permissionId);
return res;
}
}
Loading…
Cancel
Save