Przeglądaj źródła

通用文案权限细分

huangxuechao 4 lat temu
rodzic
commit
d2cd339729

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceGeneralCopywriterMapper.java

@@ -14,7 +14,7 @@ import org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter;
  * @version V1.0
  */
 public interface ByteDanceGeneralCopywriterMapper extends BaseMapper<ByteDanceGeneralCopywriter> {
-    List<Map<String,Object>> selectGeneralCopywriterReport(String userId, String accountId, String keyWord, String startTime, String endTime);
+    List<Map<String,Object>> selectGeneralCopywriterReport(List<String> accountIds, String keyWord, String startTime, String endTime);
 
     ByteDanceCreativeWordPackage selectCreativeWordPackageByName(String name);
 }

+ 7 - 5
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceGeneralCopywriterMapper.xml

@@ -9,7 +9,6 @@
         SELECT
             a.account_id as accountId,
             d.creative_id as creativeId,
-            e.user_id as userId,
             a.text_copywriter AS textCopywriter,
             count(*) AS creativeCount,
             sum(d.cost) AS sumCost,
@@ -18,17 +17,20 @@
             sum(d.show_num) AS sumConvertMaterial
         FROM
             ctop_bytedance_general_copywriter a
-        LEFT JOIN ctop_user_allocation e on a.account_id = e.account_id
         LEFT JOIN ctop_bytedance_creative b ON a.text_copywriter = b.title and a.account_id = b.account_id
         LEFT JOIN ctop_bytedance_report_creative_daily d ON b.id = d.creative_id
         WHERE
             a.`status` = 0
-            <if test="userId!=null and userId!=''">and e.user_id = #{userId}</if>
-            <if test="accountId!=null and accountId!=''">and a.account_id = #{accountId}</if>
             <if test="keyWord!=null and keyWord!=''">and a.text_copywriter like concat('%',#{keyWord},'%')</if>
             <if test="startTime!=null and startTime!=''">and STR_TO_DATE(d.stat_datetime,'%Y-%m-%d') &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d')</if>
             <if test="endTime!=null and endTime!=''">and STR_TO_DATE(d.stat_datetime,'%Y-%m-%d') &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d')</if>
-
+        <if test="accountIds!=null and accountIds!=''">
+            AND a.account_id IN
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         GROUP BY
         a.text_copywriter
 

+ 27 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceGeneralCopywriterServiceImpl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.bytedance.advertise.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import org.apache.commons.lang3.StringUtils;
@@ -9,7 +10,9 @@ import org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter;
 import org.jeecg.modules.bytedance.advertise.mapper.ByteDanceGeneralCopywriterMapper;
 import org.jeecg.modules.bytedance.advertise.mapper.BytedanceVideoSlogenInfoMapper;
 import org.jeecg.modules.bytedance.advertise.service.IByteDanceGeneralCopywriterService;
+import org.jeecg.modules.bytedance.common.service.IUserAllocationService;
 import org.jeecg.modules.bytedance.common.utils.Check;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -17,6 +20,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -30,12 +34,33 @@ import java.util.Map;
 public class ByteDanceGeneralCopywriterServiceImpl extends ServiceImpl<ByteDanceGeneralCopywriterMapper, ByteDanceGeneralCopywriter> implements IByteDanceGeneralCopywriterService {
     @Resource
     ByteDanceGeneralCopywriterMapper byteDanceGeneralCopywriterMapper;
-
+    @Autowired
+    IUserAllocationService IUserAllocationService;
 
     @Override
     public Result getGeneralCopywriterReport(String userId, String accountId, String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize){
         PageHelper.startPage(pageNum,pageSize);
-        List<Map<String, Object>> generalCopywriteReportList = byteDanceGeneralCopywriterMapper.selectGeneralCopywriterReport(userId, accountId,keyWord, startTime, endTime);
+
+        List<String> accountIds = new ArrayList<>();
+        //查询普通用户的全量查询,当前用户所有项目
+        if(Check.isNull(accountId)){
+            List<JSONObject> jsonObjectList = IUserAllocationService.getAccountIdsByUserId(userId);
+            if(!Check.isNull(jsonObjectList)){
+                for (JSONObject jsonObject:jsonObjectList) {
+                    accountIds.add((String) jsonObject.get("account_id"));
+                }
+            }else{
+                return Result.successMsg("当前登录人未绑定账户","");
+            }
+
+        }else if(accountId == "admin"){//管理员的全量查询
+            accountIds = null;
+        }else { //不论什么权限的用户的单独搜索一个项目
+            accountIds.add(accountId);
+        }
+
+
+        List<Map<String, Object>> generalCopywriteReportList = byteDanceGeneralCopywriterMapper.selectGeneralCopywriterReport(accountIds,keyWord, startTime, endTime);
         if(Check.isNull(generalCopywriteReportList)){
             return Result.successMsg("还没有此文案报表数据,请将此文案投放跑量!",generalCopywriteReportList);
         }

+ 0 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/BytedanceVideoSlogenInfoServiceImpl.java

@@ -64,7 +64,6 @@ public class BytedanceVideoSlogenInfoServiceImpl extends ServiceImpl<BytedanceVi
     @Override
     public Result getVideoSlogenReport(String userId, String projectId,String keyWord, String startTime, String endTime, Integer pageNum, Integer pageSize){
         PageHelper.startPage(pageNum,pageSize);
-        System.out.println(userId+"------------"+projectId);
         List<String> projectIdList = new ArrayList<>();
         //查询普通用户的全量查询,当前用户所有项目
         if(Check.isNull(projectId)){

+ 4 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceGeneralCopywriterController.java

@@ -104,7 +104,7 @@ public class BytedanceGeneralCopywriterController {
 
 
             byteDanceGeneralCopywriterService.saveBatch(byteDanceGeneralCopywriterList);
-            result.success("添加成功"+byteDanceGeneralCopywriterList.size()+"条"+",失败"+(list.size() - byteDanceGeneralCopywriterList.size())+"条");
+            result.success("添加成功"+byteDanceGeneralCopywriterList.size()+"条"+",失败"+(list.size() * accountIds.length - byteDanceGeneralCopywriterList.size())+"条");
             result.setCode(0);
         } catch (IOException e) {
             result.error500("动态词包格式错误,请重新上传!");
@@ -149,14 +149,13 @@ public class BytedanceGeneralCopywriterController {
     ) {
         try {
 
-            //查询用户角色
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
             if (Check.isNull(roleCode)){
                 return Result.errorMsg("请输入正确的用户id。");
             }
-            //角色为 管理员 || 销售 || 媒介 查询全部
-            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
-                userId = null;
+            //角色为 管理员并且projectId是空表示:全量查询
+            if ("admin".equals(roleCode) && Check.isNull(accountId)) {
+                accountId = "admin";	//传递projectId为admin
             }
 
             return byteDanceGeneralCopywriterService.getGeneralCopywriterReport(userId,accountId,keyWord, startTime,endTime,pageNo,pageSize);