Jelajahi Sumber

调整差来看账户权限

yumeng 5 tahun lalu
induk
melakukan
8a4d94af38

+ 31 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.IUserAllocationService;
@@ -58,6 +59,8 @@ public class UserAllocationController {
     private UserAllocationMapper userAllocationMapper;
     @Autowired
     private IProjectService projectService;
+    @Autowired
+    private MaterialReportMapper materialReportMapper;
 
 
     @GetMapping(value = "/getAccountList")
@@ -86,6 +89,34 @@ public class UserAllocationController {
     }
 
 
+    @GetMapping(value = "/getAccountsByProjectId")
+    public Result<List<UserAllocation>> getAccountsByProjectId(String userId, Long projectId) {
+        Result<List<UserAllocation>> result = new Result<>();
+        try {
+            QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("project_id", projectId);
+            Project project = projectService.getById(projectId);
+            if (!Check.isNull(project)) {
+                queryWrapper.eq("media_id", project.getMediaId());
+            }
+
+            String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
+            if (!"admin".equals(roleCode) && !"kuaishouOperationManager".equals(roleCode)) {
+                queryWrapper.eq("user_id", userId);
+            }
+
+            List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
+            result.setSuccess(true);
+            result.setResult(userAllocations);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success("查询失败");
+        }
+
+        return result;
+
+    }
+
     @GetMapping(value = "/getAccountListByProjectId")
     public Result<List<UserAllocation>> getAccountListByProjectId(Long projectId) {
         Result<List<UserAllocation>> result = new Result<>();