Przeglądaj źródła

认证通1.7.5版本功能开发

JiangChongBo 2 lat temu
rodzic
commit
063cb3d274

+ 140 - 4
src/main/java/com/caimei/controller/admin/auth/AuthApi.java

@@ -8,9 +8,7 @@ import com.caimei.components.RedisService;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.CmBrandAuthPo;
 import com.caimei.model.po.SysUser;
-import com.caimei.model.vo.AuthFormVo;
-import com.caimei.model.vo.AuthVo;
-import com.caimei.model.vo.ProductFormVo;
+import com.caimei.model.vo.*;
 import com.caimei.service.auth.AuthService;
 import com.caimei.utils.SmsUtils;
 import com.github.pagehelper.PageInfo;
@@ -547,7 +545,8 @@ public class AuthApi {
             JSONObject paramsMap = JSONObject.parseObject(params);
             String title = paramsMap.getString("title");
             String videoPath = paramsMap.getString("videoPath");
-            return authService.getclientToken( title, videoPath);
+            Integer authId=paramsMap.getInteger("authId");
+            return authService.getclientToken( title, videoPath,authId);
         }
         /**
          * 发布视频后通过webhook获取回调数据
@@ -568,6 +567,13 @@ public class AuthApi {
             String itemId=contentList.getString("item_id");
             System.out.println(itemId);
             String shareId=contentList.getString("share_id");
+            //根据回调的shareId保存itemId
+            if(StringUtils.isNotEmpty(shareId)&&StringUtils.isNotEmpty(itemId)){
+                if (authService.getShareId(shareId)){
+                    //根据shareId保存itemId
+                    authService.savaItemIdByShareId(shareId,itemId);
+                }
+            }
             System.out.println(shareId);
             Map<String ,String> map=new HashMap<>();
             map.put("challenge",challenge);
@@ -599,4 +605,134 @@ public class AuthApi {
             return ResponseJson.error("短信发送失败-----"+mobile);
         }
     }
+
+//    /**
+//     * 保存视频信息
+//     * @return
+//     */
+//    @PostMapping("/save/video/info")
+//    public ResponseJson saveVideoInfo(@RequestBody String params){
+//        JSONObject jsonObject=JSONObject.parseObject(params);
+////        //验证用户是否可以发布视频
+////         //是否为机构用户
+//        Integer authId=jsonObject.getInteger("authId");
+////        boolean flagAtuhId= authService.getauthUserId(authId);
+////        if(flagAtuhId){
+////            return ResponseJson.error("-1","由于您未认证机构,无法参与!");
+////        }
+////         //用户是否已经发不过视频
+//        String userName=jsonObject.getString("userName");
+////        Boolean flaguserName=authService.getuserName(userName);
+////        if(!flaguserName){
+////            return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
+////        }
+////         //判断是否在活动时间内
+////        Date date=new Date();
+////        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+////        String releaseTime = sf.format(date).replace("T", "");
+////        boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
+////        if(flagReleaseTime){
+////            return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
+////        }
+//        String title=jsonObject.getString("title");
+//        String ossName=jsonObject.getString("ossName");
+//        String cover=jsonObject.getString("cover");
+//        String ossUrl=jsonObject.getString("ossUrl");
+//        ChallengeRoundVo cr=new ChallengeRoundVo();
+//        cr.setUserName(userName);
+//        cr.setCover(cover);
+//        cr.setOssName(ossName);
+//        cr.setOssUrl(ossUrl);
+//        cr.setTitle(title);
+//        cr.setAuthId(authId);
+//        return authService.saveVideoInfo(cr);
+//    }
+//    @PostMapping("/get/published/video/list")
+//    public ResponseJson<List<ChallengeRoundVo>> getPublishedVideoList(@RequestBody String params){
+//        JSONObject jsonObject=JSONObject.parseObject(params);
+//        Integer status=jsonObject.getInteger("status");//1:未上传至抖音(前端使用) 否则不传(后端使用)
+//        String clubUserName=jsonObject.getString("clubUserName");
+//        Integer count=jsonObject.getInteger("count");
+//        Integer cursor =jsonObject.getInteger("cursor");
+//        if(count==null){
+//            count=10;
+//        }
+//        if(cursor==null){
+//            cursor=0;
+//        }
+//        return  authService.getPublishedVideoList(clubUserName,status,cursor,count);
+//    }
+//
+//    /**
+//     * 验证视频是否符合发布条件
+//     * @param params
+//     * @return
+//     */
+//    @PostMapping("/check/video/info")
+//    public ResponseJson checkVideoInfo(@RequestBody String params){
+//        JSONObject jsonObject=JSONObject.parseObject(params);
+//        //验证用户是否可以发布视频
+//        //是否为机构用户
+//        Integer authId=jsonObject.getInteger("authId");
+//        boolean flagAtuhId= authService.getauthUserId(authId);
+//        if(flagAtuhId){
+//            return ResponseJson.error("-1","由于您未认证机构,无法参与!");
+//        }
+//        //用户是否已经发不过视频
+//        String userName=jsonObject.getString("userName");
+//        Boolean flaguserName=authService.getuserName(userName);
+//        if(!flaguserName){
+//            return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
+//        }
+//        //判断是否在活动时间内
+//        Date date=new Date();
+//        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        String releaseTime = sf.format(date).replace("T", "");
+//        boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
+//        if(flagReleaseTime){
+//            return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
+//        }
+//        return ResponseJson.success();
+//    }
+
+    /**
+     * 保存活动信息
+     * @param params
+     * @return
+     */
+    @PostMapping("/save/activity/time")
+    public ResponseJson saveActivityTime(@CurrentUser SysUser sysUser,@RequestBody String params){
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        JSONObject jsonObject=JSONObject.parseObject(params);
+        String startTime = jsonObject.getString("startTime");
+        String endTime = jsonObject.getString("endTime");
+        Integer status = jsonObject.getInteger("status");
+        authService.saveActivityTime(startTime,endTime,status,authUserId);
+        return ResponseJson.success();
+    }
+    /**
+     *获取活动信息
+     * @return
+     */
+    @GetMapping("/get/activity/time")
+    public ResponseJson<ChallengeActivityVo> getActivityTime(@CurrentUser SysUser sysUser){
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return  authService.getActivityTime(authUserId);
+    }
 }

