wangxinhui
2025-01-09 1c3c6a93bf2bb3af1aa13258640be333eef1e1c7
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs
@@ -30,18 +30,21 @@
                CodeRuleAttribute? codeRuleAttribute = propertyInfo.GetCustomAttribute<CodeRuleAttribute>();
                if (codeRuleAttribute != null)
                {
                    SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig
                    if (propertyInfo.GetValue(entityInfo.EntityValue) == null)
                    {
                        ConfigId = MainDb.CurrentDbConnId,
                        ConnectionString = DBContext.GetMainConnectionDb().Connection,
                        IsAutoCloseConnection = true,
                        DbType = MainDb.DbType,
                    });
                    dynamic ruleConfig = sugarClient.Queryable(MainDb.CodeRuleConfig, "x").Where(nameof(CodeRuleAttribute.RuleCode), "=", codeRuleAttribute.RuleCode.ToString()).First();
                    if (ruleConfig != null)
                    {
                        string code = CreateCodeByRule(ruleConfig, sugarClient);
                        propertyInfo.SetValue(entityInfo.EntityValue, code, null);
                        SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig
                        {
                            ConfigId = MainDb.CurrentDbConnId,
                            ConnectionString = DBContext.GetMainConnectionDb().Connection,
                            IsAutoCloseConnection = true,
                            DbType = MainDb.DbType,
                        });
                        dynamic ruleConfig = sugarClient.Queryable(MainDb.CodeRuleConfig, "x").Where(nameof(CodeRuleAttribute.RuleCode), "=", codeRuleAttribute.RuleCode.ToString()).First();
                        if (ruleConfig != null)
                        {
                            string code = CreateCodeByRule(ruleConfig, sugarClient);
                            propertyInfo.SetValue(entityInfo.EntityValue, code, null);
                        }
                    }
                }