Browse Source

子账号登录 增加 启用禁用判断 切换账号增加效验

qinxuyang 2 tháng trước cách đây
mục cha
commit
50471319c8

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/StorePlatformUserRole.java

@@ -55,4 +55,8 @@ public class StorePlatformUserRole implements Serializable {
     @TableField("account_name")
     private String accountName;
 
+    @ApiModelProperty(value = "禁用标志(0启用 1 禁用)")
+    @TableField("status")
+    private Integer status;
+
 }

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/SubAccountStoreListVo.java

@@ -49,4 +49,7 @@ public class SubAccountStoreListVo implements Serializable {
 
     @ApiModelProperty(value = "手机号")
     private String phone;
+
+    @ApiModelProperty(value = "禁用标志(0启用 1禁用)")
+    private Integer status;
 }

+ 9 - 5
alien-entity/src/main/resources/mapper/SubAccountStoreMapper.xml

@@ -17,7 +17,8 @@
             spr.role_name COLLATE utf8mb4_unicode_ci AS roleName,
             spur.user_id AS userId,
             spur.account_name COLLATE utf8mb4_unicode_ci AS accountName,
-            su.phone COLLATE utf8mb4_unicode_ci AS phone
+            su.phone COLLATE utf8mb4_unicode_ci AS phone,
+            spur.status AS status
         FROM
             store_platform_user_role spur
         INNER JOIN store_user su ON spur.user_id = su.id
@@ -44,7 +45,8 @@
             NULL AS roleName,
             su_main.id AS userId,
             su_main.name COLLATE utf8mb4_unicode_ci AS accountName,
-            su_main.phone COLLATE utf8mb4_unicode_ci AS phone
+            su_main.phone COLLATE utf8mb4_unicode_ci AS phone,
+            NULL AS status
         FROM
             store_user su_main
         LEFT JOIN store_info si_main ON su_main.store_id = si_main.id 
@@ -85,7 +87,8 @@
             spr.role_name COLLATE utf8mb4_unicode_ci AS roleName,
             spur.user_id AS userId,
             spur.account_name COLLATE utf8mb4_unicode_ci AS accountName,
-            su.phone COLLATE utf8mb4_unicode_ci AS phone
+            su.phone COLLATE utf8mb4_unicode_ci AS phone,
+            spur.status AS status
         FROM
             store_platform_user_role spur
                 INNER JOIN store_user su ON spur.user_id = su.id
@@ -111,14 +114,15 @@
             NULL AS roleName,
             su_main.id AS userId,
             su_main.name COLLATE utf8mb4_unicode_ci AS accountName,
-            su_main.phone COLLATE utf8mb4_unicode_ci AS phone
+            su_main.phone COLLATE utf8mb4_unicode_ci AS phone,
+            NULL AS status
         FROM
             store_user su_main
                 INNER JOIN store_info si_main ON su_main.store_id = si_main.id
         WHERE
             (
                 -- 如果传入的是子账号,查询其主账号的门店
-                (su_main.id = (SELECT sub_account_id FROM store_user WHERE id = #{userId} AND account_type = 2 AND delete_flag = 0 LIMIT 1))
+                (su_main.id = (SELECT id FROM store_user WHERE id = #{userId} AND account_type = 2 AND delete_flag = 0 LIMIT 1))
            OR
            -- 如果传入的是主账号,查询自己的门店
             (su_main.id = #{userId} AND su_main.account_type = 1)

+ 3 - 0
alien-gateway/src/main/java/shop/alien/gateway/service/impl/StoreUserServiceImpl.java

@@ -173,6 +173,9 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserGatewayMapper, St
                     }
 
                     if (maxPermissionRole != null) {
+                        if(maxPermissionRole.getStatus() == 1){
+                            return R.fail("子账号已被禁用无法登录");
+                        }
                         // 设置门店ID和角色ID
                         storeUserVo.setStoreId(maxPermissionRole.getStoreId());
                         storeUserVo.setRoleId(maxPermissionRole.getRoleId());