+ 139 - 0
src/main/java/com/caimei/controller/wechat/WxAuthApi.java

@@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -319,4 +321,141 @@ public class WxAuthApi {
         }
         return authProductService.getPronductInfo(authId,authUserId);
     }
+    /**
+     * 保存视频信息
+     * @return
+     */
+    @PostMapping("/save/video/info")
+    public ResponseJson saveVideoInfo(@CurrentUser SysUser sysUser,@RequestBody String params){
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        JSONObject jsonObject=JSONObject.parseObject(params);
+//        //验证用户是否可以发布视频
+//         //是否为机构用户
+        Integer authId=jsonObject.getInteger("authId");
+//        boolean flagAtuhId= authService.getauthUserId(authId);
+//        if(flagAtuhId){
+//            return ResponseJson.error("-1","由于您未认证机构,无法参与!");
+//        }
+//         //用户是否已经发不过视频
+        String userName=jsonObject.getString("userName");
+//        Boolean flaguserName=authService.getuserName(userName);
+//        if(!flaguserName){
+//            return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
+//        }
+//         //判断是否在活动时间内
+//        Date date=new Date();
+//        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        String releaseTime = sf.format(date).replace("T", "");
+//        boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
+//        if(flagReleaseTime){
+//            return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
+//        }
+        String title=jsonObject.getString("title");
+        String ossName=jsonObject.getString("ossName");
+        String cover=jsonObject.getString("cover");
+        String ossUrl=jsonObject.getString("ossUrl");
+        ChallengeRoundVo cr=new ChallengeRoundVo();
+        cr.setUserName(userName);
+        cr.setCover(cover);
+        cr.setOssName(ossName);
+        cr.setOssUrl(ossUrl);
+        cr.setTitle(title);
+        cr.setAuthId(authId);
+        cr.setAuthUserId(authUserId);
+        return authService.saveVideoInfo(cr);
+    }
+
+    /**
+     * 获取已发布视频
+     * @param sysUser
+     * @param status
+     * @param clubUserName
+     * @param cursor
+     * @param count
+     * @return
+     */
+    @GetMapping("/get/published/video/list")
+    public ResponseJson<List<ChallengeRoundVo>> getPublishedVideoList(@CurrentUser SysUser sysUser,Integer status,String clubUserName,Integer cursor,Integer count){
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        if(count==null){
+            count=10;
+        }
+        if(cursor==null){
+            cursor=0;
+        }
+        return  authService.getPublishedVideoList(clubUserName,status,cursor,count,authUserId);
+    }
+
+    /**
+     * 验证视频是否符合发布条件
+     * @param params
+     * @return
+     */
+    @PostMapping("/check/video/info")
+    public ResponseJson<ChallengeActivityVo> checkVideoInfo(@RequestBody String params){
+        JSONObject jsonObject=JSONObject.parseObject(params);
+        //验证用户是否可以发布视频
+        //是否为机构用户
+//        Integer authId=jsonObject.getInteger("authId");
+//        boolean flagAtuhId= authService.getauthUserId(authId);
+//        if(flagAtuhId){
+//            return  ResponseJson.success("0",null);
+//            return ResponseJson.error("-1","由于您未认证机构,无法参与!");
+//        }
+        //用户是否已经发过视频
+        String userName=jsonObject.getString("userName");
+        Boolean flaguserName=authService.getuserName(userName);
+        ChallengeActivityVo challengeActivityVo=new ChallengeActivityVo();
+        if(!flaguserName){
+            challengeActivityVo.setActivityState(0);
+            return  ResponseJson.success(challengeActivityVo);
+//            return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
+        }else{
+            challengeActivityVo.setActivityState(1);
+            return  ResponseJson.success(challengeActivityVo);
+        }
+        //判断是否在活动时间内
+//        Date date=new Date();
+//        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        String releaseTime = sf.format(date).replace("T", "");
+//        boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
+//        if(flagReleaseTime){
+//            return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
+//        }
+    }
+
+    /**
+     * 判断活动开启状态
+     * @param sysUser
+     * @return
+     */
+    @GetMapping("/get/activitty")
+    public ResponseJson<ChallengeActivityVo> getActivitty(@CurrentUser SysUser sysUser){
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return authService.getActivitty(authUserId);
+    }
 }

