赵冬冬 4 vuotta sitten
vanhempi
commit
baa45b8d76

+ 28 - 3
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/service/impl/UmsAdminServiceImpl.java

@@ -234,14 +234,28 @@ public class UmsAdminServiceImpl implements UmsAdminService {
     private UmsAdminRoleRelationMapper umsAdminRoleRelationMapper;
     @Override
     public int delete(Long id) {
-        adminCacheService.delAdmin(id);
-        adminCacheService.delResourceList(id);
+        long userId = CurrUserUtil.getUserId();
+        if(id==userId){
+            throw new GlobalException("无法删除自己!");
+        }
         int count = adminMapper.deleteByPrimaryKey(id);
+        //清楚redis数据
+        deleteRedisData(id);
+        //删除用户和角色相关数据
+        deleteUserRole(id);
+        return count;
+    }
+
+    private void deleteUserRole(Long id) {
         UmsAdminRoleRelationExample umsAdmin=new UmsAdminRoleRelationExample();
         UmsAdminRoleRelationExample.Criteria criteria = umsAdmin.createCriteria();
         criteria.andAdminIdEqualTo(id);
         umsAdminRoleRelationMapper.deleteByExample(umsAdmin);
-        return count;
+    }
+
+    private void deleteRedisData(Long id) {
+        adminCacheService.delAdmin(id);
+        adminCacheService.delResourceList(id);
     }
 
     @Override
@@ -355,6 +369,9 @@ public class UmsAdminServiceImpl implements UmsAdminService {
         UmsAdmin admin = getAdminByUsername(username);
         Integer status = admin.getStatus();
         if(status.intValue() ==0 ){
+            adminCacheService.delToken(admin.getUsername());
+            adminCacheService.delAdmin(admin.getId());
+            adminCacheService.delResourceList(admin.getId());
             throw new UsernameNotFoundException("用户被禁用!");
         }
         if (admin != null) {
@@ -373,10 +390,18 @@ public class UmsAdminServiceImpl implements UmsAdminService {
 
     @Override
     public int updateStatus(Long id, UmsAdmin umsAdmin){
+        Integer status = umsAdmin.getStatus();
         long userId = CurrUserUtil.getUserId();
         if(id==userId){
             throw new GlobalException("无法禁用自己!");
         }
+        UmsAdmin umsAdminRe = adminMapper.selectByPrimaryKey(id);
+
+        if(status==0){
+//            adminCacheService.delToken(umsAdminRe.getUsername());
+//            adminCacheService.delAdmin(id);
+//            adminCacheService.delResourceList(id);
+        }
         umsAdmin.setId(id);
         return adminMapper.updateByPrimaryKeySelective(umsAdmin);
     }

+ 21 - 4
forest-admin/admin-server/src/main/resources/dao/BigScreamDao.xml

@@ -52,7 +52,7 @@
         AND b.product_name = #{productName}
     </select>
     <select id="data6" resultType="java.lang.String">
-        SELECT CONCAT(IFNULL(a.ums_company_info,'   '),'---',a.`name`,'---',IFNULL(a.spec,'   '),'---',a.price) as pri FROM `pms_product` a where delete_status=0
+        SELECT CONCAT(IFNULL(a.comp_name,'   '),'---',a.`name`,'---',IFNULL(a.spec,'   '),'---',a.price) as pri FROM `pms_product` a where delete_status=0
     </select>
 
     <select id="data7" resultType="java.lang.String">
@@ -67,9 +67,26 @@ END
 ,'---',op.product_name) FROM `oms_pre_item` op LEFT JOIN ums_member um on op.member_id= um.id where op.delete_status=0 and um.`status`=1
     </select>
     <select id="data8" resultType="java.lang.String">
-        select CONCAT(company_type,'---',company_type,'---',COUNT(0)) comp from ums_company_info where comp_status=0 GROUP BY company_type
-    </select>
+    SELECT
+        CONCAT(
+            company_type,
+            '---',
+            company_type,
+            '---',
+            COUNT(0)
+        ) comp
+    FROM
+        ums_company_info
+WHERE
+	comp_status = 0
+GROUP BY
+	company_type    </select>
     <select id="data9" resultType="java.lang.String">
-        select concat(id,'---',comp_name) from ums_company_info where comp_status=0
+        SELECT
+            concat(id, '---', comp_name)
+        FROM
+            ums_company_info
+        WHERE
+            comp_status = 0
     </select>
 </mapper>

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 371 - 669
sql/forest-cloud-mall.sql