Parcourir la source

1、增加租户状态设置(租户禁用后所有账号禁止登录) 2、暂时禁用表字段名称默认下划线处理 3、升级nuget包及其他优化

zuohuaijun il y a 3 ans
Parent
commit
d07fa8c21d

+ 3 - 3
Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj

@@ -17,9 +17,9 @@
     <PackageReference Include="AngleSharp" Version="0.17.1" />
     <PackageReference Include="AngleSharp" Version="0.17.1" />
     <PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
     <PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
     <PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.0.2" />
     <PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.0.2" />
-    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.2.11" />
-    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.2.11" />
-    <PackageReference Include="Furion.Pure" Version="4.8.2.11" />
+    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.3.3" />
+    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.3.3" />
+    <PackageReference Include="Furion.Pure" Version="4.8.3.3" />
     <PackageReference Include="Lazy.Captcha.Core" Version="1.1.6" />
     <PackageReference Include="Lazy.Captcha.Core" Version="1.1.6" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.7.2" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.7.2" />
     <PackageReference Include="Magicodes.IE.Pdf" Version="2.7.2" />
     <PackageReference Include="Magicodes.IE.Pdf" Version="2.7.2" />

+ 5 - 0
Admin.NET/Admin.NET.Core/Admin.NET.Core.xml

@@ -2702,6 +2702,11 @@
             禁止创建此类型的数据库
             禁止创建此类型的数据库
             </summary>
             </summary>
         </member>
         </member>
+        <member name="F:Admin.NET.Core.ErrorCodeEnum.Z1003">
+            <summary>
+            租户已禁用
+            </summary>
+        </member>
         <member name="T:Admin.NET.Core.GenderEnum">
         <member name="T:Admin.NET.Core.GenderEnum">
             <summary>
             <summary>
             性别枚举
             性别枚举

+ 6 - 0
Admin.NET/Admin.NET.Core/Enum/ErrorCodeEnum.cs

@@ -527,4 +527,10 @@ public enum ErrorCodeEnum
     /// </summary>
     /// </summary>
     [ErrorCodeItemMetadata("禁止创建此类型的数据库")]
     [ErrorCodeItemMetadata("禁止创建此类型的数据库")]
     Z1002,
     Z1002,
+
+    /// <summary>
+    /// 租户已禁用
+    /// </summary>
+    [ErrorCodeItemMetadata("租户已禁用")]
+    Z1003,
 }
 }

+ 5 - 0
Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs

@@ -69,6 +69,11 @@ public class SysAuthService : IDynamicApiController, ITransient
             .FirstAsync(u => u.Account.Equals(input.Account) && u.Password.Equals(encryptPasswod));
             .FirstAsync(u => u.Account.Equals(input.Account) && u.Password.Equals(encryptPasswod));
         _ = user ?? throw Oops.Oh(ErrorCodeEnum.D1000);
         _ = user ?? throw Oops.Oh(ErrorCodeEnum.D1000);
 
 
+        // 租户是否被禁用
+        var tenant = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysTenant>>().GetFirstAsync(u => u.Id == user.TenantId);
+        if (tenant.Status == StatusEnum.Disable)
+            throw Oops.Oh(ErrorCodeEnum.Z1003);
+
         // 账号是否被冻结
         // 账号是否被冻结
         if (user.Status == StatusEnum.Disable)
         if (user.Status == StatusEnum.Disable)
             throw Oops.Oh(ErrorCodeEnum.D1017);
             throw Oops.Oh(ErrorCodeEnum.D1017);

+ 1 - 1
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -48,7 +48,7 @@ public static class SqlSugarSetup
         {
         {
             EntityNameService = (type, entity) => // 处理表
             EntityNameService = (type, entity) => // 处理表
             {
             {
-                entity.DbTableName = UtilMethods.ToUnderLine(entity.DbTableName); // 驼峰转下划线
+                // entity.DbTableName = UtilMethods.ToUnderLine(entity.DbTableName); // 驼峰转下划线
             },
             },
             EntityService = (type, column) => // 处理列
             EntityService = (type, column) => // 处理列
             {
             {

+ 1 - 1
Web/src/layout/main/columns.vue

@@ -43,7 +43,7 @@ const initScrollBarHeight = () => {
 		setTimeout(() => {
 		setTimeout(() => {
 			updateScrollbar();
 			updateScrollbar();
 			layoutScrollbarRef.value.wrapRef.scrollTop = 0;
 			layoutScrollbarRef.value.wrapRef.scrollTop = 0;
-			layoutMainRef.value!.layoutMainScrollbarRef.wrapRef.scrollTop = 0;
+			if (layoutMainRef.value != undefined) layoutMainRef.value.layoutMainScrollbarRef.wrapRef.scrollTop = 0;
 		}, 500);
 		}, 500);
 	});
 	});
 };
 };

+ 14 - 3
Web/src/views/system/tenant/index.vue

@@ -30,10 +30,9 @@
 						<el-tag type="danger" v-else> 库隔离 </el-tag>
 						<el-tag type="danger" v-else> 库隔离 </el-tag>
 					</template>
 					</template>
 				</el-table-column>
 				</el-table-column>
-				<el-table-column prop="status" label="状态" width="70" align="center" show-overflow-tooltip>
+				<el-table-column label="状态" width="70" align="center" show-overflow-tooltip>
 					<template #default="scope">
 					<template #default="scope">
-						<el-tag type="success" v-if="scope.row.status === 1">启用</el-tag>
-						<el-tag type="danger" v-else>禁用</el-tag>
+						<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="2" size="small" @change="changeStatus(scope.row)" :disabled="scope.row.id == 123456780000000" />
 					</template>
 					</template>
 				</el-table-column>
 				</el-table-column>
 				<el-table-column prop="dbType" label="数据库类型" width="120" align="center" show-overflow-tooltip>
 				<el-table-column prop="dbType" label="数据库类型" width="120" align="center" show-overflow-tooltip>
@@ -214,6 +213,17 @@ export default defineComponent({
 				})
 				})
 				.catch(() => {});
 				.catch(() => {});
 		};
 		};
+		// 修改状态
+		const changeStatus = (row: any) => {
+			getAPI(SysTenantApi)
+				.sysTenantSetStatusPost({ id: row.id, status: row.status })
+				.then(() => {
+					ElMessage.success('租户状态设置成功');
+				})
+				.catch(() => {
+					row.status = row.status == 1 ? 2 : 1;
+				});
+		};
 		return {
 		return {
 			editTenantRef,
 			editTenantRef,
 			grantMenuRef,
 			grantMenuRef,
@@ -227,6 +237,7 @@ export default defineComponent({
 			handleSizeChange,
 			handleSizeChange,
 			handleCurrentChange,
 			handleCurrentChange,
 			createTenant,
 			createTenant,
+			changeStatus,
 			...toRefs(state),
 			...toRefs(state),
 		};
 		};
 	},
 	},

+ 3 - 0
Web/src/views/system/user/index.vue

@@ -204,6 +204,9 @@ export default defineComponent({
 		const changeStatus = (row: any) => {
 		const changeStatus = (row: any) => {
 			getAPI(SysUserApi)
 			getAPI(SysUserApi)
 				.sysUserSetStatusPost({ id: row.id, status: row.status })
 				.sysUserSetStatusPost({ id: row.id, status: row.status })
+				.then(() => {
+					ElMessage.success('账号状态设置成功');
+				})
 				.catch(() => {
 				.catch(() => {
 					row.status = row.status == 1 ? 2 : 1;
 					row.status = row.status == 1 ? 2 : 1;
 				});
 				});