+ 25 - 4
src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java

@@ -3,10 +3,7 @@ package com.caimei.mapper.cmMapper;
 import com.caimei.model.po.CmBrandAuthPo;
 import com.caimei.model.po.LdmDataPo;
 import com.caimei.model.po.TownPo;
-import com.caimei.model.vo.AuthFormVo;
-import com.caimei.model.vo.AuthVo;
-import com.caimei.model.vo.ProductFormVo;
-import com.caimei.model.vo.TemplateVo;
+import com.caimei.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -128,4 +125,28 @@ public interface AuthMapper {
     List<ProductFormVo> getRelationgList(String snCode);
 
     String getPrefix(Integer authUserId);
+
+    void saveVideoInfo(@Param("userName") String userName,@Param("cover") String cover,@Param("ossUrl") String ossUrl,@Param("ossName") String ossName,@Param("title") String title,@Param("releaseTime") String releaseTime,@Param("authId") Integer authId,@Param("authUserId")Integer authUserId);
+
+    String getauthUserId(@Param("authId") Integer authId);
+
+    String getuserName(@Param("userName") String userName);
+
+    Integer checkActivityTime(@Param("releaseTime") String releaseTime);
+
+    List<ChallengeRoundVo> getPublishedVideoList(@Param("clubUserName")String clubUserName,@Param("status")Integer status,@Param("authUserId")Integer authUserId);
+
+    Integer checkActivityId();
+
+    void saveActivityInfo(@Param("startTime") String startTime,@Param("endTime")String endTime,@Param("status")Integer status,@Param("authUserId")Integer authUserId);
+
+    void upActivityInfo(@Param("startTime") String startTime,@Param("endTime")String endTime,@Param("status")Integer status,@Param("authUserId")Integer authUserId);
+
+    ChallengeActivityVo  getActivityTime(@Param("authUserId") Integer authUserId);
+
+    void savaShareIdByAuthId(@Param("authId")Integer authId,@Param("shareId")String shareId);
+
+    String getShareId(@Param("shareId")String shareId);
+
+    void savaItemIdByShareId(@Param("shareId")String shareId,@Param("itemId")String itemId);
 }

