diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index 6daa0a53..ea720416 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -264,5 +264,9 @@ public static class MultiLanguageConst public const string CodeStlModeImportNoData = "Code_StlMode_Import_No_Data"; [Description("存在已导入的结算方式")] public const string CodeStlModeImportAlready = "Code_StlMode_Import_Already"; + + + [Description("表单设置已存在")] + public const string FormSetExist = "Form_Set_Exist"; #endregion } \ No newline at end of file diff --git a/ds-wms-service/DS.Module.Core/Data/BaseOrgModel.cs b/ds-wms-service/DS.Module.Core/Data/BaseOrgModel.cs new file mode 100644 index 00000000..ca0d5b59 --- /dev/null +++ b/ds-wms-service/DS.Module.Core/Data/BaseOrgModel.cs @@ -0,0 +1,22 @@ +using System.ComponentModel; + +namespace DS.Module.Core.Data; + +/// +/// 机构实体基类 +/// +public abstract class BaseOrgModel : BaseModel, IOrgId +{ + /// + /// 主键ID + /// + [Description("主键ID")] + [SqlSugar.SugarColumn(IsPrimaryKey = true, Length = 100, ColumnDescription = "主键ID")] + public TKey Id { get; set; } + + /// + /// 机构Id + /// + [SqlSugar.SugarColumn(ColumnDescription = "机构Id", IsOnlyIgnoreUpdate = true)] + public long OrgId { get; set; } = 0; +} \ 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 new file mode 100644 index 00000000..8521ba08 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormSetReq.cs @@ -0,0 +1,57 @@ +using DS.Module.Core; +using FluentValidation; + +namespace DS.WMS.Core.Code.Dtos; + +/// +/// 租户表单设置请求实体 +/// +public class CodeFormSetReq +{ + /// + /// 主键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 FormSetReqValidator : AbstractValidator +{ + /// + /// 构造函数 + /// + public FormSetReqValidator() + { + 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/CodeFormSetRes.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormSetRes.cs new file mode 100644 index 00000000..df4361b8 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeFormSetRes.cs @@ -0,0 +1,42 @@ +using DS.Module.Core; + +namespace DS.WMS.Core.Code.Dtos; + +/// +/// 租户表单设置返回实体 +/// +public class CodeFormSetRes +{ + + /// + /// 主键Id + /// + public long Id { get; set; } + /// + /// 权限Id + /// + public long? PermissionId { get; set; } + + /// + /// 字段设置 + /// + public string Content { get; set; } + + /// + /// 状态 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/Entity/CodeFormSet.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeFormSet.cs new file mode 100644 index 00000000..ff7d9c1f --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeFormSet.cs @@ -0,0 +1,34 @@ +using DS.Module.Core; +using DS.Module.Core.Data; +using SqlSugar; + +namespace DS.WMS.Core.Code.Entity; + +/// +/// 租户表单设置 +/// +[SqlSugar.SugarTable("op_code_form_set")] +public class CodeFormSet : BaseOrgModel +{ + /// + /// 权限Id + /// + public long? PermissionId { get; set; } + + /// + /// 表单设置 + /// + [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/System/Interface/IFormSetService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/IFormSetService.cs similarity index 64% rename from ds-wms-service/DS.WMS.Core/System/Interface/IFormSetService.cs rename to ds-wms-service/DS.WMS.Core/Code/Interface/IFormSetService.cs index f6e935d6..e703ff75 100644 --- a/ds-wms-service/DS.WMS.Core/System/Interface/IFormSetService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/IFormSetService.cs @@ -1,8 +1,8 @@ using DS.Module.Core; +using DS.WMS.Core.Code.Dtos; using DS.WMS.Core.System.Dtos; -using DS.WMS.Core.System.Entity; -namespace DS.WMS.Core.System.Interface; +namespace DS.WMS.Core.Code.Interface; public interface IFormSetService { @@ -11,7 +11,7 @@ public interface IFormSetService /// /// /// - DataResult> GetListByPage(PageRequest request); + DataResult> GetListByPage(PageRequest request); /// @@ -19,12 +19,12 @@ public interface IFormSetService /// /// /// - DataResult EditFormSet(FormSetReq model); + DataResult EditFormSet(CodeFormSetReq model); /// /// 获取详情 /// /// /// - DataResult GetFormSetInfo(string id); + DataResult GetFormSetInfo(string id); } \ 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/FormSetService.cs new file mode 100644 index 00000000..ef6feef6 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Method/FormSetService.cs @@ -0,0 +1,95 @@ +using DS.Module.Core; +using DS.Module.Core.Extensions; +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 FormSetService : IFormSetService +{ + private readonly IServiceProvider _serviceProvider; + private readonly ISqlSugarClient db; + private readonly IUser user; + + /// + /// + /// + /// + public FormSetService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + } + + /// + /// 列表 + /// + /// + /// + public DataResult> GetListByPage(PageRequest request) + { + //序列化查询条件 + var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); + var data = db.Queryable() + .LeftJoin((a, b) => a.PermissionId == b.Id) + .Where(whereList) + .Select().ToQueryPage(request.PageCondition); + return data; + } + + /// + /// 编辑 + /// + /// + /// + public DataResult EditFormSet(CodeFormSetReq req) + { + if (req.Id == 0) + { + if (db.Queryable() + .Where(x => x.OrgId == long.Parse(user.OrgId) && x.PermissionId == req.PermissionId).Any()) + { + return DataResult.Failed("表单设置已存在!", MultiLanguageConst.FormSetExist); + } + + var data = req.Adapt(); + + var entity = db.Insertable(data).ExecuteReturnEntity(); + + return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess); + } + else + { + var info = db.Queryable().Where(x => x.Id == req.Id).First(); + + info = req.Adapt(info); + + db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand(); + return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); + } + } + + /// + /// 详情 + /// + /// + /// + public DataResult GetFormSetInfo(string id) + { + var data = db.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/Flow/Entity/FlowInstance.cs b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowInstance.cs index e5a6f944..6f8cef94 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowInstance.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowInstance.cs @@ -1,6 +1,7 @@ using System.ComponentModel; using DS.Module.Core; using DS.Module.Core.Data; +using SqlSugar; namespace DS.WMS.Core.Flow.Entity; /// @@ -72,5 +73,6 @@ public class FlowInstance: BaseTenantModel /// /// 流程内容 /// + [SugarColumn(ColumnDescription = "流程内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)] public string Content { get; set; } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplate.cs b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplate.cs index a70b6925..2697f830 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplate.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplate.cs @@ -31,6 +31,7 @@ public class FlowTemplate : BaseModel /// /// 流程内容 /// + [SugarColumn(ColumnDescription = "内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)] public string Content { get; set; } /// diff --git a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplateTenant.cs b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplateTenant.cs index 0fe95168..ce227e22 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplateTenant.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplateTenant.cs @@ -30,6 +30,7 @@ public class FlowTemplateTenant : BaseTenantModel /// /// 流程内容 /// + [SugarColumn(ColumnDescription = "内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)] public string Content { get; set; } /// diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleReq.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleReq.cs index 0309a92c..0c083dbb 100644 --- a/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleReq.cs +++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleReq.cs @@ -9,9 +9,9 @@ namespace DS.WMS.Core.System.Dtos; public class DataRuleReq { /// - /// 主键Id - /// - public long Id { get; set; } + /// 主键Id + /// + public long Id { get; set; } /// /// 资源标识(权限ID) /// diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/FormSetReq.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/FormSetReq.cs deleted file mode 100644 index c0c6b7b1..00000000 --- a/ds-wms-service/DS.WMS.Core/System/Dtos/FormSetReq.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace DS.WMS.Core.System.Dtos; - -/// -/// 租户表单设置请求实体 -/// -public class FormSetReq -{ - /// - /// 权限Id - /// - public long? PermissionId { get; set; } - - /// - /// 字段设置 - /// - public string Content { get; set; } -} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/FormSetRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/FormSetRes.cs deleted file mode 100644 index d7dc0210..00000000 --- a/ds-wms-service/DS.WMS.Core/System/Dtos/FormSetRes.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace DS.WMS.Core.System.Dtos; - -/// -/// 租户表单设置返回实体 -/// -public class FormSetRes -{ - /// - /// 权限Id - /// - public long? PermissionId { get; set; } - - /// - /// 字段设置 - /// - public string Content { get; set; } -} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Entity/SysDataRule.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysDataRule.cs index fad187bb..d68da37c 100644 --- a/ds-wms-service/DS.WMS.Core/System/Entity/SysDataRule.cs +++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysDataRule.cs @@ -1,5 +1,6 @@ using DS.Module.Core; using DS.Module.Core.Data; +using SqlSugar; namespace DS.WMS.Core.System.Entity; @@ -27,6 +28,7 @@ public class SysDataRule : BaseTenantModel /// /// 权限规则 /// + [SugarColumn(ColumnDescription = "权限规则", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)] public string DataRules { get; set; } /// diff --git a/ds-wms-service/DS.WMS.Core/System/Entity/SysFieldSet.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysFieldSet.cs index 8dec6030..17c5da58 100644 --- a/ds-wms-service/DS.WMS.Core/System/Entity/SysFieldSet.cs +++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysFieldSet.cs @@ -27,5 +27,6 @@ public class SysFieldSet /// /// 字段设置 /// + [SugarColumn(ColumnDescription = "字段设置", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)] public string Content { get; set; } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Entity/SysFormSet.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysFormSet.cs deleted file mode 100644 index c8b78302..00000000 --- a/ds-wms-service/DS.WMS.Core/System/Entity/SysFormSet.cs +++ /dev/null @@ -1,31 +0,0 @@ -using SqlSugar; - -namespace DS.WMS.Core.System.Entity; - -/// -/// 租户表单设置 -/// -[SqlSugar.SugarTable("sys_tenant_form_set")] -public class SysFormSet -{ - /// - /// ID - /// - [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] - public int Id { get; set; } - - /// - /// 租户id - /// - public long? TenantId { get; set; } - - /// - /// 权限Id - /// - public long? PermissionId { get; set; } - - /// - /// 表单设置 - /// - public string Content { get; set; } -} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Entity/SysNotice.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysNotice.cs index 97b6fc92..f363c257 100644 --- a/ds-wms-service/DS.WMS.Core/System/Entity/SysNotice.cs +++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysNotice.cs @@ -1,4 +1,5 @@ using DS.Module.Core.Data; +using SqlSugar; namespace DS.WMS.Core.System.Entity; @@ -31,6 +32,7 @@ public class SysNotice : BaseModel /// /// 内容 /// + [SugarColumn(ColumnDescription = "内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)] public string Content { get; set; } /// diff --git a/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs b/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs index bc9122b8..b32b6fc9 100644 --- a/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs +++ b/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs @@ -366,14 +366,14 @@ public class CommonService : ICommonService return DataResult.Failed("密码错误!"); } - // //取第一个机构 - // var orgRelation = db.Queryable() - // .First(x => x.UserId == userInfo.Id); + //取第一个机构 + var orgRelation = db.Queryable() + .First(x => x.UserId == userInfo.Id); var tokenModel = new JwtHelper.JwtTokenModel { Uid = userInfo.Id.ToString(), Name = userInfo.UserName, - // OrgId = orgRelation.OrgId.ToString(), + OrgId = orgRelation.OrgId.ToString(), TenantId = userInfo.TenantId.ToString(), }; var token = JwtHelper.Encrypt(tokenModel, false, false); @@ -399,17 +399,17 @@ public class CommonService : ICommonService { var userId = long.Parse(user.UserId); var tenantId = user.GetTenantId(); - // //取第一个机构 - // var orgRelations = db.Queryable() - // .LeftJoin((a,b)=>a.OrgId==b.Id) - // .Where(a => a.UserId == userId) - // .Select() - // .ToList(); + //取第一个机构 + var orgRelations = db.Queryable() + .LeftJoin((a,b)=>a.OrgId==b.Id) + .Where(a => a.UserId == userId) + .Select() + .ToList(); var tokenModel = new JwtHelper.JwtTokenModel { Uid = user.UserId, Name = db.Queryable().Filter(null, true).First(x => x.Id == userId).UserName, - // OrgId = user.GetOrgId().ToString(), + OrgId = user.GetOrgId().ToString(), TenantId = tenantId.ToString(), }; var refreshToken = JwtHelper.Encrypt(tokenModel, true, false); @@ -426,7 +426,7 @@ public class CommonService : ICommonService ClientId = a.ClientId, IsLimitClient = a.IsLimitClient, RefreshToken = refreshToken, - // UserOrgs = orgRelations, + UserOrgs = orgRelations, // OrgId = a.OrgId.ToString(), CompanyName = a.CustomerName }) .Mapper(it => diff --git a/ds-wms-service/DS.WMS.Core/System/Method/FormSetService.cs b/ds-wms-service/DS.WMS.Core/System/Method/FormSetService.cs deleted file mode 100644 index 335a03d4..00000000 --- a/ds-wms-service/DS.WMS.Core/System/Method/FormSetService.cs +++ /dev/null @@ -1,88 +0,0 @@ -using DS.Module.Core; -using DS.Module.Core.Extensions; -using DS.Module.UserModule; -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.System.Method; - -public class FormSetService : IFormSetService -{ - private readonly IServiceProvider _serviceProvider; - private readonly ISqlSugarClient db; - private readonly IUser user; - - /// - /// - /// - /// - public FormSetService(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - db = _serviceProvider.GetRequiredService(); - user = _serviceProvider.GetRequiredService(); - } - - /// - /// 列表 - /// - /// - /// - public DataResult> GetListByPage(PageRequest request) - { - //序列化查询条件 - var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); - var data = db.Queryable() - .LeftJoin((a, b) => a.PermissionId == b.Id) - .Where(whereList) - .Select().ToQueryPage(request.PageCondition); - return data; - } - /// - /// 编辑 - /// - /// - /// - public DataResult EditFormSet(FormSetReq req) - { - var info = db.Queryable() - .Where(x => x.TenantId == long.Parse(user.TenantId) && x.PermissionId == req.PermissionId).First(); - - if (info.IsNull()) - { - var entity = new SysFormSet - { - TenantId = long.Parse(user.TenantId), - PermissionId = req.PermissionId, - Content = req.Content - }; - db.Insertable(entity).ExecuteCommand(); - } - else - { - info.Content = req.Content; - db.Updateable(info).ExecuteCommand(); - } - - return DataResult.Successed("更新成功",MultiLanguageConst.DataUpdateSuccess); - - } - /// - /// 详情 - /// - /// - /// - public DataResult GetFormSetInfo(string permissionId) - { - var data = db.Queryable() - .LeftJoin((a, b) => a.PermissionId == b.Id) - .Where(x => x.TenantId == long.Parse(user.TenantId) && x.PermissionId == long.Parse(permissionId)) - .Select() - .First(); - return DataResult.Success(data,MultiLanguageConst.DataQuerySuccess); - } -} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/FormSetController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/FormSetController.cs index 71db803a..f4d8008f 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/FormSetController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/FormSetController.cs @@ -1,4 +1,6 @@ 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; @@ -28,7 +30,7 @@ public class FormSetController : ApiController /// [HttpPost] [Route("GetFormSetList")] - public DataResult> GetFormSetList([FromBody] PageRequest request) + public DataResult> GetFormSetList([FromBody] PageRequest request) { var res = _invokeService.GetListByPage(request); return res; @@ -41,7 +43,7 @@ public class FormSetController : ApiController /// [HttpPost] [Route("EditFormSet")] - public DataResult EditFormSet([FromBody] FormSetReq req) + public DataResult EditFormSet([FromBody] CodeFormSetReq req) { var res = _invokeService.EditFormSet(req); return res; @@ -54,7 +56,7 @@ public class FormSetController : ApiController /// [HttpGet] [Route("GetFormSetInfo")] - public DataResult GetFormSetInfo([FromQuery] string permissionId) + public DataResult GetFormSetInfo([FromQuery] string permissionId) { var res = _invokeService.GetFormSetInfo(permissionId); return res;