Sfoglia il codice sorgente

V1.1.4 调整查询项目账户查询写法

yumeng 4 anni fa
parent
commit
ef871d52a6

+ 4 - 18
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -28,21 +28,10 @@ import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 项目成员
@@ -191,9 +180,10 @@ public class ProjectMemberController {
             List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
             List<JSONObject> haveList = new ArrayList<>();
             if (!Check.isNull(projectList)) {
+                Map<Long, List<JSONObject>> accountMap = userAllocationService.getAccountListByProjectList(projectList);
                 for (int i = 0; i < projectList.size(); i++) {
                     JSONObject project = projectList.get(i);
-                    List<JSONObject> accountList = userAllocationService.getAccountListByProject(project.getLong("projectId"));
+                    List<JSONObject> accountList = accountMap.get(project.getLong("projectId"));
                     if (!Check.isNull(accountList)) {
                         project.put("accountList", accountList);
                         haveList.add(project);
@@ -596,9 +586,5 @@ public class ProjectMemberController {
 
     }
 
-    public static void main(String[] args) {
-
-    }
-
 
 }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -42,4 +42,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     String getCompanyNameByUserId(@Param("planId") String planId);
 
     List<UserAllocation> listByMediaId(@Param("mediaId")String mediaId, @Param("accountStatus")Integer accountStatus);
+
+    List<JSONObject> getAccountListByProjectList(@Param("list") List list);
 }

+ 28 - 10
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -31,14 +31,32 @@
 
     <select id="getAccountListByProject" resultType="com.alibaba.fastjson.JSONObject">
        select
-       account_id as 'accountId',
-       user_name as 'userName',
-       auth_name as 'authName'
-       from ctop_user_allocation
-       where project_id = #{projectId}
-       order by create_time desc
+       t1.account_id as 'accountId',
+       (select  realname  from sys_user where  id = t1.user_id ) as 'userName',
+       t1.auth_name as 'authName'
+       from ctop_user_allocation t1
+       where t1.project_id = #{projectId}
+       order by t1.create_time desc
     </select>
 
+    <select id="getAccountListByProjectList" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        t1.project_id as 'projectId',
+        t1.account_id as 'accountId',
+        (select realname from sys_user where id = t1.user_id ) as 'userName',
+        t1.auth_name as 'authName'
+        from ctop_user_allocation t1
+        where t1.project_id in
+        <foreach collection="list" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+
+
+        order by t1.create_time desc
+    </select>
+
+
     <select id="getUserIdListByProjectId" resultType="com.alibaba.fastjson.JSONObject">
    SELECT t1.user_id as 'userId',
     t1.account_id as 'accountId',
@@ -128,10 +146,10 @@
         select a.* from ctop_user_allocation a
         left join ctop_project p on p.id = a.project_id
         where
-            1=1
-            <if test="null!=accountStatus">
-                and a.account_status = #{accountStatus}
-            </if>
+        1=1
+        <if test="null!=accountStatus">
+            and a.account_status = #{accountStatus}
+        </if>
         <if test="null!=mediaId">
             and p.media_id = #{mediaId}
         </if>

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -43,4 +43,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     JSONObject getSwitchStatusByAccount(Long accountId);
 
     List<Long> getAccountsByDeleteComment();
+
+    Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
 }

+ 26 - 8
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -6,7 +6,6 @@ import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -96,8 +95,8 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     }
 
     @Override
-    public List<UserAllocation> listByMediaId(String mediaId,int accountStatus) {
-        return userAllocationMapper.listByMediaId(mediaId,accountStatus);
+    public List<UserAllocation> listByMediaId(String mediaId, int accountStatus) {
+        return userAllocationMapper.listByMediaId(mediaId, accountStatus);
     }
 
     @Override
@@ -128,11 +127,11 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
 
     @Override
     public List<JSONObject> getAccountIdsByUserId(String userId) {
-        List<JSONObject> result= new ArrayList<>();
-        if(userId.equals("e9ca23d68d884d4ebb19d07889727dae")){
-            result=userAllocationMapper.getAllAccountIdsByMediaId("2");
-        }else {
-            result=userAllocationMapper.getAccountIdsByUserId(userId);
+        List<JSONObject> result = new ArrayList<>();
+        if (userId.equals("e9ca23d68d884d4ebb19d07889727dae")) {
+            result = userAllocationMapper.getAllAccountIdsByMediaId("2");
+        } else {
+            result = userAllocationMapper.getAccountIdsByUserId(userId);
 
         }
         return result;
@@ -157,4 +156,23 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     public List<Long> getAccountsByDeleteComment() {
         return userAllocationMapper.queryAccountsByDeleteComment();
     }
+
+    @Override
+    public Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList) {
+        Map<Long, List<JSONObject>> map = new HashMap<>();
+        List list = new ArrayList();
+        for (int i = 0; i < projectList.size(); i++) {
+            JSONObject jsonObject = projectList.get(i);
+            list.add(jsonObject.getLong("projectId"));
+            map.put(jsonObject.getLong("projectId"), new ArrayList<>());
+        }
+        List<JSONObject> jsonList = userAllocationMapper.getAccountListByProjectList(list);
+        for (int i = 0; i < jsonList.size(); i++) {
+            JSONObject jsonObject = jsonList.get(i);
+            Long projectId = jsonObject.getLong("projectId");
+            List<JSONObject> jsonObjects = map.get(projectId);
+            jsonObjects.add(jsonObject);
+        }
+        return map;
+    }
 }

+ 31 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java

@@ -40,6 +40,37 @@ public class KuaiShouMaterialControer {
     @Autowired
     private IKuaishouVideoRelateCreativesService relateCreativesService;
 
+
+    @PostMapping(value = "/getKuaiShouVideoList")
+    public JSONObject getKuaiShouVideoList(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参不能为空");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("未获取账号授权信息");
+            }
+
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            iKuaishouInterfaceService.getVideoList(token, nowDate, nowDate);
+            returnJson.put("code", 0);
+            returnJson.put("message", "素材更新成功");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
     /**
      * 查询上新素材
      *