+ 31 - 0
src/main/java/com/caimei/model/vo/ChallengeActivityVo.java

@@ -0,0 +1,31 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+/**
+ * table:cm_challenge_activity
+ */
+@Data
+public class ChallengeActivityVo {
+    private Integer id;
+    /**
+     * 供应商id
+     */
+    private Integer authUserId;
+    /**
+     * 活动开始时间
+     */
+    private String  startTime;
+    /**
+     * 活动结束时间
+     */
+    private String  endtime;
+    /**
+     * 活动开启状态(0:未开启;1:已开启)
+     */
+    private Integer status;
+    /**
+     * 0: 活动未开始 1:活动进行中 2:活动已结束
+     */
+    private Integer activityState;
+}

+ 61 - 0
src/main/java/com/caimei/model/vo/ChallengeRoundVo.java

@@ -0,0 +1,61 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+/**
+ * tablae:cm_challenge_round
+ */
+@Data
+public class ChallengeRoundVo {
+        private Integer id;
+        private Integer authId;
+        /**
+         * 供应商id
+         */
+        private Integer authUserId;
+        /**
+         * 用户id
+         */
+        private String userName;
+        /**
+         * 发布到抖音的视频id
+         */
+        private String itemId;
+        /**
+         * 视频描述
+         */
+        private String title;
+        /**
+         * 视频oss名称
+         */
+        private String ossName;
+        /**
+         * 视频oss地址
+         */
+        private String ossUrl;
+        /**
+         * 视频封面
+         */
+        private String cover;
+        /**
+         * 视频发布时间
+         */
+        private String releaseTime;
+        /**
+         * 0:视频未上传到抖音;1:视频已上传到抖音
+         */
+        private Integer status;
+        /**
+         * 视频分享抖音凭证id
+         */
+        private String shareId;
+        /**
+         * 点赞
+         */
+        private String digg_count;
+        /**
+         * 播放数量
+         */
+        private String play_count;
+
+}

+ 13 - 0
src/main/java/com/caimei/model/vo/DyVideoInfoVo.java

@@ -0,0 +1,13 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+
+@Data
+public class DyVideoInfoVo {
+    private String item_id;
+
+    private String statistics;
+}

+ 31 - 0
src/main/java/com/caimei/model/vo/StatisticsVo.java

@@ -0,0 +1,31 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+@Data
+public class StatisticsVo {
+    /**
+     * 评论数量
+     */
+    private String comment_count;
+    /**
+     * 分享数量
+     */
+    private String share_count;
+    /**
+     * 点赞
+     */
+    private String digg_count;
+    /**
+     * 分享数量
+     */
+    private String forward_count;
+    /**
+     * 播放数量
+     */
+    private String play_count;
+    /**
+     * 下载数量
+     */
+    private String download_count;
+}

