Kaynağa Gözat

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-cloud

zhaoxian 4 yıl önce
ebeveyn
işleme
60b84e30e1

+ 3 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -51,7 +51,7 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
     List<UserAllocation> getAccountListByUserIdAndProductId(@Param("userId") String userId, @Param("projectId") Long projectId, @Param("productId") Long productId);
 
-    List<JSONObject> getUserIdListByProductId(@Param("productId") Long productId);
+    List<JSONObject> getUserIdListByProductId(@Param("productId") Long productId, @Param("userId") String userId);
 
     List<JSONObject> getByAccountIds(@Param("accountIds") JSONArray accountIds);
 
@@ -59,7 +59,7 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
     List<JSONObject> selectAccountsByKuaishouUserId(@Param("userId") Long userId);
 
-    int updateProjectStrategyStatus(@Param("accountId") Long accountId,@Param("projectStrategy") Integer projectStrategy);
+    int updateProjectStrategyStatus(@Param("accountId") Long accountId, @Param("projectStrategy") Integer projectStrategy);
 
     List<Long> queryAutomaticAccounts(@Param("projectId") Long projectId);
 
@@ -73,5 +73,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     List<JSONObject> getAccountListByProjectListV2(@Param("list") List list);
 
     List<JSONObject> getAccountListByProjectAndUserId(@Param("projectId") Long projectId, @Param("userId") String userId);
+
     List<Long> getAccountListByProjectId(@Param("projectId") Long projectId);
 }

+ 41 - 12
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -85,18 +85,47 @@
     GROUP BY t1.user_id;
     </select>
     <select id="getUserIdListByProductId" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT t1.user_id as 'userId',
-               t1.account_id as 'accountId',
-               t1.user_name  as 'userName'
-        from  ctop_kuaishou_advertiser_base_info t1  LEFT JOIN
-              ctop_user_allocation  t2
-              ON t1.account_id = t2.account_id
-                                                     left join
-              ctop_project t3
-                on t2.project_id=t3.id
-        WHERE t3.product_id = #{productId}
-          AND t2.account_status = 0
-        GROUP BY t1.user_id;
+       SELECT
+	*
+FROM
+	(
+		SELECT
+			t4.user_id AS 'userId',
+			t3.account_id AS 'accountId',
+			t3.auth_name AS 'userName',
+			t1.project_name AS 'projectName'
+		FROM
+			ctop_project t1
+		INNER JOIN (
+			SELECT
+				project_id
+			FROM
+				ctop_project_member
+			WHERE
+				project_id IN (
+					SELECT
+						id
+					FROM
+						ctop_project
+					WHERE
+						product_id = #{productId}
+					AND media_id IN (2, 4)
+				)
+        <if test="userId != null and userId != ''">
+            AND user_id = #{userId}
+        </if>
+		) t2 ON t1.id = t2.project_id
+		LEFT JOIN ctop_user_allocation t3 ON t1.id = t3.project_id
+		LEFT JOIN ctop_kuaishou_advertiser_base_info t4 ON t3.account_id = t4.account_id
+		WHERE
+			t1.product_id = #{productId}
+		AND t3.account_status = 0
+		GROUP BY
+			t4.user_id
+	) t
+ORDER BY
+	t.projectName,
+	t.userId
     </select>
 
     <select id="getValidProjectIds" resultType="java.lang.Long">

+ 4 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -4,7 +4,6 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.apache.ibatis.annotations.Param;
 import org.jeecg.common.api.vo.Result;
 
 import java.util.List;
@@ -46,11 +45,11 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     List<Long> getAccountsByDeleteComment();
 
-    List<UserAllocation> getAccountListByUserIdAndProductId(String userId,Long projectId,Long productId);
+    List<UserAllocation> getAccountListByUserIdAndProductId(String userId, Long projectId, Long productId);
 
     Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
 
-    List<JSONObject> getUserIdListByProductId(Long productId);
+    List<JSONObject> getUserIdListByProductId(Long productId, String userId);
 
     /**
      * 获取有效的项目ID集合
@@ -65,6 +64,7 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     List<Long> getKuaiShouUserIdListByProjectId(Long projectId);
 
     List<JSONObject> selectAccountsByKuaishouUserId(Long userId);
+
     boolean updateProjectStrategyStatus(Long accountId, Integer projectStrategy);
 
     List<Long> queryAutomaticAccounts(Long projectId);
@@ -74,5 +74,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     Map<Long, List<JSONObject>> getAccountListByProjectListV2(List<JSONObject> projectList);
 
     List<JSONObject> getAccountListByProjectAndUserId(Long projectId, String userId);
+
     List<Long> getAccountListByProjectId(Long projectId);
 }

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -223,8 +223,8 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     }
 
     @Override
-    public List<JSONObject> getUserIdListByProductId(Long productId) {
-        return userAllocationMapper.getUserIdListByProductId(productId);
+    public List<JSONObject> getUserIdListByProductId(Long productId,String userId) {
+        return userAllocationMapper.getUserIdListByProductId(productId,userId);
     }
 
     @Override

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

@@ -1,7 +1,5 @@
 package org.jeecg.modules.ctop.controller;
 
-import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
-import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.Project;
@@ -13,7 +11,6 @@ import cn.com.ctop.common.module.service.ISysRoleExtService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.StringUtils;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAdvertiserBaseInfoService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONArray;
@@ -98,13 +95,17 @@ public class UserAllocationController {
 
 
     @GetMapping(value = "/getUserIdListByProductId")
-    public Result<List<JSONObject>> getUserIdListByProductId(Long productId) {
+    public Result<List<JSONObject>> getUserIdListByProductId(Long productId, String userId) {
         Result<List<JSONObject>> result = new Result<>();
         try {
             if (Check.isNull(productId)) {
                 throw new Exception("请选择产品id");
             }
-            List<JSONObject> userIdList = userAllocationService.getUserIdListByProductId(productId);
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (roleCode.equals("admin")) {
+                userId = null;
+            }
+            List<JSONObject> userIdList = userAllocationService.getUserIdListByProductId(productId, userId);
             result.setSuccess(true);
             result.setResult(userIdList);
         } catch (Exception e) {