Pārlūkot izejas kodu

1.7.5认证通版本下载视频功能优化

JiangChongBo 2 gadi atpakaļ
vecāks
revīzija
b62576200e

+ 142 - 121
src/main/java/com/caimei/controller/admin/auth/AuthApi.java

@@ -58,6 +58,7 @@ import java.util.*;
 public class AuthApi {
 
     private final AuthService authService;
+
     /**
      * 授权列表
      */
@@ -79,7 +80,7 @@ public class AuthApi {
     @GetMapping("/list")
     public ResponseJson<PageInfo<AuthVo>> getAuthList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
                                                       Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
-                                                      Integer shopAuditStatus, Integer sendStatus,String authCode,
+                                                      Integer shopAuditStatus, Integer sendStatus, String authCode,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
         // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
@@ -93,17 +94,17 @@ public class AuthApi {
         } else if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }
-        return authService.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus,authCode, pageNum, pageSize);
+        return authService.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, authCode, pageNum, pageSize);
     }
 
     /**
      * 授权列表
-     *1.7.4版本
+     * 1.7.4版本
      * 新加两个查询条件
-     *
+     * <p>
      * name 商品名称
      * snCode 商品sn码
-     * **/
+     **/
     @ApiOperation("授权列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
@@ -121,10 +122,10 @@ public class AuthApi {
     })
     @GetMapping("/listAll")
     public ResponseJson<PageInfo<AuthVo>> getAuthListAll(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
-                                                      Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
-                                                      Integer shopAuditStatus, Integer sendStatus, String name, String snCode,
-                                                      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
-                                                      @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+                                                         Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
+                                                         Integer shopAuditStatus, Integer sendStatus, String name, String snCode,
+                                                         @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                         @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
         // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
         if (null != sysUser && 1 != sysUser.getId()) {
             // 获取供应商用户id
@@ -242,8 +243,8 @@ public class AuthApi {
         List<String> bannerList = (List<String>) paramsMap.get("bannerList");
         String authParty = paramsMap.getString("authParty");
         Integer source = paramsMap.getInteger("source");
-        String relationId=paramsMap.getString("relationId");
-        String relationName=paramsMap.getString("relationName");
+        String relationId = paramsMap.getString("relationId");
+        String relationName = paramsMap.getString("relationName");
         if (null == source) {
             // 默认供应商保存
             source = 1;
@@ -287,10 +288,10 @@ public class AuthApi {
         auth.setRelationName(relationName);
         return authService.saveAuth(auth, bannerList, false, source);
     }
+
     /**
      * 添加/编辑授权
      * 1.7.4版本:编辑时新加关联机构操作
-     *
      */
     @ApiOperation("添加/编辑授权")
     @ApiImplicitParam(name = "params", value = "authId:授权id;authParty:授权机构;provinceId;cityId;" +
@@ -336,8 +337,8 @@ public class AuthApi {
         String authCode = paramsMap.getString("authCode");
         String authDateStr = paramsMap.getString("authDate");
         SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
-        String relationId=paramsMap.getString("relationId");
-        String relationName=paramsMap.getString("relationName");
+        String relationId = paramsMap.getString("relationId");
+        String relationName = paramsMap.getString("relationName");
         Date authDate = null;
         if (StringUtils.isNotEmpty(authDateStr)) {
             authDate = format.parse(authDateStr);
@@ -469,24 +470,24 @@ public class AuthApi {
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer authId = paramsMap.getInteger("authId");
         Integer starFlag = paramsMap.getInteger("starFlag");
-        String  starNum=paramsMap.getString("starNum");
+        String starNum = paramsMap.getString("starNum");
         if (null == authId) {
             return ResponseJson.error("机构id不能为空");
         }
         if (null == starFlag) {
             return ResponseJson.error("明星机构标识不能为空");
         }
-        return authService.starAuth(authId, starFlag,starNum);
+        return authService.starAuth(authId, starFlag, starNum);
     }
+
     /**
      * 获取机构关联的机构信息
      * 1.7.4版本:编辑时新加关联机构操作
-     *
      */
     @PostMapping("/product/relation/list")
-    public ResponseJson<List<AuthFormVo>> getRelationgInfo(@CurrentUser SysUser sysUser,@RequestBody String params){
+    public ResponseJson<List<AuthFormVo>> getRelationgInfo(@CurrentUser SysUser sysUser, @RequestBody String params) {
         JSONObject paramsMap = JSONObject.parseObject(params);
-        String  snCode=paramsMap.getString("snCode");
+        String snCode = paramsMap.getString("snCode");
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
@@ -496,15 +497,15 @@ public class AuthApi {
         if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }
-        return authService.getRelationgInfo(snCode,authUserId);
+        return authService.getRelationgInfo(snCode, authUserId);
     }
+
     /**
      * 获取可绑定机构机构信息
      * 1.7.4版本:编辑时新加关联机构操作
-     *
      */
     @GetMapping("/club/bind/list")
-    public ResponseJson<List<AuthFormVo>> getClubBindAuth(@CurrentUser SysUser sysUser){
+    public ResponseJson<List<AuthFormVo>> getClubBindAuth(@CurrentUser SysUser sysUser) {
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
@@ -518,70 +519,75 @@ public class AuthApi {
     }
 //-----------------------------------------------------上传视频至抖音-----------------------------------------------------------------------------------
 
-        /**
-         * 用户扫码授权,获取code值
-         * @param response
-         * @throws IOException
-         */
-        @GetMapping("/check/accesstoken")
-        public ResponseJson getDouYingCode(HttpServletResponse response) throws IOException {
-            return authService.getDouYingCode(response);
-        }
-        /**
-         * 根据用户的code值获取AcessToken
-         * ccode 用户授权登录code
-         **/
-        @GetMapping("/get/douying/acesstoken")
-        public ResponseJson getDouYingAcessToken(String code) throws IOException {
-            return authService.getDouYingAcessToken(code);
-        }
-
-        /**
-         * h5的方式上传视频
-         * @return
-         * @throws IOException
-         */
-        @PostMapping("/upload/video/to/douyin")
-        public ResponseJson getclientToken(@RequestBody String params) throws IOException {
-            JSONObject paramsMap = JSONObject.parseObject(params);
-            String title = paramsMap.getString("title");
-            String videoPath = paramsMap.getString("videoPath");
-            Integer authId=paramsMap.getInteger("authId");
-            return authService.getclientToken( title, videoPath,authId);
-        }
-        /**
-         * 发布视频后通过webhook获取回调数据
-         * @param params
-         * @return
-         */
-        @PostMapping("/webhook")
-        @ResponseBody
-        @WebHooks
-        public Object webhook(@RequestBody String params){
-            JSONObject paramsMap = JSONObject.parseObject(params);
-            System.out.println(paramsMap.getString("item_id"));
-            String content = paramsMap.getString("content");
-            JSONObject contentList = JSONObject.parseObject(content);
-            System.out.println(content);
-            String challenge = contentList.getString("challenge");
-            System.out.println(challenge);
-            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);
-                }
+    /**
+     * 用户扫码授权,获取code值
+     *
+     * @param response
+     * @throws IOException
+     */
+    @GetMapping("/check/accesstoken")
+    public ResponseJson getDouYingCode(HttpServletResponse response) throws IOException {
+        return authService.getDouYingCode(response);
+    }
+
+    /**
+     * 根据用户的code值获取AcessToken
+     * ccode 用户授权登录code
+     **/
+    @GetMapping("/get/douying/acesstoken")
+    public ResponseJson getDouYingAcessToken(String code) throws IOException {
+        return authService.getDouYingAcessToken(code);
+    }
+
+    /**
+     * h5的方式上传视频
+     *
+     * @return
+     * @throws IOException
+     */
+    @PostMapping("/upload/video/to/douyin")
+    public ResponseJson getclientToken(@RequestBody String params) throws IOException {
+        JSONObject paramsMap = JSONObject.parseObject(params);
+        String title = paramsMap.getString("title");
+        String videoPath = paramsMap.getString("videoPath");
+        Integer authId = paramsMap.getInteger("authId");
+        return authService.getclientToken(title, videoPath, authId);
+    }
+
+    /**
+     * 发布视频后通过webhook获取回调数据
+     *
+     * @param params
+     * @return
+     */
+    @PostMapping("/webhook")
+    @ResponseBody
+    @WebHooks
+    public Object webhook(@RequestBody String params) {
+        JSONObject paramsMap = JSONObject.parseObject(params);
+        System.out.println(paramsMap.getString("item_id"));
+        String content = paramsMap.getString("content");
+        JSONObject contentList = JSONObject.parseObject(content);
+        System.out.println(content);
+        String challenge = contentList.getString("challenge");
+        System.out.println(challenge);
+        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);
-            map.put("item_id",itemId);
-            map.put("share_id",shareId);
-            return map;
         }
+        System.out.println(shareId);
+        Map<String, String> map = new HashMap<>();
+        map.put("challenge", challenge);
+        map.put("item_id", itemId);
+        map.put("share_id", shareId);
+        return map;
+    }
 
     /**
      * 把抖音分享视频口令以短信推送给机构
@@ -589,27 +595,27 @@ public class AuthApi {
      * @return
      */
     @PostMapping("/sms/send/douyin")
-    public ResponseJson sms(@RequestBody String params){//String mobile,String content
-         JSONObject jsonObject=JSONObject.parseObject(params);
-         //根据authId获取手机号
-         Integer authId = jsonObject.getInteger("authId");
+    public ResponseJson sms(@RequestBody String params) {//String mobile,String content
+        JSONObject jsonObject = JSONObject.parseObject(params);
+        //根据authId获取手机号
+        Integer authId = jsonObject.getInteger("authId");
         String mobile = authService.getMobileByAuthId(authId);
         //根据authId获取供应商名称
         String authUserName = authService.getAuthUserName(authId);
-        String content=jsonObject.getString("content");
+        String content = jsonObject.getString("content");
 //         String authParty=jsonObject.getString("authParty");
         // 短信类型:1通知短信,2验证码短信,3营销短信
-        String con=content.substring(0,content.indexOf("/")+1);
-        String cs=content.substring(content.indexOf("com")+3);
-         Integer type=1;
-         String kouLin="["+authUserName+"]您在认证通抖音视频挑战赛发布的视频已成功上传至抖音平台,抖音分享口令为:"+con+" https://v.douyin.com"+cs+",您可复制该口令后去抖音平台打开";
+        String con = content.substring(0, content.indexOf("/") + 1);
+        String cs = content.substring(content.indexOf("com") + 3);
+        Integer type = 1;
+        String kouLin = "[" + authUserName + "]您在认证通抖音视频挑战赛发布的视频已成功上传至抖音平台,抖音分享口令为:" + con + " https://v.douyin.com" + cs + ",您可复制该口令后去抖音平台打开";
         Boolean flag = SmsUtils.sendSms(type, mobile, kouLin);
-        if (flag){
+        if (flag) {
             //短信发送成功后,保存口令
-            authService.savaDyCommand(authId,content);
+            authService.savaDyCommand(authId, content);
             return ResponseJson.success();
-        }else{
-            return ResponseJson.error("短信发送失败-----"+mobile);
+        } else {
+            return ResponseJson.error("短信发送失败-----" + mobile);
         }
     }
 
@@ -704,11 +710,12 @@ public class AuthApi {
 
     /**
      * 保存活动信息
+     *
      * @param params
      * @return
      */
     @PostMapping("/save/activity/time")
-    public ResponseJson saveActivityTime(@CurrentUser SysUser sysUser,@RequestBody String params){
+    public ResponseJson saveActivityTime(@CurrentUser SysUser sysUser, @RequestBody String params) {
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
@@ -718,19 +725,21 @@ public class AuthApi {
         if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }
-        JSONObject jsonObject=JSONObject.parseObject(params);
+        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);
+        authService.saveActivityTime(startTime, endTime, status, authUserId);
         return ResponseJson.success();
     }
+
     /**
-     *获取活动信息
+     * 获取活动信息
+     *
      * @return
      */
     @GetMapping("/get/activity/time")
-    public ResponseJson<ChallengeActivityVo> getActivityTime(@CurrentUser SysUser sysUser){
+    public ResponseJson<ChallengeActivityVo> getActivityTime(@CurrentUser SysUser sysUser) {
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
@@ -740,11 +749,12 @@ public class AuthApi {
         if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }
-        return  authService.getActivityTime(authUserId);
+        return authService.getActivityTime(authUserId);
     }
 
     /**
      * 获取已发布视频
+     *
      * @param sysUser
      * @param status
      * @param cursor
@@ -752,8 +762,8 @@ public class AuthApi {
      * @return
      */
     @GetMapping("/get/published/video/list")
-    public ResponseJson<PageInfo<ChallengeRoundVo>> getPublishedVideoList(@CurrentUser SysUser sysUser,Integer status,String mobile,String authParty,Integer cursor,Integer count, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
-                                                                      @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
+    public ResponseJson<PageInfo<ChallengeRoundVo>> getPublishedVideoList(@CurrentUser SysUser sysUser, Integer status, String mobile, String authParty, Integer cursor, Integer count, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                                          @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
@@ -763,20 +773,22 @@ public class AuthApi {
         if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }
-        if(count==null){
-            count=10;
+        if (count == null) {
+            count = 10;
         }
-        if(cursor==null){
-            cursor=0;
+        if (cursor == null) {
+            cursor = 0;
         }
-        return  authService.getPublishedVideo(mobile,authParty,status,cursor,count,authUserId,pageNum,pageSize);
+        return authService.getPublishedVideo(mobile, authParty, status, cursor, count, authUserId, pageNum, pageSize);
     }
+
     /**
      * 获取机构已发布视频的机构下拉列表
+     *
      * @return
      */
     @GetMapping("/get/auth/party/list")
-    public ResponseJson<List<ChallengeRoundVo>> getAuthPartylist(@CurrentUser SysUser sysUser){
+    public ResponseJson<List<ChallengeRoundVo>> getAuthPartylist(@CurrentUser SysUser sysUser) {
         if (null == sysUser) {
             return ResponseJson.error("用户信息异常", null);
         }
@@ -791,29 +803,38 @@ public class AuthApi {
 
     /**
      * 删除视频
+     *
      * @param videoId
      * @return
      */
-     @GetMapping("/del/video")
-    public ResponseJson delVideo(Integer videoId){
+    @GetMapping("/del/video")
+    public ResponseJson delVideo(Integer videoId) {
         //删除阿里云存储视频
-         String ossName = authService.getOssNameAuthId(videoId);
-         OSSUtils.deleteSingleFile(ossName);
-         //删除视频信息
-         authService.deleteVideoByAuthId(videoId);
-         return ResponseJson.success();
+        String ossName = authService.getOssNameAuthId(videoId);
+        OSSUtils.deleteSingleFile(ossName);
+        //删除视频信息
+        authService.deleteVideoByAuthId(videoId);
+        return ResponseJson.success();
     }
 
     /**
      * 下载视频
+     *
      * @param fileId
      * @param response
      * @return
      */
     @GetMapping("/downLoad/chose/zip")
-    public ResponseJson downLoadChoseZip(String fileId,HttpServletResponse response) {
+    public ResponseJson downLoadChoseZip(String fileId, HttpServletResponse response) {
 
-         return authService.downLoadChoseZip(fileId,response);
+        return authService.downLoadChoseZip(fileId, response);
     }
 
-}
+    /**
+     * 根据id获取信息
+     */
+    @GetMapping("/get/info/by/id")
+    public ResponseJson<ChallengeRoundVo> getInfoById(Integer videoId) {
+        return authService.getInfoById(videoId);
+    }
+}

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

@@ -283,5 +283,10 @@ public interface AuthService {
      * @return
      */
     ResponseJson downLoadChoseZip(String fileId,HttpServletResponse response);
+    /**
+     * 根据id获取信息
+     *
+     */
+     ResponseJson<ChallengeRoundVo> getInfoById(Integer videoId);
 
 }

+ 10 - 3
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -1069,7 +1069,7 @@ public class AuthServiceImpl implements AuthService {
         URIBuilder uri = null;
         String schema = null;
         try {
-            uri = new URIBuilder("snssdk1128://openplatform/share");
+            uri = new URIBuilder("snssdk1128://openplatform/share");// snssdk1128://openplatform/share
             uri.addParameter("share_type", "h5");//固定h5
             uri.addParameter("client_key", "awwwvh9tsnvo54w1");//应用唯一标识
             uri.addParameter("nonce_str", noncestr);//随机数(必须和签名时的nonce_str一致)
@@ -1412,9 +1412,9 @@ public class AuthServiceImpl implements AuthService {
         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){
+            if(activityTime.getStartTime().compareTo(releaseTime)>0&&activityTime.getStatus()==0){
                 activityTime.setActivityState(0);
-            }else if(activityTime.getStartTime().compareTo(releaseTime)<0&&activityTime.getEndTime().compareTo(releaseTime)>0){
+            }else if(activityTime.getStartTime().compareTo(releaseTime)<0&&activityTime.getEndTime().compareTo(releaseTime)>0&&activityTime.getStatus()==1){
                 activityTime.setActivityState(1);
             }else {
                 activityTime.setActivityState(2);
@@ -1629,5 +1629,12 @@ public class AuthServiceImpl implements AuthService {
         return null;
 
     }
+    /**
+     * 根据id获取信息
+     *
+     */
+    public ResponseJson<ChallengeRoundVo> getInfoById(Integer videoId) {
+        return ResponseJson.success(authMapper.getChallengeRoundInfo(videoId));
+    }
 
 }