+ 75 - 5
src/main/java/com/caimei/service/auth/AuthService.java

@@ -1,12 +1,12 @@
 package com.caimei.service.auth;
 
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.CmBrandAuthPo;
-import com.caimei.model.vo.AuthFormVo;
-import com.caimei.model.vo.AuthVo;
-import com.caimei.model.vo.ProductFormVo;
-import com.caimei.model.vo.TemplateVo;
+import com.caimei.model.po.SysUser;
+import com.caimei.model.vo.*;
 import com.github.pagehelper.PageInfo;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
@@ -157,5 +157,75 @@ public interface AuthService {
      * @return
      * @throws IOException
      */
-    ResponseJson getclientToken(String title,String videoPath) throws IOException;
+    ResponseJson getclientToken(String title,String videoPath,Integer authId) throws IOException;
+    /**
+     * 保存视频信息
+     * @return
+     */
+    ResponseJson saveVideoInfo(ChallengeRoundVo challengeRoundVo);
+    /**
+     * 根据authid获取authUserId
+     */
+    boolean getauthUserId(Integer authId);
+
+    /**
+     * 判断是否存在userName
+     * @param userName
+     * @return
+     */
+    boolean getuserName(String userName);
+
+    /**
+     * 验证是否在活动时间内
+     * @return
+     */
+    boolean checkActivityTime(String releaseTime);
+
+    /**
+     * 获取已发布视频
+     * @param clubUserName
+     * @param status
+     * @param cursor
+     * @param count
+     * @return
+     */
+    ResponseJson<List<ChallengeRoundVo>> getPublishedVideoList(String clubUserName,Integer status,Integer cursor,Integer count,Integer authUserId);
+
+    /**
+     * 保存活动信息
+     * @param startTime
+     * @param endTime
+     * @param status
+     * @return
+     */
+    ResponseJson saveActivityTime(String startTime,String endTime,Integer status,Integer authUserId);
+
+    /**
+     * 获取活动信息
+     * @return
+     */
+     ResponseJson<ChallengeActivityVo> getActivityTime(Integer authUserId);
+
+    /**
+     * 获取shareId
+     * @param shareId
+     * @return
+     */
+    boolean getShareId(String shareId);
+
+    /**
+     * 根据ShareId保存itemId (webhook触发时调用)
+     * @param shareId
+     * @param itemId
+     */
+     void savaItemIdByShareId(String shareId,String itemId);
+
+    /**
+     * 判断活动开启状态
+     * @param sysUser
+     * @return
+     */
+     ResponseJson<ChallengeActivityVo> getActivitty(Integer sysUser);
+
+
 }

+ 143 - 8
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -1,5 +1,6 @@
 package com.caimei.service.auth.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei.components.RedisService;
