Selaa lähdekoodia

微信查询企业信息+档案新增查看权限

anderx 1 vuosi sitten
vanhempi
commit
fc48c516c7

+ 2 - 5
src/main/java/com/goafanti/customer/controller/UserArchivesController.java

@@ -1,10 +1,8 @@
 package com.goafanti.customer.controller;
 
 import com.goafanti.common.bo.Result;
-import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.controller.BaseController;
 import com.goafanti.common.model.UserArchives;
-import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.customer.service.UserArchivesService;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -107,12 +105,11 @@ public class UserArchivesController  extends BaseController {
     @GetMapping("/queryByUidAll")
     public Result queryByUidAll( String id) {
         Result res = new Result<>();
-
-        if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)&&!TokenManager.hasRole(AFTConstants.SALESMAN_MANAGER)
-        &&!TokenManager.hasRole(AFTConstants.SALESMAN_ADMIN)){
+        if (userArchivesService.checkPermission(id)){
             res.error(buildError("查看权限不足"));
             return res;
         }
+
         res.data(this.userArchivesService.queryByUidAll(id));
         return res;
     }

+ 2 - 0
src/main/java/com/goafanti/customer/service/UserArchivesService.java

@@ -49,4 +49,6 @@ public interface UserArchivesService {
     Object queryByUid(String id);
 
     Object queryByUidAll(String id);
+
+    boolean checkPermission(String id);
 }

+ 20 - 1
src/main/java/com/goafanti/customer/service/impl/UserArchivesServiceImpl.java

@@ -1,10 +1,14 @@
 package com.goafanti.customer.service.impl;
 
+import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.UserArchivesMapper;
+import com.goafanti.common.dao.UserMapper;
 import com.goafanti.common.model.OrganizationContactBook;
+import com.goafanti.common.model.User;
 import com.goafanti.common.model.UserArchives;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.customer.bo.UserArchivesDetails;
 import com.goafanti.customer.service.CustomerService;
 import com.goafanti.customer.service.UserArchivesService;
@@ -29,7 +33,8 @@ public class UserArchivesServiceImpl extends BaseMybatisDao< UserArchivesMapper>
     private UserArchivesMapper userArchivesMapper;
     @Resource
     private CustomerService customerService;
-    
+    @Resource
+    private UserMapper userMapper;
     
     
     @Override
@@ -61,6 +66,20 @@ public class UserArchivesServiceImpl extends BaseMybatisDao< UserArchivesMapper>
         return user;
     }
 
+    @Override
+    public boolean checkPermission(String id) {
+        User user = userMapper.selectByPrimaryKey(id);
+        if (user.getAid().equals(TokenManager.getAdminId())){
+            return false;
+        }else {
+            if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)&&!TokenManager.hasRole(AFTConstants.SALESMAN_MANAGER)
+                    &&!TokenManager.hasRole(AFTConstants.SALESMAN_ADMIN)){
+                return true;
+            }
+        }
+        return true;
+    }
+
     /**
      * 通过ID查询单条数据
      *