😎清理代码

This commit is contained in:
zuohuaijun 2025-09-03 11:12:21 +08:00
parent 0cd44ad692
commit a7a717c052
8 changed files with 24 additions and 27 deletions

View File

@ -536,6 +536,7 @@ public class SysAuthService : IDynamicApiController, ITransient
case ApiDescriptionSettingsAttribute settings: case ApiDescriptionSettingsAttribute settings:
if (!string.IsNullOrWhiteSpace(settings.GroupName)) groupName = settings.GroupName; if (!string.IsNullOrWhiteSpace(settings.GroupName)) groupName = settings.GroupName;
break; break;
case DisplayNameAttribute displayName: case DisplayNameAttribute displayName:
if (!string.IsNullOrWhiteSpace(displayName.DisplayName)) displayText = displayName.DisplayName; if (!string.IsNullOrWhiteSpace(displayName.DisplayName)) displayText = displayName.DisplayName;
break; break;

View File

@ -583,8 +583,8 @@ public static class SqlSugarExtension
if (string.IsNullOrWhiteSpace(value)) return; if (string.IsNullOrWhiteSpace(value)) return;
// 使用线程安全的延迟初始化服务实例获取文本缩写 // 使用线程安全的延迟初始化服务实例获取文本缩写
var abbrValue = LazyHelper.GetService<SysCommonService>() var abbrValue = LazyHelper.GetService<SysCommonService>().Value
.Value.GetNameAbbr(new() { Text = value, All = attribute.SaveFullAbbr }) .GetNameAbbr(new() { Text = value, All = attribute.SaveFullAbbr })
.GetAwaiter() .GetAwaiter()
.GetResult(); .GetResult();
entityInfo.SetValue(abbrValue); entityInfo.SetValue(abbrValue);

View File

@ -59,8 +59,7 @@ public static class SqlSugarFilter
if (string.IsNullOrWhiteSpace(userId)) return; if (string.IsNullOrWhiteSpace(userId)) return;
// 获取用户session // 获取用户session
var userManager = LazyHelper.GetService<UserManager>().Value; var session = LazyHelper.GetService<UserManager>().Value.GetSessionOrRefresh(userId);
var session = userManager.GetSessionOrRefresh(userId);
if (session == null) return; if (session == null) return;
// 配置用户机构集合缓存 // 配置用户机构集合缓存
@ -114,8 +113,7 @@ public static class SqlSugarFilter
if (string.IsNullOrWhiteSpace(userId)) return maxDataScope; if (string.IsNullOrWhiteSpace(userId)) return maxDataScope;
// 获取用户session // 获取用户session
var userManager = LazyHelper.GetService<UserManager>().Value; var session = LazyHelper.GetService<UserManager>().Value.GetSessionOrRefresh(userId);
var session = userManager.GetSessionOrRefresh(userId);
if (session == null) return (int)DataScopeEnum.Self; if (session == null) return (int)DataScopeEnum.Self;
// 获取用户最大数据范围---仅本人数据 // 获取用户最大数据范围---仅本人数据

View File

@ -37,8 +37,7 @@ public class SqlSugarRepository<T> : SimpleClient<T>, ISqlSugarRepository<T> whe
return; return;
// 若未贴任何表特性或当前未登录或是默认租户Id则返回默认库连接 // 若未贴任何表特性或当前未登录或是默认租户Id则返回默认库连接
var userManager = LazyHelper.GetService<UserManager>().Value; var tenantId = LazyHelper.GetService<UserManager>().Value.TenantId?.ToString();
var tenantId = userManager.TenantId?.ToString();
if (string.IsNullOrWhiteSpace(tenantId) || tenantId == SqlSugarConst.MainConfigId) return; if (string.IsNullOrWhiteSpace(tenantId) || tenantId == SqlSugarConst.MainConfigId) return;
// 根据租户Id切换库连接, 为空则返回默认库连接 // 根据租户Id切换库连接, 为空则返回默认库连接

View File

@ -91,8 +91,7 @@ namespace Admin.NET.Web.Core
} }
// 验证租户有效期 // 验证租户有效期
var userManager = LazyHelper.GetService<UserManager>().Value; var tenantId = LazyHelper.GetService<UserManager>().Value.TenantId?.ToString();
var tenantId = userManager.TenantId?.ToString();
if (!string.IsNullOrWhiteSpace(tenantId)) if (!string.IsNullOrWhiteSpace(tenantId))
{ {
var tenant = sysCacheService.Get<List<SysTenant>>(CacheConst.KeyTenant)?.FirstOrDefault(u => u.Id == long.Parse(tenantId)); var tenant = sysCacheService.Get<List<SysTenant>>(CacheConst.KeyTenant)?.FirstOrDefault(u => u.Id == long.Parse(tenantId));

View File

@ -20,7 +20,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="8" :md="8" :lg="8" :xl="8" class="mb20"> <el-col :xs="24" :sm="8" :md="8" :lg="8" :xl="8" class="mb20">
<el-form-item label="编码" prop="code"> <el-form-item label="编码">
<el-input v-model="state.ruleForm.code" placeholder="编码" clearable /> <el-input v-model="state.ruleForm.code" placeholder="编码" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -57,10 +57,10 @@
</el-col> </el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-form-item label="拓展数据"> <el-form-item label="拓展数据">
<div style="display: flex; flex-direction: column; gap: 10px; width: 100%;"> <div style="display: flex; flex-direction: column; gap: 10px; width: 100%">
<el-input v-model="state.ruleForm.extData" placeholder="请输入拓展数据" clearable type="textarea" :rows="12" style="width: 100%;" /> <el-input v-model="state.ruleForm.extData" placeholder="请输入拓展数据" clearable type="textarea" :rows="12" style="width: 100%" />
<div style="width: 100%;"> <div style="width: 100%">
<el-button type="primary" @click="formatJSON" style="width: 100%;">格式化JSON</el-button> <el-button type="primary" @click="formatJSON" style="width: 100%">格式化JSON</el-button>
</div> </div>
</div> </div>
</el-form-item> </el-form-item>