diff --git a/ds-wms-admin-web/.env.development b/ds-wms-admin-web/.env.development
index 05d8f173..adbe8f71 100644
--- a/ds-wms-admin-web/.env.development
+++ b/ds-wms-admin-web/.env.development
@@ -13,7 +13,7 @@ VITE_PROXY=[["/api","http://60.209.125.238:3008"],["/stage-api","https://www.666
VITE_DROP_CONSOLE = true
# 后台接口父地址(必填)
-VITE_GLOB_API_URL=http://localhost:3008
+#VITE_GLOB_API_URL=http://localhost:3008
# VITE_GLOB_API_URL="/api" # 开发 测试环境
# File upload address, optional
diff --git a/ds-wms-service/DS.Module.Core/Constants/DataRuleConst.cs b/ds-wms-service/DS.Module.Core/Constants/DataRuleConst.cs
new file mode 100644
index 00000000..c061b18e
--- /dev/null
+++ b/ds-wms-service/DS.Module.Core/Constants/DataRuleConst.cs
@@ -0,0 +1,22 @@
+using System.ComponentModel;
+
+namespace DS.Module.Core;
+
+///
+/// 数据权限常量
+///
+public static class DataRuleConst
+{
+ ///
+ /// 数据权限配置中,当前登录用户的key
+ ///
+ public const string LoginUser = "{loginUser}";
+ ///
+ /// 数据权限配置中,当前登录角色的key
+ ///
+ public const string LoginRole = "{loginRole}";
+ ///
+ /// 数据权限配置中,当前登录机构的key
+ ///
+ public const string LoginOrg = "{loginOrg}";
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
index 79b9326a..8b240937 100644
--- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
+++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
@@ -23,6 +23,14 @@ public static class MultiLanguageConst
///
[Description("更新成功")]
public const string DataUpdateSuccess = "Data_Update_Success";
+
+ ///
+ /// 删除成功
+ ///
+ [Description("删除成功")]
+ public const string DataDelSuccess = "Data_Del_Success";
+
+
///
/// 更新失败
///
@@ -44,12 +52,16 @@ public static class MultiLanguageConst
[Description("用户授权数量限制")]
public const string UserAuthNumLimit = "User_AuthNum_Limit";
+ [Description("{0}模块数量超出授权数量{1}")]
+ public const string PerAuthNumLimit = "Permission_AuthNum_Limit";
+
[Description("用户唯一编码已存在")]
public const string UserCodeExist = "UserCode_Exist";
[Description("角色唯一编码已存在")]
public const string RoleCodeExist = "RoleCode_Exist";
#endregion
-
+ [Description("字典类型唯一编码已存在")]
+ public const string DictCodeExist = "DictCode_Exist";
[Description("机构名称已存在")]
public const string OrgNameExist = "OrgName_Exist";
///
@@ -58,6 +70,9 @@ public static class MultiLanguageConst
[Description("权限模块不存在")]
public const string PermissionNotExist = "Permission_NotExist";
+ [Description("数据权限已存在")]
+ public const string DataRuleExist = "Data_Rule_Exist";
+
///
/// 非法请求
///
@@ -65,7 +80,11 @@ public static class MultiLanguageConst
public const string IllegalRequest = "Illegal_Request";
#region 工作流相关
-
+
+ [Description("工作流实例存在引用的流程模板不能删除")]
+ public const string FlowTemplateDelExistImport = "FlowTemplate_Del_Exist_Import";
+ [Description("引入的流程模板不存在")]
+ public const string FlowTemplateImportNotExist = "FlowTemplate_Import_NotExist";
///
/// 只能修改【草稿】和【驳回】状态的流程
///
@@ -74,7 +93,7 @@ public static class MultiLanguageConst
///
/// 该流程模板已不存在,请重新设计流程
///
- [Description("该流程模板已不存在,请重新设计流程")]
+ [Description("该流程模板不存在")]
public const string FlowTemplateNotExist = "FlowTemplate_NotExist";
///
diff --git a/ds-wms-service/DS.Module.Core/Data/DataGroupConditions.cs b/ds-wms-service/DS.Module.Core/Data/DataGroupConditions.cs
new file mode 100644
index 00000000..6ef6c02c
--- /dev/null
+++ b/ds-wms-service/DS.Module.Core/Data/DataGroupConditions.cs
@@ -0,0 +1,43 @@
+namespace DS.Module.Core.Data;
+
+///
+/// 数据条件组
+///
+public class DataGroupConditions
+{
+ ///
+ /// 逻辑操作符
+ ///
+ public string LogicalOperator { get; set; }
+
+ ///
+ /// 条件组
+ ///
+ public List Conditions { get; set; }
+
+ ///
+ /// 分组
+ ///
+ public List Groups { get; set; }
+}
+///
+/// 条件
+///
+public class DataConditions
+{
+ ///
+ /// 字段
+ ///
+ public string Field { get; set; }
+
+ ///
+ /// 操作符
+ ///
+ public string Operator { get; set; }
+
+ ///
+ /// 值
+ ///
+ public string Value { get; set; }
+
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.Module.Core/Data/IdModel.cs b/ds-wms-service/DS.Module.Core/Data/IdModel.cs
new file mode 100644
index 00000000..f0af4a24
--- /dev/null
+++ b/ds-wms-service/DS.Module.Core/Data/IdModel.cs
@@ -0,0 +1,12 @@
+namespace DS.Module.Core.Data;
+
+///
+/// id实体
+///
+public class IdModel
+{
+ ///
+ /// 主键id
+ ///
+ public string Id { get; set; }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.Module.Core/Extensions/QueryableExtensions.cs b/ds-wms-service/DS.Module.Core/Extensions/QueryableExtensions.cs
index 64fa30ee..4052b366 100644
--- a/ds-wms-service/DS.Module.Core/Extensions/QueryableExtensions.cs
+++ b/ds-wms-service/DS.Module.Core/Extensions/QueryableExtensions.cs
@@ -1,5 +1,7 @@
using SqlSugar;
using System.ComponentModel;
+using DS.Module.Core.Data;
+using Newtonsoft.Json;
namespace DS.Module.Core.Extensions;
@@ -35,14 +37,15 @@ public static partial class Extensions
///
///
///
- public static DataResult> ToQueryPage(this ISugarQueryable source, PageCondition page)
+ public static DataResult> ToQueryPage(this ISugarQueryable source,
+ PageCondition page)
{
page.NotNull(nameof(page));
var result = source.WhereAsync(page.PageIndex, page.PageSize, page.SortConditions);
var list = result.data;
var total = result.totalNumber;
- return DataResult>.PageList(total, list,MultiLanguageConst.DataQuerySuccess);
+ return DataResult>.PageList(total, list, MultiLanguageConst.DataQuerySuccess);
}
///
@@ -79,4 +82,191 @@ public static partial class Extensions
? source.ToPageList(pageIndex, pageSize, ref total)
: Enumerable.Empty().ToList(), total);
}
+ ///
+ /// 转换SqlSugar条件查询表达式
+ ///
+ ///
+ ///
+ public static List ConvertSqlSugarExpression(this string ruleStr)
+ {
+ var conditions = JsonConvert.DeserializeObject(ruleStr);
+ var conditionalCollections = new List();
+ if (conditions.LogicalOperator == "and")
+ {
+ var conditionList = new List>();
+ foreach (var item in conditions.Conditions)
+ {
+ conditionList.Add(new KeyValuePair
+ (WhereType.And,
+ new ConditionalModel
+ {
+ FieldName = item.Field, ConditionalType = GetConditionalType(item.Operator),
+ FieldValue = item.Value
+ })
+ );
+ }
+
+ if (conditionList.Count > 0)
+ {
+ conditionalCollections.Add(new ConditionalCollections
+ {
+ ConditionalList = conditionList
+ }
+ )
+ ;
+ }
+
+ var groupList = new List>();
+ foreach (var group in conditions.Groups)
+ {
+ if (group.LogicalOperator == "and")
+ {
+ foreach (var item1 in group.Conditions)
+ {
+ groupList.Add(new KeyValuePair
+ (WhereType.And,
+ new ConditionalModel
+ {
+ FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
+ FieldValue = item1.Value
+ })
+ );
+ }
+ }
+ else
+ {
+ foreach (var item1 in group.Conditions)
+ {
+ groupList.Add(new KeyValuePair
+ (WhereType.Or,
+ new ConditionalModel
+ {
+ FieldName = item1.Field, ConditionalType =GetConditionalType(item1.Operator),
+ FieldValue = item1.Value
+ })
+ );
+ }
+ }
+ }
+
+ if (groupList.Count > 0)
+ {
+ conditionalCollections.Add(new ConditionalCollections
+ {
+ ConditionalList = groupList
+ }
+ )
+ ;
+ }
+ }
+ else
+ {
+ var conditionList = new List>();
+ foreach (var item in conditions.Conditions)
+ {
+ conditionList.Add(new KeyValuePair
+ (WhereType.Or,
+ new ConditionalModel
+ {
+ FieldName = item.Field, ConditionalType = GetConditionalType(item.Operator),
+ FieldValue = item.Value
+ })
+ );
+ }
+
+ if (conditionList.Count > 0)
+ {
+ conditionalCollections.Add(new ConditionalCollections
+ {
+ ConditionalList = conditionList
+ }
+ )
+ ;
+ }
+
+ var groupList = new List>();
+ foreach (var group in conditions.Groups)
+ {
+ if (group.LogicalOperator == "and")
+ {
+ foreach (var item1 in group.Conditions)
+ {
+ groupList.Add(new KeyValuePair
+ (WhereType.And,
+ new ConditionalModel
+ {
+ FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
+ FieldValue = item1.Value
+ })
+ );
+ }
+ }
+ else
+ {
+ foreach (var item1 in group.Conditions)
+ {
+ groupList.Add(new KeyValuePair
+ (WhereType.Or,
+ new ConditionalModel
+ {
+ FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
+ FieldValue = item1.Value
+ })
+ );
+ }
+ }
+ }
+
+ if (groupList.Count > 0)
+ {
+ conditionalCollections.Add(new ConditionalCollections
+ {
+ ConditionalList = groupList
+ }
+ )
+ ;
+ }
+ }
+
+ return conditionalCollections;
+ }
+
+ ///
+ /// 转换SqlSugar 条件操作符
+ ///
+ ///
+ ///
+ private static ConditionalType GetConditionalType(string conditionalType)
+ {
+ switch (conditionalType)
+ {
+ //等于
+ case "equal":
+ return ConditionalType.Equal;
+ //不等于
+ case "not_equal":
+ return ConditionalType.NoEqual;
+ //大于
+ case "GreaterThan":
+ return ConditionalType.GreaterThan;
+ //大于等于
+ case "GreaterThanOrEqual":
+ return ConditionalType.GreaterThanOrEqual;
+ //小于
+ case "LessThan":
+ return ConditionalType.LessThan;
+ //小于等于
+ case "LessThanOrEqual":
+ return ConditionalType.GreaterThanOrEqual;
+ //包含
+ case "contains":
+ return ConditionalType.In;
+ //不包含
+ case "not_contain":
+ return ConditionalType.NotIn;
+ //默认
+ default:
+ return ConditionalType.Equal;
+ }
+ }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs b/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs
index 732780a4..179aac6d 100644
--- a/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs
@@ -13,6 +13,7 @@ public class SaasDbService : ISaasDbService
private readonly IServiceProvider _serviceProvider;
private readonly SqlSugarScope db;
private readonly IUser user;
+ private readonly ISaasDbService saasService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
///
diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs
index 5960a216..ee5156b4 100644
--- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs
@@ -27,9 +27,11 @@ namespace DS.Module.SqlSugar
entityInfo.SetValue(GuidHelper.GetSnowflakeId());
}
- if (entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
+ if (entityInfo.EntityColumnInfo.IsPrimarykey && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
{
- entityInfo.SetValue(SnowFlakeSingle.Instance.NextId());
+ var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue);
+ if (id == null || (long)id == 0)
+ entityInfo.SetValue(SnowFlakeSingle.Instance.NextId());
}
}
diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/DictController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/DictController.cs
new file mode 100644
index 00000000..e201bb92
--- /dev/null
+++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/DictController.cs
@@ -0,0 +1,101 @@
+using DS.Module.Core;
+using DS.WMS.Core.System.Dtos;
+using DS.WMS.Core.System.Entity;
+using DS.WMS.Core.System.Interface;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace DS.WMS.AdminApi.Controllers;
+///
+/// 字典模块
+///
+public class DictController : ApiController
+{
+ private readonly ISysDictTypeService _invokeService;
+ private readonly ISysDictDataService _dictDataService;
+ ///
+ /// 构造函数
+ ///
+ ///
+ public DictController(ISysDictTypeService invokeService,ISysDictDataService dictDataService)
+ {
+ _invokeService = invokeService;
+ _dictDataService = dictDataService;
+ }
+
+ ///
+ /// 字典类型列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("GetSysDictTypeList")]
+ public DataResult> GetSysDictTypeList([FromBody] PageRequest request)
+ {
+ var res = _invokeService.GetListByPage(request);
+ return res;
+ }
+
+ ///
+ /// 编辑字典类型
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("EditDictType")]
+ public DataResult EditDictType([FromBody] DictTypeReq model)
+ {
+ var res = _invokeService.EditDictType(model);
+ return res;
+ }
+
+ ///
+ /// 字典明细列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("GetSysDictDataList")]
+ public DataResult> GetSysDictDataList([FromBody] PageRequest request)
+ {
+ var res = _dictDataService.GetListByPage(request);
+ return res;
+ }
+
+ ///
+ /// 编辑字典明细
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("EditDictData")]
+ public DataResult EditDictData([FromBody] DictDataReq model)
+ {
+ var res = _dictDataService.EditDictData(model);
+ return res;
+ }
+ ///
+ /// 字典类型详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("GetDictTypeInfo")]
+ public DataResult GetDictTypeInfo([FromQuery] string id)
+ {
+ var res = _invokeService.GetDictTypeInfo(id);
+ return res;
+ }
+ ///
+ /// 字典明细详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("GetDictDataInfo")]
+ public DataResult GetDictDataInfo([FromQuery] string id)
+ {
+ var res = _dictDataService.GetDictDataInfo(id);
+ return res;
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantController.cs
index 7233a75d..f657673d 100644
--- a/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantController.cs
+++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantController.cs
@@ -3,6 +3,7 @@ using DS.Module.Core.Data;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
namespace DS.WMS.AdminApi.Controllers;
@@ -83,4 +84,28 @@ public class TenantController : ApiController
{
return _invokeService.UpdateTenantPermission(req);
}
+
+ ///
+ /// 获取租户表差异
+ ///
+ /// 租户Id
+ ///
+ [HttpGet]
+ [Route("GetSaasTableDifference")]
+ public DataResult GetSaasTableDifference([FromQuery] string id)
+ {
+ var res = _invokeService.GetSaasTableDifference(id);
+ return res;
+ }
+ ///
+ /// 更新租户表差异
+ ///
+ /// 主键id
+ ///
+ [HttpPost]
+ [Route("UpdateSaasTableInfo")]
+ public DataResult UpdateSaasTableInfo([FromBody] IdModel req)
+ {
+ return _invokeService.UpdateSaasTableInfo(req);
+ }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt
index 44939cc7..e23830fd 100644
--- a/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt
+++ b/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt
@@ -404,3 +404,31 @@
2024-02-19 14:33:49.2154 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-02-19 14:33:49.2301 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-19 14:33:49.2610 Info Configuration initialized.
+2024-02-20 09:36:39.3273 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-20 09:36:39.4228 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-20 09:36:39.4960 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-20 09:36:39.5664 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-02-20 09:36:39.6753 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
+2024-02-20 09:36:39.7236 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-20 09:36:39.8320 Info Configuration initialized.
+2024-02-20 15:44:41.9090 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-20 15:44:42.1108 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-20 15:44:42.2070 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-20 15:44:42.4571 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-02-20 15:44:42.6293 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
+2024-02-20 15:44:42.6549 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-20 15:44:42.7207 Info Configuration initialized.
+2024-02-22 17:59:02.7290 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-22 17:59:02.7572 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-22 17:59:02.7819 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-22 17:59:02.8134 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-02-22 17:59:02.8482 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
+2024-02-22 17:59:02.8692 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-22 17:59:02.9376 Info Configuration initialized.
+2024-02-23 08:53:34.7978 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-23 08:53:34.8813 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-23 08:53:34.9347 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-23 08:53:35.0052 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-02-23 08:53:35.0867 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
+2024-02-23 08:53:35.1429 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-23 08:53:35.2826 Info Configuration initialized.
diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeGoods.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeGoods.cs
new file mode 100644
index 00000000..34832be7
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeGoods.cs
@@ -0,0 +1,103 @@
+using DS.Module.Core;
+using DS.Module.Core.Data;
+using SqlSugar;
+
+namespace DS.WMS.Core.Code.Entity;
+///
+/// 商品信息表
+///
+[SqlSugar.SugarTable("op_code_goods","商品信息表")]
+public class CodeGoods: BaseModel
+{
+ ///
+ /// 商品编码
+ ///
+ [SugarColumn(ColumnDescription = "商品编码", Length = 30)]
+ public string GoodsCode { get; set; }
+
+ ///
+ /// 商品名称
+ ///
+ [SugarColumn(ColumnDescription = "商品名称", Length = 50)]
+ public string GoodName { get; set; }
+
+ ///
+ /// 物料号
+ ///
+ [SugarColumn(ColumnDescription = "物料号", Length = 50)]
+ public string GoodNo { get; set; }
+
+ ///
+ /// 英文名称
+ ///
+ [SugarColumn(ColumnDescription = "英文名称", Length = 10)]
+ public string EnName { get; set; }
+ ///
+ /// 商品描述
+ ///
+ [SugarColumn(ColumnDescription = "商品描述", Length = 200)]
+ public string Description { get; set; }
+
+ ///
+ /// 入库应收
+ ///
+ [SugarColumn(ColumnDescription = "入库应收", Length = 18,DecimalDigits = 2,DefaultValue ="0")]
+ public decimal ARRate { get; set; }
+
+ ///
+ /// 入库应付
+ ///
+ [SugarColumn(ColumnDescription = "入库应收", Length = 18,DecimalDigits = 2,DefaultValue ="0")]
+ public decimal APRate { get; set; }
+ ///
+ /// 出库应收
+ ///
+ [SugarColumn(ColumnDescription = "出库应收", Length = 18,DecimalDigits = 2,DefaultValue ="0")]
+ public decimal AROutRate { get; set; }
+
+ ///
+ /// 出库应付
+ ///
+ [SugarColumn(ColumnDescription = "出库应收", Length = 18,DecimalDigits = 2,DefaultValue ="0")]
+ public decimal APOutRate { get; set; }
+
+ ///
+ /// 商品类型
+ ///
+ [SugarColumn(ColumnDescription = "商品类型", IsNullable = true)]
+ public long GoodsTypeId { get; set; }
+ ///
+ /// 计费大类
+ ///
+ [SugarColumn(ColumnDescription = "计费大类", IsNullable = true)]
+ public long GoodsFeeTypeId { get; set; }
+
+ ///
+ /// 海关代码
+ ///
+ [SugarColumn(ColumnDescription = "海关代码", Length = 50)]
+ public string HSCode { get; set; }
+
+ ///
+ /// 申报计量单位
+ ///
+ [SugarColumn(ColumnDescription = "物料号", Length = 50)]
+ public string RuleUnit { get; set; }
+
+ ///
+ /// 法定第一计量单位
+ ///
+ [SugarColumn(ColumnDescription = "法定第一计量单位", Length = 50)]
+ public string RuleUnit1 { get; set; }
+
+ ///
+ /// 法定第二计量单位
+ ///
+ [SugarColumn(ColumnDescription = "法定第二计量单位", Length = 50)]
+ public string RuleUnit2 { get; set; }
+ ///
+ /// 状态 0启用 1禁用
+ ///
+ [SugarColumn(ColumnDescription = "状态",DefaultValue = "0")]
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeGoodsType.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeGoodsType.cs
new file mode 100644
index 00000000..ddd4a566
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeGoodsType.cs
@@ -0,0 +1,39 @@
+using DS.Module.Core;
+using DS.Module.Core.Data;
+using SqlSugar;
+
+namespace DS.WMS.Core.Code.Entity;
+///
+/// 商品类型表
+///
+[SqlSugar.SugarTable("op_code_goods_type","商品类型表")]
+public class CodeGoodsType: BaseModel
+{
+ ///
+ /// 类型代码
+ ///
+ [SugarColumn(ColumnDescription = "类型代码", Length = 20)]
+ public string GoodsTypeCode { get; set; }
+
+ ///
+ /// 货物类型
+ ///
+ [SugarColumn(ColumnDescription = "货物类型", Length = 50)]
+ public string GoodsTypeName { get; set; }
+
+ ///
+ /// 英文名称
+ ///
+ [SugarColumn(ColumnDescription = "英文名称", Length = 10)]
+ public string EnName { get; set; }
+ ///
+ /// 描述
+ ///
+ [SugarColumn(ColumnDescription = "描述", Length = 200)]
+ public string Description { get; set; }
+ ///
+ /// 状态 0启用 1禁用
+ ///
+ [SugarColumn(ColumnDescription = "状态",DefaultValue = "0")]
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj
index ea7b5066..86f45634 100644
--- a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj
+++ b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj
@@ -20,6 +20,10 @@
+
+
+
+
diff --git a/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowTemplateReq.cs b/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowTemplateReq.cs
index 6fa58162..a3c159de 100644
--- a/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowTemplateReq.cs
+++ b/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowTemplateReq.cs
@@ -37,7 +37,10 @@ public class FlowTemplateReq
/// 排序
///
public int? OrderNo { get; set; } = 100;
-
+ ///
+ /// 状态 0 启用 1 禁用
+ ///
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
///
/// 备注
///
diff --git a/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowTemplateRes.cs b/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowTemplateRes.cs
index cf450189..fd5303d4 100644
--- a/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowTemplateRes.cs
+++ b/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowTemplateRes.cs
@@ -11,22 +11,24 @@ public class FlowTemplateRes
/// 主键Id
///
public long Id { get; set; }
+
///
/// 模板名称
///
public string Name { get; set; }
-
+
///
/// 模块Id
///
public long PermissionId { get; set; }
-
-
+
+
///
/// 模块名称
///
public string PermissionName { get; set; }
+
///
///中文视图名;设计打印方案时,提供中文快捷按钮的视图来源
///
@@ -41,13 +43,17 @@ public class FlowTemplateRes
/// 排序
///
public int? OrderNo { get; set; } = 100;
-
+
///
/// 状态
///
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
-
-
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime CreateTime { get; set; }
+
///
/// 备注
///
diff --git a/ds-wms-service/DS.WMS.Core/Flow/Interface/IClientFlowTemplateService.cs b/ds-wms-service/DS.WMS.Core/Flow/Interface/IClientFlowTemplateService.cs
index 0dfe0fa4..2191626d 100644
--- a/ds-wms-service/DS.WMS.Core/Flow/Interface/IClientFlowTemplateService.cs
+++ b/ds-wms-service/DS.WMS.Core/Flow/Interface/IClientFlowTemplateService.cs
@@ -34,6 +34,13 @@ public interface IClientFlowTemplateService
///
DataResult ImportFlowTemplate(string id);
+ ///
+ /// 删除模板
+ ///
+ ///
+ ///
+ DataResult DelFlowTemplate(string id);
+
///
/// 获取模板列表
///
diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowTemplateService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowTemplateService.cs
index 05bab47d..6c38d280 100644
--- a/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowTemplateService.cs
+++ b/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowTemplateService.cs
@@ -49,17 +49,7 @@ public class ClientFlowTemplateService : IClientFlowTemplateService
{
if (req.Id == 0)
{
- var isExist = db.Queryable().Where(x => x.Name == req.Name).First();
- if (isExist != null)
- {
- return DataResult.Failed("流程模板名称已存在!");
- }
-
- var data = req.Adapt();
-
- var entity = db.Insertable(data).ExecuteReturnEntity();
-
- return DataResult.Successed("添加成功!", entity.Id);
+ return DataResult.Failed("非法请求!",MultiLanguageConst.IllegalRequest);
}
else
{
@@ -68,7 +58,7 @@ public class ClientFlowTemplateService : IClientFlowTemplateService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
- return DataResult.Successed("更新成功!");
+ return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@@ -78,7 +68,7 @@ public class ClientFlowTemplateService : IClientFlowTemplateService
.Where(a => a.Id == long.Parse(id))
.Select()
.First();
- return DataResult.Success(data);
+ return DataResult.Success(data,MultiLanguageConst.DataQuerySuccess);
}
public DataResult ImportFlowTemplate(string id)
@@ -86,20 +76,38 @@ public class ClientFlowTemplateService : IClientFlowTemplateService
var info = db.Queryable().Where(x => x.Id == long.Parse(id)).First();
if (info == null)
{
- return DataResult.Failed("流程模板不存在!");
+ return DataResult.Failed("流程模板不存在!",MultiLanguageConst.FlowTemplateImportNotExist);
}
var data = info.Adapt();
- db.Insertable(info).ExecuteCommand();
- return DataResult.Successed("引入成功!");
+ data.Id = 0;
+ db.Insertable(data).ExecuteCommand();
+ return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
+ }
+
+ public DataResult DelFlowTemplate(string id)
+ {
+ var info = db.Queryable().Where(x => x.Id == long.Parse(id)).First();
+ if (info == null)
+ {
+ return DataResult.Failed("流程模板不存在!",MultiLanguageConst.FlowTemplateNotExist);
+ }
+
+ if (db.Queryable().Where(x=>x.TemplateId == long.Parse(id)).Any())
+ {
+ return DataResult.Failed("工作流实例存在引用的流程模板不能删除!",MultiLanguageConst.FlowTemplateDelExistImport);
+ }
+
+ db.Deleteable(info).ExecuteCommand();
+ return DataResult.Successed("删除成功!",MultiLanguageConst.DataDelSuccess);
}
public DataResult> GetFlowTemplateList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
- var data = db.Queryable()
- // .LeftJoin((a, b) => a.PermissionId == b.Id)
+ var data = db.Queryable().Where(a=>a.Status == StatusEnum.Enable)
+ .LeftJoin((a, b) => a.PermissionId == b.Id)
.Select()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs
index 587125ac..d4d5d532 100644
--- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs
+++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs
@@ -182,7 +182,7 @@ public class FlowInstanceService : IFlowInstanceService
instance.ActivityType = wfruntime.GetNodeType(startNodeId);
instance.ActivityName = wfruntime.ChildNodes.First(x => x.Id == startNodeId).Name;
instance.MakerList =
- (wfruntime.GetNextNodeType() != 4 ? GetCurrentMakers(wfruntime) : "");
+ (wfruntime.GetNextNodeType() != 4 ? GetCurrentMakers(wfruntime) : "1");
instance.FlowStatus = FlowStatusEnum.Draft.ToEnumInt();
wfruntime.FlowInstanceId = instance.Id;
@@ -243,7 +243,7 @@ public class FlowInstanceService : IFlowInstanceService
instance.ActivityName = wfruntime.NextNode.Name;
instance.PreviousId = wfruntime.CurrentNodeId;
instance.MakerList =
- (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "");
+ (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "1");
instance.FlowStatus = (wfruntime.GetNextNodeType() == 4
? FlowStatusEnum.Approve.ToEnumInt()
: FlowStatusEnum.Running.ToEnumInt());
@@ -318,7 +318,7 @@ public class FlowInstanceService : IFlowInstanceService
? FlowStatusEnum.Approve.ToEnumInt()
: FlowStatusEnum.Running.ToEnumInt());
instance.MakerList =
- (wfruntime.NextNodeType == 4 ? "" : GetNextMakers(wfruntime));
+ (wfruntime.NextNodeType == 4 ? "1" : GetNextMakers(wfruntime));
// AddTransHistory(wfruntime);
}
@@ -343,7 +343,7 @@ public class FlowInstanceService : IFlowInstanceService
instance.ActivityId = wfruntime.NextNodeId;
instance.ActivityType = wfruntime.NextNodeType;
instance.ActivityName = wfruntime.NextNode.Name;
- instance.MakerList = wfruntime.NextNodeType == 4 ? "" : GetNextMakers(wfruntime);
+ instance.MakerList = wfruntime.NextNodeType == 4 ? "1" : GetNextMakers(wfruntime);
instance.FlowStatus = (wfruntime.NextNodeType == 4
? FlowStatusEnum.Approve.ToEnumInt()
: FlowStatusEnum.Running.ToEnumInt());
diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntimeService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntimeService.cs
index 9ba653f8..23e3f96d 100644
--- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntimeService.cs
+++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntimeService.cs
@@ -245,7 +245,7 @@ public class FlowRuntimeService
(WhereType.And,
new ConditionalModel
{
- FieldName = item.Field, ConditionalType = ConditionalType.Equal,
+ FieldName = item.Field, ConditionalType = GetConditionalType(item.Operator),
FieldValue = item.Value
})
);
@@ -272,7 +272,7 @@ public class FlowRuntimeService
(WhereType.And,
new ConditionalModel
{
- FieldName = item1.Field, ConditionalType = ConditionalType.Equal,
+ FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
FieldValue = item1.Value
})
);
@@ -286,7 +286,7 @@ public class FlowRuntimeService
(WhereType.Or,
new ConditionalModel
{
- FieldName = item1.Field, ConditionalType = ConditionalType.Equal,
+ FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
FieldValue = item1.Value
})
);
@@ -313,7 +313,7 @@ public class FlowRuntimeService
(WhereType.Or,
new ConditionalModel
{
- FieldName = item.Field, ConditionalType = ConditionalType.Equal,
+ FieldName = item.Field, ConditionalType = GetConditionalType(item.Operator),
FieldValue = item.Value
})
);
@@ -340,7 +340,7 @@ public class FlowRuntimeService
(WhereType.And,
new ConditionalModel
{
- FieldName = item1.Field, ConditionalType = ConditionalType.Equal,
+ FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
FieldValue = item1.Value
})
);
@@ -354,7 +354,7 @@ public class FlowRuntimeService
(WhereType.Or,
new ConditionalModel
{
- FieldName = item1.Field, ConditionalType = ConditionalType.Equal,
+ FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
FieldValue = item1.Value
})
);
@@ -372,11 +372,7 @@ public class FlowRuntimeService
;
}
}
-
- var entity = EntityUtil.getEntity(ColumnView);
-
- var temp = db.EntityMaintenance.GetEntityInfo(entity);
- // var table = ColumnView
+
var conditionalModels =
db.ConfigQuery.Context.Utilities.JsonToConditionalModels(
JsonConvert.SerializeObject(conditionalCollections));
@@ -505,7 +501,44 @@ public class FlowRuntimeService
return -1;
}
-
+ ///
+ /// 转换SqlSugar 条件操作符
+ ///
+ ///
+ ///
+ private static ConditionalType GetConditionalType(string conditionalType)
+ {
+ switch (conditionalType)
+ {
+ //等于
+ case "equal":
+ return ConditionalType.Equal;
+ //不等于
+ case "not_equal":
+ return ConditionalType.NoEqual;
+ //大于
+ case "GreaterThan":
+ return ConditionalType.GreaterThan;
+ //大于等于
+ case "GreaterThanOrEqual":
+ return ConditionalType.GreaterThanOrEqual;
+ //小于
+ case "LessThan":
+ return ConditionalType.LessThan;
+ //小于等于
+ case "LessThanOrEqual":
+ return ConditionalType.GreaterThanOrEqual;
+ //包含
+ case "contains":
+ return ConditionalType.In;
+ //不包含
+ case "not_contain":
+ return ConditionalType.NotIn;
+ //默认
+ default:
+ return ConditionalType.Equal;
+ }
+ }
///
/// 获取节点类型 0会签开始,1会签结束,2一般节点,3开始节点,4流程运行结束
///
diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/ClientPermissionRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/ClientPermissionRes.cs
new file mode 100644
index 00000000..0bc0d396
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Dtos/ClientPermissionRes.cs
@@ -0,0 +1,22 @@
+namespace DS.WMS.Core.System.Dtos;
+
+///
+/// 客户权限返回
+///
+public class ClientPermissionRes
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+
+ ///
+ /// 权限名称
+ ///
+ public string PermissionName { get; set; }
+
+ ///
+ /// 权限实体
+ ///
+ public string PermissionEntity { get; set; }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleReq.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleReq.cs
new file mode 100644
index 00000000..0309a92c
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleReq.cs
@@ -0,0 +1,66 @@
+using DS.Module.Core;
+using FluentValidation;
+
+namespace DS.WMS.Core.System.Dtos;
+
+///
+/// 数据权限请求实体
+///
+public class DataRuleReq
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+ ///
+ /// 资源标识(权限ID)
+ ///
+ public long PermissionId { get; set; }
+ ///
+ /// 中文视图名
+ ///
+ public string ColumnView { get; set; }
+ ///
+ /// 权限规则
+ ///
+ public string DataRules { get; set; }
+ ///
+ /// 权限实体
+ ///
+ public string PermissionEntity { get; set; }
+ ///
+ /// 数据权限描述
+ ///
+ public string Description { get; set; }
+ ///
+ /// 排序
+ ///
+ public int? OrderNo { get; set; } = 100;
+
+ ///
+ /// 状态 0 启用 1 禁用
+ ///
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+ ///
+ /// 备注
+ ///
+ public string Note { get; set; } = "";
+}
+
+
+///
+/// 验证
+///
+public class DataRuleReqValidator : AbstractValidator
+{
+ ///
+ /// 构造函数
+ ///
+ public DataRuleReqValidator()
+ {
+ this.RuleFor(o => o.PermissionId)
+ .NotEmpty().WithName("权限模块Id");
+ this.RuleFor(o => o.ColumnView)
+ .NotEmpty().WithName("中文视图名");
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleRes.cs
new file mode 100644
index 00000000..ccc8dd1e
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DataRuleRes.cs
@@ -0,0 +1,58 @@
+using DS.Module.Core;
+
+namespace DS.WMS.Core.System.Dtos;
+
+///
+/// 数据权限返回实体
+///
+public class DataRuleRes
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+ ///
+ /// 资源标识(权限ID)
+ ///
+ public long PermissionId { get; set; }
+ ///
+ /// 中文视图名
+ ///
+ public string ColumnView { get; set; }
+ ///
+ /// 权限模块名称
+ ///
+ public string PermissionName { get; set; }
+
+ ///
+ /// 权限实体
+ ///
+ public string PermissionEntity { get; set; }
+ ///
+ /// 权限规则
+ ///
+ public string DataRules { get; set; }
+
+ ///
+ /// 数据权限描述
+ ///
+ public string Description { 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/System/Dtos/DictDataReq.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataReq.cs
new file mode 100644
index 00000000..4caf70a8
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataReq.cs
@@ -0,0 +1,59 @@
+using DS.Module.Core;
+using FluentValidation;
+
+namespace DS.WMS.Core.System.Dtos;
+
+///
+/// 字典值请求实体
+///
+public class DictDataReq
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+ ///
+ /// 字典类型Id
+ ///
+ public long TypeId { get; set; }
+
+ ///
+ /// 字典值编码
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 字典值
+ ///
+ public string Value { get; set; }
+ ///
+ /// 排序
+ ///
+ public int? OrderNo { get; set; } = 100;
+
+ ///
+ /// 状态 0 启用 1 禁用
+ ///
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+ ///
+ /// 备注
+ ///
+ public string Note { get; set; } = "";
+}
+
+///
+/// 验证
+///
+public class DictDataReqValidator : AbstractValidator
+{
+ ///
+ /// 构造函数
+ ///
+ public DictDataReqValidator()
+ {
+ this.RuleFor(o => o.Value)
+ .NotEmpty().WithName("字典值");
+ this.RuleFor(o => o.Code)
+ .NotEmpty().WithName("字典值编码");
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataRes.cs
new file mode 100644
index 00000000..22be3504
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataRes.cs
@@ -0,0 +1,45 @@
+using DS.Module.Core;
+
+namespace DS.WMS.Core.System.Dtos;
+///
+/// 字典值返回
+///
+public class DictDataRes
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+ ///
+ /// 字典类型Id
+ ///
+ public long TypeId { get; set; }
+
+ ///
+ /// 字典值编码
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 字典值
+ ///
+ public string Value { get; set; }
+ ///
+ /// 排序
+ ///
+ public int? OrderNo { get; set; } = 100;
+
+ ///
+ /// 状态 0 启用 1 禁用
+ ///
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+ ///
+ /// 备注
+ ///
+ public string Note { get; set; } = "";
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime CreateTime { get; set; }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/DictTypeReq.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DictTypeReq.cs
new file mode 100644
index 00000000..9ef15470
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DictTypeReq.cs
@@ -0,0 +1,54 @@
+using DS.Module.Core;
+using FluentValidation;
+
+namespace DS.WMS.Core.System.Dtos;
+
+///
+/// 字典类型请求实体
+///
+public class DictTypeReq
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+
+ ///
+ /// 唯一编码
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 字典类型名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 排序
+ ///
+ public int? OrderNo { get; set; } = 100;
+ ///
+ /// 状态 0 启用 1 禁用
+ ///
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+ ///
+ /// 备注
+ ///
+ public string Note { get; set; } = "";
+}
+
+///
+/// 验证
+///
+public class DictTypeReqValidator : AbstractValidator
+{
+ ///
+ /// 构造函数
+ ///
+ public DictTypeReqValidator()
+ {
+ this.RuleFor(o => o.Name)
+ .NotEmpty().WithName("字典类型名称");
+ this.RuleFor(o => o.Code)
+ .NotEmpty().WithName("字典类型唯一编码");
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/DictTypeRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DictTypeRes.cs
new file mode 100644
index 00000000..39f106bb
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DictTypeRes.cs
@@ -0,0 +1,40 @@
+using DS.Module.Core;
+
+namespace DS.WMS.Core.System.Dtos;
+
+///
+/// 字典类型返回
+///
+public class DictTypeRes
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+
+ ///
+ /// 唯一编码
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 字典类型名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 排序
+ ///
+ public int? OrderNo { get; set; } = 100;
+ ///
+ /// 备注
+ ///
+ public string Note { get; set; } = "";
+ ///
+ /// 状态 0 启用 1 禁用
+ ///
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+ ///
+ /// 创建时间
+ ///
+ public DateTime CreateTime { get; set; }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/SysOrgRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/SysOrgRes.cs
index 863fa7eb..da750af7 100644
--- a/ds-wms-service/DS.WMS.Core/System/Dtos/SysOrgRes.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Dtos/SysOrgRes.cs
@@ -20,7 +20,7 @@ public class SysOrgRes
///
public string OrgName { get; set; }
- ///
+ ///
/// Desc:负责人
/// Default:
/// Nullable:True
@@ -36,7 +36,10 @@ public class SysOrgRes
///
public int? OrderNo { get; set; } = 100;
-
+ ///
+ /// 创建时间
+ ///
+ public DateTime CreateTime { get; set; }
///
/// 是否部门标识
///
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 d2899db8..fad187bb 100644
--- a/ds-wms-service/DS.WMS.Core/System/Entity/SysDataRule.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysDataRule.cs
@@ -1,25 +1,29 @@
+using DS.Module.Core;
using DS.Module.Core.Data;
namespace DS.WMS.Core.System.Entity;
-[SqlSugar.SugarTable("sys_datarule")]
-public class SysDataRule : BaseModel
+[SqlSugar.SugarTable("sys_data_rule")]
+public class SysDataRule : BaseTenantModel
{
///
/// 资源标识(权限ID)
///
- public string PermissionId { get; set; }
-
+ public long PermissionId { get; set; }
+
///
- /// 模块名称
+ /// 权限实体
///
- public string PermissionName { get; set; }
-
+ public string PermissionEntity { get; set; }
///
- /// 是否可用
+ /// 状态
///
- public string Enable { get; set; }
-
+ [SqlSugar.SugarColumn(ColumnDescription = "状态")]
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+ ///
+ /// 中文视图名
+ ///
+ public string ColumnView { get; set; }
///
/// 权限规则
///
@@ -33,5 +37,5 @@ public class SysDataRule : BaseModel
///
/// 排序号
///
- public string SortNo { get; set; }
+ public string OrderNo { get; set; }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Entity/SysDictData.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysDictData.cs
new file mode 100644
index 00000000..887341ec
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysDictData.cs
@@ -0,0 +1,41 @@
+using DS.Module.Core;
+using DS.Module.Core.Data;
+
+namespace DS.WMS.Core.System.Entity;
+///
+/// 系统字典值表
+///
+[SqlSugar.SugarTable("sys_dict_data")]
+public class SysDictData : BaseModel
+{
+ ///
+ /// 字典类型Id
+ ///
+ public long TypeId { get; set; }
+ ///
+ /// 字典值
+ ///
+ [SqlSugar.SugarColumn(Length = 100,ColumnDescription="名称")]
+ public string Value { get; set; }
+
+ ///
+ /// 字典值编码
+ ///
+ [SqlSugar.SugarColumn(Length = 50,ColumnDescription="编码")]
+ public string Code { get; set; }
+
+
+ ///
+ /// 排序
+ ///
+ [SqlSugar.SugarColumn(ColumnDescription = "排序")]
+ public int? OrderNo { get; set; } = 100;
+
+
+ ///
+ /// 状态
+ ///
+ [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/Entity/SysDictType.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysDictType.cs
new file mode 100644
index 00000000..ce983000
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysDictType.cs
@@ -0,0 +1,38 @@
+using DS.Module.Core;
+using DS.Module.Core.Data;
+
+namespace DS.WMS.Core.System.Entity;
+///
+/// 系统字典类型表
+///
+[SqlSugar.SugarTable("sys_dict_type")]
+public class SysDictType : BaseModel
+{
+ ///
+ /// 名称
+ ///
+ [SqlSugar.SugarColumn(Length = 100,ColumnDescription="名称")]
+ public string Name { get; set; }
+
+ ///
+ /// 编码
+ ///
+ [SqlSugar.SugarColumn(Length = 50,ColumnDescription="编码")]
+ public string Code { get; set; }
+
+
+ ///
+ /// 排序
+ ///
+ [SqlSugar.SugarColumn(ColumnDescription = "排序")]
+ public int? OrderNo { get; set; } = 100;
+
+
+ ///
+ /// 状态
+ ///
+ [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/Entity/SysPermission.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysPermission.cs
index 5cc574d3..bd6613c2 100644
--- a/ds-wms-service/DS.WMS.Core/System/Entity/SysPermission.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysPermission.cs
@@ -118,7 +118,7 @@ public class SysPermission : BaseModel
#endregion 拓展字段
///
- ///权限实体
+ /// 权限实体
///
public string PermissionEntity { get; set; }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/ICommonService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/ICommonService.cs
index 0f3742fe..0fb1f62b 100644
--- a/ds-wms-service/DS.WMS.Core/System/Interface/ICommonService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Interface/ICommonService.cs
@@ -89,6 +89,11 @@ public interface ICommonService
///
DataResult> GetOrgList();
+ ///
+ /// 获取客户数据权限列表
+ ///
+ ///
+ public DataResult> GetClientPermissionList();
///
/// 修改密码
///
diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/IDataRuleService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/IDataRuleService.cs
index 5e4a0b13..948e957f 100644
--- a/ds-wms-service/DS.WMS.Core/System/Interface/IDataRuleService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Interface/IDataRuleService.cs
@@ -1,9 +1,30 @@
using DS.Module.Core;
+using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface;
public interface IDataRuleService
{
- DataResult> GetListByPage(PageRequest request);
+ ///
+ /// 列表
+ ///
+ ///
+ ///
+ DataResult> GetListByPage(PageRequest request);
+
+
+ ///
+ /// 编辑
+ ///
+ ///
+ ///
+ DataResult EditDataRule(DataRuleReq model);
+
+ ///
+ /// 获取详情
+ ///
+ ///
+ ///
+ DataResult GetDataRuleInfo(string id);
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/ISysDictDataService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/ISysDictDataService.cs
new file mode 100644
index 00000000..a5e19a49
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Interface/ISysDictDataService.cs
@@ -0,0 +1,27 @@
+using DS.Module.Core;
+using DS.WMS.Core.System.Dtos;
+
+namespace DS.WMS.Core.System.Interface;
+
+public interface ISysDictDataService
+{
+ ///
+ /// 列表查询
+ ///
+ ///
+ ///
+ DataResult> GetListByPage(PageRequest request);
+ ///
+ /// 添加字典值
+ ///
+ ///
+ ///
+ DataResult EditDictData(DictDataReq model);
+
+ ///
+ /// 获取详情
+ ///
+ ///
+ ///
+ DataResult GetDictDataInfo(string id);
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/ISysDictTypeService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/ISysDictTypeService.cs
new file mode 100644
index 00000000..46a009e7
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Interface/ISysDictTypeService.cs
@@ -0,0 +1,27 @@
+using DS.Module.Core;
+using DS.WMS.Core.System.Dtos;
+
+namespace DS.WMS.Core.System.Interface;
+
+public interface ISysDictTypeService
+{
+ ///
+ /// 列表查询
+ ///
+ ///
+ ///
+ DataResult> GetListByPage(PageRequest request);
+ ///
+ /// 添加字典类型
+ ///
+ ///
+ ///
+ DataResult EditDictType(DictTypeReq model);
+
+ ///
+ /// 获取详情
+ ///
+ ///
+ ///
+ DataResult GetDictTypeInfo(string id);
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/ISysRoleService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/ISysRoleService.cs
index a4faeccf..a1bd67f8 100644
--- a/ds-wms-service/DS.WMS.Core/System/Interface/ISysRoleService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Interface/ISysRoleService.cs
@@ -55,4 +55,10 @@ public interface ISysRoleService
///
///
DataResult UpdateRolePermission(RolePermissionInput model);
+ ///
+ /// 更新角色权限-客户端
+ ///
+ ///
+ ///
+ public DataResult UpdateClientRolePermission(RolePermissionInput model);
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/ITenantService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/ITenantService.cs
index 6f7b3b22..32afb966 100644
--- a/ds-wms-service/DS.WMS.Core/System/Interface/ITenantService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Interface/ITenantService.cs
@@ -1,6 +1,8 @@
using DS.Module.Core;
+using DS.Module.Core.Data;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
+using SqlSugar;
namespace DS.WMS.Core.System.Interface;
@@ -39,4 +41,18 @@ public interface ITenantService
///
///
public DataResult UpdateTenantPermission(TenantPermissionReq req);
+
+ ///
+ /// 获取租户表差异
+ ///
+ ///
+ ///
+ public DataResult GetSaasTableDifference(string id);
+
+ ///
+ /// 更新租户表差异
+ ///
+ ///
+ ///
+ public DataResult UpdateSaasTableInfo(IdModel req);
}
\ No newline at end of file
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 770e7432..bee3fcc6 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs
@@ -603,8 +603,10 @@ public class CommonService : ICommonService
foreach (var item in list)
{
var childs = db.Queryable().Where(x =>
- x.MenuType == 2 && x.ParentId == item.ParentId && x.IsHidden == false && permissions.Contains(x.PermissionId) &&
- (x.PermissionType == 1 || x.PermissionType == 0))
+ x.MenuType == 2 && x.ParentId == item.ParentId && x.IsHidden == false &&
+ permissions.Contains(x.PermissionId) &&
+ (x.PermissionType == 1 || x.PermissionType == 0) &&
+ x.PermissionId != 1744968217220222976) //排除企业用户维护
.OrderBy(x => x.SortCode)
.Select(a => new RouteItem
{
@@ -760,7 +762,7 @@ public class CommonService : ICommonService
}
#endregion 获取用户下拉列表
-
+
#region 获取机构下拉列表
///
@@ -781,6 +783,26 @@ public class CommonService : ICommonService
#endregion 获取机构下拉列表
+
+ #region 获取客户数据权限列表
+
+ ///
+ /// 获取客户数据权限列表
+ ///
+ ///
+ public DataResult> GetClientPermissionList()
+ {
+ var list = db.Queryable().Where(x => x.MenuType == 2 && x.IsHidden == false &&
+ (x.PermissionType == 1 || x.PermissionType == 0) &&
+ x.Id != 1744968217220222976 &&
+ (x.PermissionEntity != "" || x.PermissionEntity != null))
+ .Select()
+ .ToList();
+ return DataResult>.Success("获取数据成功!", list);
+ }
+
+ #endregion
+
#region 修改密码
///
@@ -954,41 +976,39 @@ public class CommonService : ICommonService
return db.Queryable(); //超级管理员特权
}
- var moduleName = typeof(T).Name;
- var rule = db.Queryable().First(u => u.PermissionName == moduleName);
- if (rule == null) return db.Queryable(); //没有设置数据规则,那么视为该资源允许被任何主体查看
+ var moduleName = typeof(T).Name.ToLower();
+ var rule = db.Queryable()
+ .First(u => u.PermissionEntity.ToLower() == moduleName && u.Status == StatusEnum.Enable);
+ if (rule == null) return db.Queryable(); //没有设置数据规则,那么视为该资源允许被任何主体查看
- var ruleConditions = JsonConvert.DeserializeObject(rule.DataRules);
- if (ruleConditions.RoleCondition.Count > 0)
+ if (rule.DataRules.Contains(DataRuleConst.LoginUser))
{
- var roles = db.Queryable().Where(x => x.UserId == long.Parse(user.UserId))
- .Select(u => u.RoleId.ToString()).ToList();
- roles.Sort(); //按字母排序,这样可以进行like操作
-
- var ruleCondition = ruleConditions.RoleCondition[0];
-
- if (ruleCondition.ConditionalType == SqlSugar.ConditionalType.In)
- {
- var s = ruleCondition.FieldValue.Split(',');
-
- var intersectArr = roles.Intersect(s);
-
- if (intersectArr.Count() == 0)
- {
- throw new Exception("该用户角色无权限!");
- }
- }
+ //即把{loginUser} =='xxxxxxx'换为 user.UserId =='xxxxxxx',从而把当前登录的用户名与当时设计规则时选定的用户id对比
+ rule.DataRules = rule.DataRules.Replace(DataRuleConst.LoginUser, user.UserId);
}
- if (ruleConditions.QueryCondition.Count > 0)
+ if (rule.DataRules.Contains(DataRuleConst.LoginRole))
{
- return db.Queryable()
- .Where(ruleConditions.QueryCondition);
+ var roles = db.Queryable().Where(x => x.UserId == long.Parse(user.UserId))
+ .Select(n => n.RoleId)
+ .ToList();
+ roles.Sort();
+ rule.DataRules = rule.DataRules.Replace(DataRuleConst.LoginRole, string.Join(',', roles));
}
- else
+
+ if (rule.DataRules.Contains(DataRuleConst.LoginOrg))
{
- return db.Queryable();
+ var orgs = db.Queryable().Where(x => x.UserId == long.Parse(user.UserId)).Select(n => n.OrgId)
+ .ToList();
+ orgs.Sort();
+ rule.DataRules = rule.DataRules.Replace(DataRuleConst.LoginOrg, string.Join(',', orgs));
}
+
+ var conditions = rule.DataRules.ConvertSqlSugarExpression();
+ var conditionalModels =
+ db.ConfigQuery.Context.Utilities.JsonToConditionalModels(
+ JsonConvert.SerializeObject(conditions));
+ return db.Queryable().Where(conditionalModels);
}
diff --git a/ds-wms-service/DS.WMS.Core/System/Method/DataRuleService.cs b/ds-wms-service/DS.WMS.Core/System/Method/DataRuleService.cs
index e1b85b60..67ba3695 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/DataRuleService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/DataRuleService.cs
@@ -1,8 +1,10 @@
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;
@@ -26,16 +28,63 @@ public class DataRuleService : IDataRuleService
}
///
- ///
+ /// 列表
///
///
///
- public DataResult> GetListByPage(PageRequest request)
+ public DataResult> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable()
- .Where(whereList).ToQueryPage(request.PageCondition);
+ .LeftJoin((a, b) => a.PermissionId == b.Id)
+ .Where(whereList)
+ .Select().ToQueryPage(request.PageCondition);
return data;
}
+ ///
+ /// 编辑
+ ///
+ ///
+ ///
+ public DataResult EditDataRule(DataRuleReq req)
+ {
+ if (req.Id == 0)
+ {
+
+ if (db.Queryable().Where(x=>x.PermissionId == req.PermissionId).Any())
+ {
+ return DataResult.Failed("数据权限已存在!",MultiLanguageConst.DataRuleExist);
+ }
+
+ 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).ExecuteCommand();
+ return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
+ }
+ }
+ ///
+ /// 详情
+ ///
+ ///
+ ///
+ public DataResult GetDataRuleInfo(string id)
+ {
+ var data = db.Queryable()
+ .LeftJoin((a, b) => a.PermissionId == b.Id)
+ .Where(a => a.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/System/Method/SysDictDataService.cs b/ds-wms-service/DS.WMS.Core/System/Method/SysDictDataService.cs
new file mode 100644
index 00000000..2a961b5f
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Method/SysDictDataService.cs
@@ -0,0 +1,75 @@
+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 SysDictDataService:ISysDictDataService
+{
+ private readonly IServiceProvider _serviceProvider;
+ private readonly ISqlSugarClient db;
+ private readonly IUser user;
+ private readonly ICommonService _commonService;
+ ///
+ ///
+ ///
+ ///
+ public SysDictDataService(IServiceProvider serviceProvider)
+ {
+ _serviceProvider = serviceProvider;
+ db = _serviceProvider.GetRequiredService();
+ user = _serviceProvider.GetRequiredService();
+ _commonService = _serviceProvider.GetRequiredService();
+ }
+ public DataResult> GetListByPage(PageRequest request)
+ {
+ //序列化查询条件
+ var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
+ var data = db.Queryable()
+ .Select()
+ .Where(whereList).ToQueryPage(request.PageCondition);
+ return data;
+ }
+
+ public DataResult EditDictData(DictDataReq req)
+ {
+ if (req.Id == 0)
+ {
+ var isExist = db.Queryable().Where(x =>x.TypeId == req.TypeId && x.Code == req.Code).First();
+ if (isExist != null)
+ {
+ return DataResult.Failed("字典值唯一编码已存在!",MultiLanguageConst.DictCodeExist);
+ }
+
+ 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).ExecuteCommand();
+ return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
+ }
+ }
+
+ public DataResult GetDictDataInfo(string id)
+ {
+ var data = db.Queryable()
+ .Where(a => a.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/System/Method/SysDictTypeService.cs b/ds-wms-service/DS.WMS.Core/System/Method/SysDictTypeService.cs
new file mode 100644
index 00000000..49c04a60
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/System/Method/SysDictTypeService.cs
@@ -0,0 +1,78 @@
+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 SysDictTypeService:ISysDictTypeService
+{
+ private readonly IServiceProvider _serviceProvider;
+ private readonly ISqlSugarClient db;
+ private readonly IUser user;
+ private readonly ICommonService _commonService;
+ ///
+ ///
+ ///
+ ///
+ public SysDictTypeService(IServiceProvider serviceProvider)
+ {
+ _serviceProvider = serviceProvider;
+ db = _serviceProvider.GetRequiredService();
+ user = _serviceProvider.GetRequiredService();
+ _commonService = _serviceProvider.GetRequiredService();
+ }
+ public DataResult> GetListByPage(PageRequest request)
+ {
+ //序列化查询条件
+ var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
+ var data = db.Queryable()
+ .Select()
+ .Where(whereList).ToQueryPage(request.PageCondition);
+ return data;
+ }
+
+ public DataResult EditDictType(DictTypeReq req)
+ {
+ if (req.Id == 0)
+ {
+ var isExist = db.Queryable().Where(x => x.Code == req.Code).First();
+ if (isExist != null)
+ {
+ return DataResult.Failed("字典类型唯一编码已存在!",MultiLanguageConst.DictCodeExist);
+ }
+
+ 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).ExecuteCommand();
+ return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
+ }
+ }
+
+ public DataResult GetDictTypeInfo(string id)
+ {
+ var data = db.Queryable()
+ .Where(a => a.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/System/Method/SysOrgService.cs b/ds-wms-service/DS.WMS.Core/System/Method/SysOrgService.cs
index 67abd843..bf75e8ff 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/SysOrgService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/SysOrgService.cs
@@ -72,7 +72,7 @@ public class SysOrgService:ISysOrgService
}
}
///
- ///
+ /// 获取机构信息
///
///
///
@@ -98,7 +98,7 @@ public class SysOrgService:ISysOrgService
ParentId = a.ParentId
}).ToList();
- var orgList = BulidTree(list);
+ var orgList = BuildTree(list);
return DataResult>.Success("获取数据成功!", orgList);
}
@@ -108,7 +108,7 @@ public class SysOrgService:ISysOrgService
///
///
///
- public static List BulidTree(List treeNodes)
+ public static List BuildTree(List treeNodes)
{
try
{
diff --git a/ds-wms-service/DS.WMS.Core/System/Method/SysRoleService.cs b/ds-wms-service/DS.WMS.Core/System/Method/SysRoleService.cs
index a845004a..e57dc94e 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/SysRoleService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/SysRoleService.cs
@@ -1,5 +1,6 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
+using DS.Module.Core.Helpers;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
@@ -245,4 +246,87 @@ public class SysRoleService : ISysRoleService
}
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
+
+
+ public DataResult UpdateClientRolePermission(RolePermissionInput model)
+ {
+ var existPermissions = db.Queryable().Where(x => x.RoleId == model.RoleId && x.IsPermission == 1).Select(n => n.PermissionId).ToArray();
+
+ IEnumerable delPermissions = existPermissions.AsQueryable().Except(model.PermissionIds);
+ if (delPermissions.Count() > 0)
+ {
+ db.Updateable()
+ .SetColumns(it => it.IsPermission == 0)//SetColumns是可以叠加的 写2个就2个字段赋值
+ .Where(it => it.RoleId == model.RoleId && delPermissions.Contains(it.PermissionId))
+ .ExecuteCommand();
+ }
+ IEnumerable addPermissions = model.PermissionIds.AsQueryable().Except(existPermissions);
+ if (addPermissions.Count() > 0)
+ {
+ var existNoPermissions = db.Queryable().Where(x => x.RoleId == model.RoleId && x.IsPermission == 0).Select(n => n.PermissionId).ToArray();
+ IEnumerable updatePermissions = existNoPermissions.AsQueryable().Except(addPermissions);
+ if (updatePermissions.Count() > 0)
+ {
+ db.Updateable()
+ .SetColumns(it => it.IsPermission == 1)
+ .Where(it => it.RoleId == model.RoleId && updatePermissions.Contains(it.PermissionId))
+ .ExecuteCommand();
+ }
+ IEnumerable addRolePermissions = addPermissions.AsQueryable().Except(existNoPermissions);
+
+ #region 租户模块权限检测
+
+ var tenant = db.Queryable().Where(x=>x.Id ==long.Parse(user.TenantId)).First();
+ foreach (var item in addRolePermissions)
+ {
+ var per = db.Queryable().Where(x => x.Id == item)
+ .First();
+ if (per.MenuType == 2)
+ {
+ var perAuth = db.Queryable().Where(x=>x.PermissionId == item).First();
+ if (perAuth.IsNotNull())
+ {
+ var authNum = EncrypteHelper.DecryptData(perAuth.AuthNum, tenant.AppSecret);
+
+ var roleList = db.Queryable()
+ .Where(x => x.PermissionId == item && x.IsPermission == 1).Select(n => n.RoleId).ToList();
+
+ roleList.Add(model.RoleId);
+ roleList.Distinct();
+ var userList = new List();
+ foreach (var role in roleList)
+ {
+ var userArr = db.Queryable().Where(x => x.RoleId == role).Select(n => n.UserId)
+ .ToList();
+ userList.AddRange(userArr);
+ }
+
+ userList.Distinct();
+
+ var userCount = userList.Count();
+ if (userCount>= int.Parse(authNum))
+ {
+
+ return DataResult.Failed(string.Format("{0}模块数量超出授权数量{1}",per.PermissionName, int.Parse(authNum)),MultiLanguageConst.PerAuthNumLimit);
+ }
+ }
+ }
+ }
+
+
+ #endregion
+
+ foreach (var item in addRolePermissions)
+ {
+ var permission = new SysRolePermission
+ {
+ RoleId = model.RoleId,
+ PermissionId = item,
+ IsPermission = 1,
+ };
+ db.Insertable(permission).ExecuteCommand();
+ }
+ }
+ return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
+ }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Method/TenantApplyService.cs b/ds-wms-service/DS.WMS.Core/System/Method/TenantApplyService.cs
index 6bce7c63..c34742b9 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/TenantApplyService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/TenantApplyService.cs
@@ -156,6 +156,7 @@ public class TenantApplyService : ITenantApplyService
foreach (var item in permissions)
{
var tenantPer = item.Adapt();
+ tenantPer.Id = 0;
tenantPer.TenantId = tenant.Id;
tenantPer.PermissionId = item.Id;
diff --git a/ds-wms-service/DS.WMS.Core/System/Method/TenantService.cs b/ds-wms-service/DS.WMS.Core/System/Method/TenantService.cs
index 79684a54..ca6a532f 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/TenantService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/TenantService.cs
@@ -1,6 +1,9 @@
+using System.Reflection;
using DS.Module.Core;
+using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
+using DS.Module.SqlSugar;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
@@ -17,7 +20,7 @@ public class TenantService : ITenantService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
-
+ private readonly ISaasDbService saasService;
///
///
///
@@ -26,6 +29,7 @@ public class TenantService : ITenantService
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService();
+ saasService = _serviceProvider.GetRequiredService();
}
///
@@ -96,9 +100,27 @@ public class TenantService : ITenantService
IEnumerable addPermissions = req.PermissionIds.AsQueryable().Except(existPermissions);
if (addPermissions.Count() > 0)
- {
+ {
var addPers = db.Queryable().Filter(null, true)
.Where(x => addPermissions.Contains(x.Id)).ToList();
+
+ #region 处理租户管理员新增权限
+
+ var tenantRole = db.Queryable().Filter(null, true)
+ .Where(x => x.TenantId == req.TenantId && x.RoleCode == "tenantAdmin").First();
+ //写入租户管理员权限
+ var rolePerList = new List();
+ foreach (var item in addPers)
+ {
+ var rolePer = item.Adapt();
+ rolePer.RoleId = tenantRole.Id;
+ rolePer.PermissionId = item.Id;
+ rolePer.IsPermission = 1;
+
+ rolePerList.Add(rolePer);
+ }
+ db.Insertable(rolePerList).ExecuteCommandAsync();
+ #endregion 处理租户管理员新增权限
var tenantPerList = new List();
foreach (var item in addPers)
{
@@ -166,4 +188,36 @@ public class TenantService : ITenantService
return DataResult>.Success("获取数据成功!", list, MultiLanguageConst.DataQuerySuccess);
}
+
+ ///
+ /// 获取租户表差异
+ ///
+ ///
+ ///
+ public DataResult GetSaasTableDifference(string id)
+ {
+ Type[] types= Assembly
+ .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
+ .GetTypes().Where(it=>it.FullName != null && it.FullName.Contains("DS.WMS.Core.Code."))//命名空间过滤,当然你也可以写其他条件过滤
+ .ToArray();
+ var tenantDb = saasService.GetBizDbById(id);
+ var data = db.CodeFirst.GetDifferenceTables(types);
+ return DataResult.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
+ }
+ ///
+ /// 更新租户表差异
+ ///
+ ///
+ ///
+ public DataResult UpdateSaasTableInfo(IdModel req)
+ {
+ Type[] types= Assembly
+ .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
+ .GetTypes().Where(it=>it.FullName != null && it.FullName.Contains("DS.WMS.Core.Code."))//命名空间过滤,当然你也可以写其他条件过滤
+ .ToArray();
+ var tenantDb = saasService.GetBizDbById(req.Id);
+ StaticConfig.CodeFirst_MySqlCollate="utf8mb4_0900_ai_ci";//较高版本支持
+ tenantDb.CodeFirst.InitTables(types);
+ return DataResult.Successed("更新租户表信息成功!", MultiLanguageConst.DataUpdateSuccess);
+ }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/ClientFlowTemplateController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/ClientFlowTemplateController.cs
index c4b84ac1..d477a77c 100644
--- a/ds-wms-service/DS.WMS.MainApi/Controllers/ClientFlowTemplateController.cs
+++ b/ds-wms-service/DS.WMS.MainApi/Controllers/ClientFlowTemplateController.cs
@@ -58,7 +58,30 @@ public class ClientFlowTemplateController : ApiController
var res = _invokeService.GetClientFlowTemplateInfo(id);
return res;
}
-
+ ///
+ /// 导入模板
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("ImportFlowTemplate")]
+ public DataResult ImportFlowTemplate([FromQuery] string id)
+ {
+ var res = _invokeService.ImportFlowTemplate(id);
+ return res;
+ }
+ ///
+ /// 删除模板
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("DelFlowTemplate")]
+ public DataResult DelFlowTemplate([FromQuery] string id)
+ {
+ var res = _invokeService.DelFlowTemplate(id);
+ return res;
+ }
///
/// 获取模板列表
diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/CommonController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/CommonController.cs
index d405e8c2..6f86fc54 100644
--- a/ds-wms-service/DS.WMS.MainApi/Controllers/CommonController.cs
+++ b/ds-wms-service/DS.WMS.MainApi/Controllers/CommonController.cs
@@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.System.Dtos;
+using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -185,7 +186,17 @@ public class CommonController : ApiController
return res;
}
-
+ ///
+ /// 获取客户数据权限列表
+ ///
+ ///
+ [HttpGet]
+ [Route("GetClientPermissionList")]
+ public DataResult> GetClientPermissionList()
+ {
+ var res = _invokeService.GetClientPermissionList();
+ return res;
+ }
///
/// 获取数据库表及视图名
///
@@ -209,4 +220,31 @@ public class CommonController : ApiController
var res = _invokeService.GetColumns(tableViewName);
return res;
}
+
+ ///
+ /// 获取用户字段设置
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("GetUserFieldSet")]
+ public DataResult GetUserFieldSet([FromQuery] string permissionId)
+ {
+ var res = _invokeService.GetUserFieldSet(permissionId);
+ return res;
+ }
+
+
+ ///
+ /// 更新用户字段设置
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("UpdateUserFieldSet")]
+ public DataResult UpdateUserFieldSet([FromBody] UserFieldSetUpdateReq req)
+ {
+ var res = _invokeService.UpdateUserFieldSet(req);
+ return res;
+ }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/DataRuleController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/DataRuleController.cs
new file mode 100644
index 00000000..d8b36bed
--- /dev/null
+++ b/ds-wms-service/DS.WMS.MainApi/Controllers/DataRuleController.cs
@@ -0,0 +1,62 @@
+using DS.Module.Core;
+using DS.WMS.Core.System.Dtos;
+using DS.WMS.Core.System.Interface;
+using Microsoft.AspNetCore.Mvc;
+
+namespace DS.WMS.MainApi.Controllers;
+
+///
+/// 数据权限模块
+///
+public class DataRuleController : ApiController
+{
+ private readonly IDataRuleService _invokeService;
+
+ ///
+ /// 构造函数
+ ///
+ ///
+ public DataRuleController(IDataRuleService invokeService)
+ {
+ _invokeService = invokeService;
+ }
+
+ ///
+ /// 列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("GetDataRuleList")]
+ public DataResult> GetDataRuleList([FromBody] PageRequest request)
+ {
+ var res = _invokeService.GetListByPage(request);
+ return res;
+ }
+
+ ///
+ /// 编辑
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("EditDataRule")]
+ public DataResult EditDataRule([FromBody] DataRuleReq req)
+ {
+ var res = _invokeService.EditDataRule(req);
+ return res;
+ }
+
+ ///
+ /// 详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("GetDataRuleInfo")]
+ public DataResult GetDataRuleInfo([FromQuery] string id)
+ {
+ var res = _invokeService.GetDataRuleInfo(id);
+ return res;
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/RoleController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/RoleController.cs
index 61dbb778..07e7a444 100644
--- a/ds-wms-service/DS.WMS.MainApi/Controllers/RoleController.cs
+++ b/ds-wms-service/DS.WMS.MainApi/Controllers/RoleController.cs
@@ -87,15 +87,15 @@ public class RoleController : ApiController
}
///
- /// 更新角色权限
+ /// 更新角色权限-客户端
///
///
///
[HttpPost]
- [Route("UpdateRolePermission")]
- public DataResult UpdateRolePermission([FromBody] RolePermissionInput model)
+ [Route("UpdateClientRolePermission")]
+ public DataResult UpdateClientRolePermission([FromBody] RolePermissionInput model)
{
- var res = _invokeService.UpdateRolePermission(model);
+ var res = _invokeService.UpdateClientRolePermission(model);
return res;
}
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt
index 8f87d113..a6ea881d 100644
--- a/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt
+++ b/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt
@@ -138,3 +138,24 @@
2024-02-19 14:09:24.2207 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-02-19 14:09:24.2517 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-19 14:09:24.3040 Info Configuration initialized.
+2024-02-20 09:40:59.5968 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-20 09:40:59.6794 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-20 09:40:59.7454 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-20 09:40:59.8286 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-02-20 09:40:59.9372 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
+2024-02-20 09:40:59.9923 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-20 09:41:00.1331 Info Configuration initialized.
+2024-02-22 18:00:02.8205 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-22 18:00:02.8930 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-22 18:00:02.9099 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-22 18:00:02.9383 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-02-22 18:00:02.9564 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
+2024-02-22 18:00:02.9679 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-22 18:00:02.9866 Info Configuration initialized.
+2024-02-23 08:54:46.3885 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-23 08:54:46.5134 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-23 08:54:46.5423 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-23 08:54:46.5925 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-02-23 08:54:46.6245 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
+2024-02-23 08:54:46.6406 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-23 08:54:46.6758 Info Configuration initialized.
diff --git a/ds-wms-service/DS.WMS.Test/SaasTest.cs b/ds-wms-service/DS.WMS.Test/SaasTest.cs
new file mode 100644
index 00000000..3f0be21a
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Test/SaasTest.cs
@@ -0,0 +1,46 @@
+using System.Reflection;
+using DS.Module.Core;
+using DS.Module.Core.Extensions;
+using DS.Module.SqlSugar;
+using DS.WMS.Core.System.Entity;
+using Microsoft.Extensions.DependencyInjection;
+using SqlSugar;
+using SqlSugar.IOC;
+using Xunit;
+
+namespace Ds.WMS.Test;
+
+public class SaasTest
+{
+ private readonly IServiceProvider _serviceProvider;
+ private readonly SqlSugarScope db;
+ private readonly ISaasDbService saasService;
+ public SaasTest(IServiceProvider serviceProvider)
+ {
+ _serviceProvider = serviceProvider;
+ db = (SqlSugarScope)_serviceProvider.GetRequiredService();
+ saasService = _serviceProvider.GetRequiredService();
+ }
+
+ [Fact]
+ public void TreeTest1()
+ {
+ Type[] types= Assembly
+ .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
+ .GetTypes().Where(it=>it.FullName.Contains("DS.WMS.Core.Code."))//命名空间过滤,当然你也可以写其他条件过滤
+ .ToArray();
+ var tenantDb = saasService.GetBizDbById("1750335377144680448");
+ var temp = db.CodeFirst.GetDifferenceTables(types);
+ // var diffString= tenantDb.CodeFirst.GetDifferenceTables(types).ToDiffString();
+ // StaticConfig.CodeFirst_MySqlCollate="utf8mb4_0900_ai_ci";//较高版本支持
+ // tenantDb.CodeFirst.InitTables(types);
+ // //初始化数库
+ // tenantDb.DbMaintenance.CreateDatabase();
+ //
+ // tenantDb.CodeFirst.InitTables(typeof(CodeCountry));
+ Assert.True(true);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Test/Startup.cs b/ds-wms-service/DS.WMS.Test/Startup.cs
index 8e6ee9e1..8683c70d 100644
--- a/ds-wms-service/DS.WMS.Test/Startup.cs
+++ b/ds-wms-service/DS.WMS.Test/Startup.cs
@@ -2,6 +2,7 @@ using Autofac;
using Autofac.Extensions.DependencyInjection;
using DS.Module.AutofacModule;
using DS.Module.SqlSugar;
+using DS.Module.UserModule;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -48,7 +49,9 @@ public class Startup
public void ConfigureServices(IServiceCollection services, HostBuilderContext hostBuilderContext)
{
// services.AddTransient();
+ services.AddUserModuleInstall(); //用户服务
services.AddSqlsugarInstall();
+ services.AddSaasDbInstall();
}
///
diff --git a/ds-wms-service/DS.WMS.Test/UnitTest1.cs b/ds-wms-service/DS.WMS.Test/UnitTest1.cs
index e4b24d5f..43e66002 100644
--- a/ds-wms-service/DS.WMS.Test/UnitTest1.cs
+++ b/ds-wms-service/DS.WMS.Test/UnitTest1.cs
@@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.System.Entity;
+using DS.WMS.Core.System.Interface;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using Xunit;
@@ -11,11 +12,12 @@ public class UnitTest1
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
-
+ // private readonly ICommonService _commonService;
public UnitTest1(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService();
+ // _commonService = _serviceProvider.GetRequiredService();
}
[Fact]
@@ -40,4 +42,25 @@ public class UnitTest1
ConstUtil.GetConstantField();
Assert.True(true);
}
+ [Fact]
+ public void DataRuleTest()
+ {
+ // var query = _commonService.GetDataRuleFilter();
+
+ var query = GetDataRuleFilter();
+ Assert.True(true);
+ }
+ public ISugarQueryable GetDataRuleFilter()
+ {
+ // var userInfo = db.Queryable().First(x => x.Id == long.Parse(user.UserId));
+ // if (userInfo.UserType == 0)
+ // {
+ // return db.Queryable(); //超级管理员特权
+ // }
+
+ var moduleName = typeof(T).Name;
+ // var rule = db.Queryable().First(u => u.PermissionName == moduleName);
+ // if (rule == null) return db.Queryable(); //没有设置数据规则,那么视为该资源允许被任何主体查看
+ return db.Queryable();
+ }
}
\ No newline at end of file