@@ -66,6 +67,8 @@ import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * Description
@@ -956,7 +959,7 @@ public class AuthServiceImpl implements AuthService {
      * @throws IOException
      */
     @Override
-    public ResponseJson getclientToken(String title,String videoPath) throws IOException {
+    public ResponseJson getclientToken(String title,String videoPath,Integer authId) throws IOException {
         //获取accessToken
         String client_key = "awwwvh9tsnvo54w1";
         String client_secret = "1dd7446d29e16738787447b771ced2df";
@@ -985,7 +988,7 @@ public class AuthServiceImpl implements AuthService {
             JSONObject params=JSONObject.parseObject(data);
             String accessToken=params.getString("access_token");
             //根据accesstoken获取tiket
-             schema = getDouYingTicket(accessToken, title,videoPath);
+             schema = getDouYingTicket(accessToken, title,videoPath,authId);
             EntityUtils.consume(he);
         } catch (IOException e) {
             e.printStackTrace();
@@ -997,7 +1000,7 @@ public class AuthServiceImpl implements AuthService {
      * 根据token获取ticket
      **/
     @RequestMapping("/getDouYingTicket")
-    public String getDouYingTicket(String clientToken,String title,String videoPath) throws IOException {
+    public String getDouYingTicket(String clientToken,String title,String videoPath,Integer authId) throws IOException {
         //时间戳
         long l = System.currentTimeMillis();
         String timestamp = String.valueOf(l);
@@ -1021,6 +1024,8 @@ public class AuthServiceImpl implements AuthService {
             String ticket = params.getString("ticket");
             //getDouYingshareId
             String shareId = getDouYingshareId(clientToken);
+            //保存shareId用于回调时存储item_id
+            authMapper.savaShareIdByAuthId(authId,shareId);
             //获取签名 并且用md5加密
             String signature = signatureAlgorithm(ticket, timestamp,noncestr);
             //获取schema(返回前端用于生成二维码发布视频)
@@ -1113,13 +1118,14 @@ public class AuthServiceImpl implements AuthService {
      * @param cursor 分页游标, 第一页请求cursor是0, response中会返回下一页请求用到的cursor, 同时response还会返回has_more来表明是否有更多的数据。
      * @param count  每页数量 10
      */
-    public void getVideoList(String openId,Integer cursor,Integer count,String accessToken){
+    public String getVideoList(String openId,Integer cursor,Integer count,String accessToken){
         String requestUrl="https://open.douyin.com/video/list/?open_id="+openId+"&cursor="+cursor+"&count="+count;
         //创建httppost对象
         CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
         HttpGet hg = new HttpGet(requestUrl);
         hg.setHeader("Content-Type","application/json");
         hg.addHeader("access-token",accessToken);
+        String resultList=null;
         try {
             CloseableHttpResponse execute = closeableHttpClient.execute(hg);
             HttpEntity entity = execute.getEntity();
@@ -1127,15 +1133,15 @@ public class AuthServiceImpl implements AuthService {
             JSONObject jsonObject = JSONObject.parseObject(result);
             String data = jsonObject.getString("data");
             JSONObject paramslist = JSONObject.parseObject(data);
-            String itemIdlist = paramslist.getString("list");
-            JSONArray params = JSONArray.parseArray(itemIdlist);
-            String itemId = params.getJSONObject(0).get("item_id").toString();
+             resultList = paramslist.getString("list");
+//             resultList = JSONArray.parseArray(itemIdlist);
+//            String itemId = params.getJSONObject(0).get("item_id").toString();
             //根据itemid获取视频的数据(点赞,播放,评论量)
             EntityUtils.consume(entity);
         } catch (IOException e) {
             e.printStackTrace();
         }
-
+        return resultList;
     }
 
     /**
@@ -1153,4 +1159,133 @@ public class AuthServiceImpl implements AuthService {
         }
         return sb.toString();
     }
+    /**
+     * 保存视频信息
+     * @return
+     */
+    @Override
+    public ResponseJson saveVideoInfo(ChallengeRoundVo cr){
+        Date date=new Date();
+        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String releaseTime = sf.format(date).replace("T", "");
+        authMapper.saveVideoInfo(cr.getUserName(),cr.getCover(),cr.getOssUrl(),cr.getOssName(),cr.getTitle(),releaseTime,cr.getAuthId(),cr.getAuthUserId());
+        return ResponseJson.success("保存成功",null);
+    }
+
+    /**
+     * 根据authid获取authUserId
+     * @param authId
+     * @return
+     */
+    @Override
+   public boolean getauthUserId(Integer authId){
+       String authUserId= authMapper.getauthUserId(authId);
+        return StringUtils.isEmpty(authUserId);
+   }
+
+    /**
+     * 判断是否存在userName
+     * @param userName
+     * @return
+     */
+    @Override
+    public boolean getuserName(String userName){
+       String name= authMapper.getuserName(userName);
+       return StringUtils.isEmpty(name);
+   }
+
+    /**
+     * 验证是否在活动时间内
+     * @param releaseTime 发布时间
+     * @return
+     */
+    @Override
+    public boolean checkActivityTime(String releaseTime){
+       Integer id=  authMapper.checkActivityTime(releaseTime);
+        return id==null?true:false;
+   }
+
+    /**
+     * 获取已发布视频列表
+     * @param clubUserName 手机号或者机构名
+     * @param status 用户发布状态
+     * @param cursor 页码
+     * @param count  条数
+     * @return
+     */
+    @Override
+   public ResponseJson<List<ChallengeRoundVo>> getPublishedVideoList(String clubUserName,Integer status,Integer cursor,Integer count,Integer authUserId){
+       List<ChallengeRoundVo> listChallengeRoundVo=authMapper.getPublishedVideoList(clubUserName,status,authUserId);
+       //调用抖音api获取视频数据
+        String dyopenId=redisService.get("DyopenId").toString();
+        String DYaccessToken=redisService.get("DYaccessToken").toString();
+        String paramsList = getVideoList(dyopenId, cursor, count, DYaccessToken);
+
+        List<DyVideoInfoVo> list= JSONArray.parseArray(paramsList, DyVideoInfoVo.class);
+        for (ChallengeRoundVo ChallengeRoundVo:listChallengeRoundVo) {
+            for (DyVideoInfoVo dyVideoInfoVo:list) {
+                if(dyVideoInfoVo.getItem_id().equals(ChallengeRoundVo.getItemId())){
+                    StatisticsVo StatisticsVo= JSONObject.parseObject(dyVideoInfoVo.getStatistics(), StatisticsVo.class);
+                    ChallengeRoundVo.setDigg_count(StatisticsVo.getDigg_count());
+                    ChallengeRoundVo.setPlay_count(StatisticsVo.getPlay_count());
+                    break;
+                }
+            }
+        }
+        //根据点赞量降序排序
+        List<ChallengeRoundVo> collect = listChallengeRoundVo.stream().sorted(Comparator.comparing(ChallengeRoundVo::getDigg_count).reversed().thenComparing(ChallengeRoundVo::getPlay_count, Comparator.reverseOrder())).collect(Collectors.toList());//先以属性一升序,升序结果进行属性一降序,再进行属性二降序
+        return ResponseJson.success(collect);
+    }
+    /**
+     * 保存活动信息
+     * @param startTime
+     * @param endTime
+     * @param status
+     * @return
+     */
+    @Override
+    public ResponseJson saveActivityTime(String startTime,String endTime,Integer status,Integer authUserId){
+        //如果数据库有值则修改,没值则新增
+        Integer aid = authMapper.checkActivityId();
+        if(aid==null){
+            authMapper.saveActivityInfo(startTime,endTime,status,authUserId);
+        }else {
+            authMapper.upActivityInfo(startTime,endTime,status,authUserId);
+        }
+        return ResponseJson.success();
+    }
+
+    /**
+     * 获取活动信息
+     * @return
+     */
+    @Override
+    public ResponseJson<ChallengeActivityVo> getActivityTime(Integer authUserId){
+         return ResponseJson.success(authMapper.getActivityTime(authUserId));
+    }
+    @Override
+    public boolean getShareId(String shareId){
+        return StringUtils.isNotEmpty(authMapper.getShareId(shareId));
+    }
+    @Override
+    public void savaItemIdByShareId(String shareId,String itemId){
+        authMapper.savaItemIdByShareId(shareId,itemId);
+    }
+    @Override
+    public ResponseJson<ChallengeActivityVo> getActivitty(Integer authUserId){
+        ChallengeActivityVo activityTime = authMapper.getActivityTime(authUserId);
+        Date date=new Date();
+        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String releaseTime = sf.format(date).replace("T", "");
+        if(activityTime!=null){
+            if(activityTime.getStartTime().compareTo(releaseTime)>0){
+                activityTime.setActivityState(0);
+            }else if(activityTime.getStartTime().compareTo(releaseTime)<0&&activityTime.getEndtime().compareTo(releaseTime)>0){
+                activityTime.setActivityState(1);
+            }else {
+                activityTime.setActivityState(2);
+            }
+        }
+        return ResponseJson.success(activityTime);
+    }
 }

+ 67 - 1
src/main/resources/mapper/AuthMapper.xml

@@ -637,5 +637,71 @@
         from cm_brand_auth_user
         where authUserId = #{authUserId}
     </select>
-
+    <insert id="saveVideoInfo">
+        insert into cm_challenge_round(userName,title,ossName,ossUrl,cover,releaseTime,authId,authUserId)
+        values(#{userName},#{title},#{ossName},#{ossUrl},#{cover},#{releaseTime},#{authId},#{authUserId})
+    </insert>
+    <select id="getauthUserId" resultType="java.lang.String">
+        select authUserId
+        from cm_brand_auth
+        where id = #{authId}
+    </select>
+    <select id="getuserName" resultType="java.lang.String">
+        select userName
+        from cm_challenge_round
+        where userName = #{userName}
+    </select>
+    <select id="checkActivityTime" resultType="java.lang.Integer">
+        select id
+        from cm_challenge_activity
+        where startTime  &lt;#{releaseTime}  and  endtime &gt;#{releaseTime} and status=1
+    </select>
+    <select id="getPublishedVideoList" resultType="com.caimei.model.vo.ChallengeRoundVo">
+        select cr.id,cr.userName,cr.itemId,cr.title,cr.ossName,cr.ossUrl,cr.cover,cr.releaseTime,cr.status,cr.shareId,cr.authId
+        from cm_challenge_round cr left join cm_brand_auth cba
+        on cr.authId=cba.id
+               where cr.authUserId=#{authUserId}
+        <if test="clubUserName != null and clubUserName != ''">
+            and (cr.userName like concat('%', #{clubUserName})
+            or  cba.authParty=#{clubUserName})
+        </if>
+        <if test="status != null">
+            and cr.status = #{status}
+        </if>
+    </select>
+    <select id="checkActivityId" resultType="java.lang.Integer">
+        select id
+        from cm_challenge_activity
+    </select>
+    <insert id="saveActivityInfo">
+            insert into cm_challenge_activity(startTime,endtime,status,authUserId)
+            values(#{startTime},#{endTime},#{status},#{authUserId})
+    </insert>
+    <update id="upActivityInfo">
+        update cm_challenge_activity set
+            startTime=#{startTime},
+            endtime=#{endTime},
+            status = #{status}
+        where authUserId=#{authUserId}
+    </update>
+    <select id="getActivityTime" resultType="com.caimei.model.vo.ChallengeActivityVo">
+        select id,startTime,endtime,status,authUserId
+        from cm_challenge_activity
+        where authUserId=#{authUserId}
+    </select>
+    <update id="savaShareIdByAuthId">
+        update cm_challenge_round set
+            shareId=#{shareId}
+        where authId=#{authId}
+    </update>
+    <select id="getShareId" resultType="java.lang.String">
+        select shareId
+        from cm_challenge_round
+        where shareId=#{shareId}
+    </select>
+    <update id="savaItemIdByShareId">
+        update cm_challenge_round set
+            itemId=#{itemId}
+        where shareId=#{shareId}
+    </update>
 </mapper>

+ 1 - 1
src/main/resources/mapper/AuthProductMapper.xml

@@ -534,7 +534,7 @@
         where a.id=#{authId}
     </select>
     <select id="getSnList" resultType="com.caimei.model.po.ProductPo">
-        select a.id as productId,a.authId1 as authId
+        select a.id as productId
         from cm_brand_auth_product a
         where a.snCode=#{sn}
     </select>