From c6d8650fc1e5213d6da15073607b78d79eb27c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ZR20090193-=E9=99=88=E6=95=AC=E5=8B=87?= Date: Tue, 12 Mar 2024 15:13:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E5=AD=97=E6=AE=B5=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constants/MultiLanguageConst.cs | 3 + .../DS.WMS.Core/Code/Dtos/CodeFormCopyReq.cs | 57 ++++++++++ .../DS.WMS.Core/Code/Dtos/CodeFormCopyRes.cs | 54 ++++++++++ .../DS.WMS.Core/Code/Dtos/CodeFormSetReq.cs | 14 ++- .../DS.WMS.Core/Code/Entity/CodeFormCopy.cs | 44 ++++++++ .../Code/Interface/IFormCopyService.cs | 30 ++++++ .../Code/Method/CodeFormCopyService.cs | 100 ++++++++++++++++++ ...ormSetService.cs => CodeFormSetService.cs} | 23 ++-- .../Controllers/FormCopyController.cs | 64 +++++++++++ 9 files changed, 379 insertions(+), 10 deletions(-) create mode 100644 ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormCopyReq.cs create mode 100644 ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormCopyRes.cs create mode 100644 ds-wms-service/DS.WMS.Core/Code/Entity/CodeFormCopy.cs create mode 100644 ds-wms-service/DS.WMS.Core/Code/Interface/IFormCopyService.cs create mode 100644 ds-wms-service/DS.WMS.Core/Code/Method/CodeFormCopyService.cs rename ds-wms-service/DS.WMS.Core/Code/Method/{FormSetService.cs => CodeFormSetService.cs} (73%) create mode 100644 ds-wms-service/DS.WMS.MainApi/Controllers/FormCopyController.cs diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index ea720416..96a3aa2d 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -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 } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormCopyReq.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormCopyReq.cs new file mode 100644 index 00000000..f458e74a --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormCopyReq.cs @@ -0,0 +1,57 @@ +using DS.Module.Core; +using FluentValidation; + +namespace DS.WMS.Core.Code.Dtos; + +/// +/// 租户表单字段复制设置请求实体 +/// +public class CodeFormCopyReq +{ + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 权限Id + /// + public long? PermissionId { get; set; } + + /// + /// 字段复制设置 + /// + public string Content { get; set; } + + /// + /// 排序 + /// + public int? OrderNo { get; set; } = 100; + + /// + /// 状态 0 启用 1 禁用 + /// + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 备注 + /// + public string Note { get; set; } = ""; +} + + +/// +/// 验证 +/// +public class CodeFormCopyReqValidator : AbstractValidator +{ + /// + /// 构造函数 + /// + public CodeFormCopyReqValidator() + { + this.RuleFor(o => o.PermissionId) + .NotEmpty().WithName("权限模块Id"); + this.RuleFor(o => o.Content) + .NotEmpty().WithName("字段复制设置"); + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormCopyRes.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormCopyRes.cs new file mode 100644 index 00000000..63a3c414 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormCopyRes.cs @@ -0,0 +1,54 @@ +using DS.Module.Core; + +namespace DS.WMS.Core.Code.Dtos; + +/// +/// 租户表单字段复制设置返回实体 +/// +public class CodeFormCopyRes +{ + + /// + /// 主键Id + /// + public long Id { get; set; } + /// + /// 权限Id + /// + public long? PermissionId { get; set; } + + /// + /// 字段设置 + /// + public string Content { get; set; } + + + /// + /// 模板名称 + /// + public string TemplateName { get; set; } + + /// + /// 是否公共标识 + /// + public bool IsPublic { get; set; } = false; + + + /// + /// 状态 0 启用 1 禁用 + /// + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 备注 + /// + public string Note { get; set; } = ""; + /// + /// 排序 + /// + public int? OrderNo { get; set; } = 100; + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormSetReq.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormSetReq.cs index 8521ba08..0a8de48a 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormSetReq.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormSetReq.cs @@ -18,6 +18,16 @@ public class CodeFormSetReq /// public long? PermissionId { get; set; } + /// + /// 模板名称 + /// + public string TemplateName { get; set; } + + /// + /// 是否公共标识 + /// + public bool IsPublic { get; set; } = false; + /// /// 表单设置 /// @@ -51,7 +61,9 @@ public class FormSetReqValidator : AbstractValidator { this.RuleFor(o => o.PermissionId) .NotEmpty().WithName("权限模块Id"); + this.RuleFor(o => o.TemplateName) + .NotEmpty().WithName("模板名称"); this.RuleFor(o => o.Content) - .NotEmpty().WithName("中文视图名"); + .NotEmpty().WithName("表单设置"); } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeFormCopy.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeFormCopy.cs new file mode 100644 index 00000000..9803d92e --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeFormCopy.cs @@ -0,0 +1,44 @@ +using DS.Module.Core; +using DS.Module.Core.Data; +using SqlSugar; + +namespace DS.WMS.Core.Code.Entity; + +/// +/// 租户表单字段复制模板 +/// +[SqlSugar.SugarTable("op_code_form_copy")] +public class CodeFormCopy : BaseOrgModel +{ + /// + /// 权限Id + /// + public long? PermissionId { get; set; } + + /// + /// 模板名称 + /// + public string TemplateName { get; set; } + + /// + /// 是否公共标识 + /// + public bool IsPublic { get; set; } = false; + + /// + /// 表单字段复制设置 + /// + [SugarColumn(ColumnDescription = "表单字段复制设置", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string Content { get; set; } + + /// + /// 排序号 + /// + public string OrderNo { get; set; } + + /// + /// 状态 + /// + [SqlSugar.SugarColumn(ColumnDescription = "状态")] + public StatusEnum? Status { get; set; } = StatusEnum.Enable; +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/IFormCopyService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/IFormCopyService.cs new file mode 100644 index 00000000..22b98474 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/IFormCopyService.cs @@ -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 +{ + /// + /// 列表 + /// + /// + /// + DataResult> GetListByPage(PageRequest request); + + + /// + /// 编辑 + /// + /// + /// + DataResult EditFormCopy(CodeFormCopyReq model); + + /// + /// 获取详情 + /// + /// + /// + DataResult GetFormCopyInfo(string id); +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormCopyService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormCopyService.cs new file mode 100644 index 00000000..27b9c8fe --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormCopyService.cs @@ -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; + /// + /// + /// + /// + public CodeFormCopyService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); + } + + /// + /// 列表 + /// + /// + /// + public DataResult> GetListByPage(PageRequest request) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + //序列化查询条件 + var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); + var data = tenantDb.Queryable() + .LeftJoin((a, b) => a.PermissionId == b.Id) + .Where(whereList) + .Select().ToQueryPage(request.PageCondition); + return data; + } + + /// + /// 编辑 + /// + /// + /// + public DataResult EditFormCopy(CodeFormCopyReq req) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + if (req.Id == 0) + { + if (tenantDb.Queryable() + .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(); + + var entity = tenantDb.Insertable(data).ExecuteReturnEntity(); + + return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess); + } + else + { + var info = tenantDb.Queryable().Where(x => x.Id == req.Id).First(); + + info = req.Adapt(info); + + tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand(); + return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); + } + } + + /// + /// 详情 + /// + /// + /// + public DataResult GetFormCopyInfo(string id) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + var data = tenantDb.Queryable() + .LeftJoin((a, b) => a.PermissionId == b.Id) + .Where(x => x.Id == long.Parse(id)) + .Select() + .First(); + return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess); + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/FormSetService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormSetService.cs similarity index 73% rename from ds-wms-service/DS.WMS.Core/Code/Method/FormSetService.cs rename to ds-wms-service/DS.WMS.Core/Code/Method/CodeFormSetService.cs index ef6feef6..b61826ef 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Method/FormSetService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormSetService.cs @@ -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; /// /// /// /// - public FormSetService(IServiceProvider serviceProvider) + public CodeFormSetService(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; db = _serviceProvider.GetRequiredService(); user = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); } /// @@ -37,9 +39,10 @@ public class FormSetService : IFormSetService /// public DataResult> GetListByPage(PageRequest request) { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); //序列化查询条件 var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); - var data = db.Queryable() + var data = tenantDb.Queryable() .LeftJoin((a, b) => a.PermissionId == b.Id) .Where(whereList) .Select().ToQueryPage(request.PageCondition); @@ -53,9 +56,10 @@ public class FormSetService : IFormSetService /// public DataResult EditFormSet(CodeFormSetReq req) { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); if (req.Id == 0) { - if (db.Queryable() + if (tenantDb.Queryable() .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(); - var entity = db.Insertable(data).ExecuteReturnEntity(); + var entity = tenantDb.Insertable(data).ExecuteReturnEntity(); return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess); } else { - var info = db.Queryable().Where(x => x.Id == req.Id).First(); + var info = tenantDb.Queryable().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 /// public DataResult GetFormSetInfo(string id) { - var data = db.Queryable() + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + var data = tenantDb.Queryable() .LeftJoin((a, b) => a.PermissionId == b.Id) .Where(x => x.Id == long.Parse(id)) .Select() diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/FormCopyController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/FormCopyController.cs new file mode 100644 index 00000000..ede996bc --- /dev/null +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/FormCopyController.cs @@ -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; + +/// +/// 表单字段复制设置 模块 +/// +public class FormCopyController : ApiController +{ + private readonly IFormCopyService _invokeService; + + /// + /// 构造函数 + /// + /// + public FormCopyController(IFormCopyService invokeService) + { + _invokeService = invokeService; + } + + /// + /// 列表 + /// + /// + /// + [HttpPost] + [Route("GetFormCopyList")] + public DataResult> GetFormCopyList([FromBody] PageRequest request) + { + var res = _invokeService.GetListByPage(request); + return res; + } + + /// + /// 编辑 + /// + /// + /// + [HttpPost] + [Route("EditFormCopy")] + public DataResult EditFormCopy([FromBody] CodeFormCopyReq req) + { + var res = _invokeService.EditFormCopy(req); + return res; + } + + /// + /// 详情 + /// + /// 权限Id + /// + [HttpGet] + [Route("GetFormCopyInfo")] + public DataResult GetFormCopyInfo([FromQuery] string permissionId) + { + var res = _invokeService.GetFormCopyInfo(permissionId); + return res; + } +} \ No newline at end of file