Commit d48a002e19c8223a34fbb507a9eaeffc7c5d6b19
1 parent
989bae58
update
Showing
4 changed files
with
90 additions
and
11 deletions
src/main/java/com/cnlive/shenhe/api/CommentsControllerApi.java
| @@ -16,10 +16,6 @@ import org.springframework.stereotype.Controller; | @@ -16,10 +16,6 @@ import org.springframework.stereotype.Controller; | ||
| 16 | import org.springframework.web.bind.annotation.PostMapping; | 16 | import org.springframework.web.bind.annotation.PostMapping; |
| 17 | import org.springframework.web.bind.annotation.RequestMapping; | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
| 18 | import org.springframework.web.bind.annotation.ResponseBody; | 18 | import org.springframework.web.bind.annotation.ResponseBody; |
| 19 | - | ||
| 20 | -import java.sql.Timestamp; | ||
| 21 | -import java.time.Year; | ||
| 22 | -import java.util.Arrays; | ||
| 23 | import java.util.Date; | 19 | import java.util.Date; |
| 24 | import java.util.List; | 20 | import java.util.List; |
| 25 | 21 |
src/main/java/com/cnlive/shenhe/job/CommentsJob.java
| 1 | package com.cnlive.shenhe.job; | 1 | package com.cnlive.shenhe.job; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | -import com.cnlive.shenhe.bean.ErrorEnum; | ||
| 5 | -import com.cnlive.shenhe.bean.ResponseBean; | ||
| 6 | import com.cnlive.shenhe.entity.ShyComments; | 4 | import com.cnlive.shenhe.entity.ShyComments; |
| 7 | import com.cnlive.shenhe.entity.ShySites; | 5 | import com.cnlive.shenhe.entity.ShySites; |
| 8 | import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl; | 6 | import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl; |
| @@ -70,7 +68,15 @@ public class CommentsJob { | @@ -70,7 +68,15 @@ public class CommentsJob { | ||
| 70 | logger.error("评论回调失败,activity_id:{}", comments.getActivity_id()); | 68 | logger.error("评论回调失败,activity_id:{}", comments.getActivity_id()); |
| 71 | } | 69 | } |
| 72 | comments.setState(CommonConst.AUDIT_SUCCESS); | 70 | comments.setState(CommonConst.AUDIT_SUCCESS); |
| 73 | - int i = commentsService.updateComment(json1, null, comments.getAuditor_id()); | 71 | + int i = commentsService.updateComment(comments.getId(), CommonConst.AUDIT_SUCCESS, json1.getString("msg")); |
| 72 | + if (i > 0) { | ||
| 73 | + logger.info("评论修改成功"); | ||
| 74 | + System.out.println("评论修改成功"); | ||
| 75 | + } else { | ||
| 76 | + logger.info("评论修改失败"); | ||
| 77 | + System.out.println("评论修改失败"); | ||
| 78 | + | ||
| 79 | + } | ||
| 74 | } | 80 | } |
| 75 | } | 81 | } |
| 76 | } | 82 | } |
src/main/java/com/cnlive/shenhe/job/VideosJob.java
0 → 100644
| 1 | +package com.cnlive.shenhe.job; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.cnlive.shenhe.entity.ShySites; | ||
| 5 | +import com.cnlive.shenhe.entity.ShyVideos; | ||
| 6 | +import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl; | ||
| 7 | +import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; | ||
| 8 | +import com.cnlive.shenhe.serviceImpl.UsersServiceImpl; | ||
| 9 | +import com.cnlive.shenhe.serviceImpl.VideosServiceImpl; | ||
| 10 | +import com.cnlive.shenhe.utils.AuditPass; | ||
| 11 | +import com.cnlive.shenhe.utils.CommonConst; | ||
| 12 | +import com.cnlive.shenhe.utils.CommonUtils; | ||
| 13 | +import org.slf4j.Logger; | ||
| 14 | +import org.slf4j.LoggerFactory; | ||
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 16 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 17 | +import org.springframework.stereotype.Component; | ||
| 18 | + | ||
| 19 | +import java.util.ArrayList; | ||
| 20 | +import java.util.Arrays; | ||
| 21 | +import java.util.List; | ||
| 22 | + | ||
| 23 | +@Component | ||
| 24 | +public class VideosJob { | ||
| 25 | + private static Logger logger = LoggerFactory.getLogger(CommentsJob.class); | ||
| 26 | + @Autowired | ||
| 27 | + SitesServiceImpl sitesService; | ||
| 28 | + @Autowired | ||
| 29 | + AuditPass Pass; | ||
| 30 | + @Autowired | ||
| 31 | + CommentsServiceImpl commentsService; | ||
| 32 | + @Autowired | ||
| 33 | + UsersServiceImpl usersService; | ||
| 34 | + @Autowired | ||
| 35 | + VideosServiceImpl videosService; | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + @Scheduled(fixedRate = 30 * 60 * 1000) | ||
| 39 | + public void syncComments() { | ||
| 40 | + | ||
| 41 | + //收集免审的spid | ||
| 42 | + List<ShySites> sitesList = sitesService.findAll(); | ||
| 43 | + ArrayList<Integer> sites = new ArrayList<Integer>(); | ||
| 44 | + for (ShySites shySites : sitesList) { | ||
| 45 | + if (CommonUtils.isNotEmpty(shySites.getWrite_business())) { | ||
| 46 | + String[] business = shySites.getWrite_business().split(","); | ||
| 47 | + List<String> asList = Arrays.asList(business); | ||
| 48 | + if (asList.contains(CommonConst.BUSINESS_VIDEO + "")) { | ||
| 49 | + sites.add(shySites.getSpid()); | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + //遍历免审的spid去更改状态值 | ||
| 54 | + ShyVideos shyVideos = new ShyVideos(); | ||
| 55 | + for (int spid : sites) { | ||
| 56 | + shyVideos.setSpid(spid); | ||
| 57 | + List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideos); | ||
| 58 | + if (shyVideosList.size() > 0) { | ||
| 59 | + for (ShyVideos video : shyVideosList) { | ||
| 60 | + JSONObject result = new JSONObject(); | ||
| 61 | + try { | ||
| 62 | + result = Pass.auditPass(video.getVideo_id(), 3, "", "", video.getCallback()); | ||
| 63 | + } catch (Exception e) { | ||
| 64 | + logger.error("点播视频回调失败,activity_id:{}", video.getVideo_id()); | ||
| 65 | + } | ||
| 66 | + int i = videosService.updateVideo(video.getId(), video.getAuditor_id(), CommonConst.AUDIT_SUCCESS, ""); | ||
| 67 | + if (i > 0) { | ||
| 68 | + System.out.println("点播视频更改成功"); | ||
| 69 | + logger.info("点播视频更改成功"); | ||
| 70 | + } else { | ||
| 71 | + logger.info("点播视频更改失败"); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | +} |
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
| @@ -65,11 +65,10 @@ public class CommentsServiceImpl { | @@ -65,11 +65,10 @@ public class CommentsServiceImpl { | ||
| 65 | return true; | 65 | return true; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | - public int updateComment(JSONObject json, Integer id, String auditor_id) { | 68 | + public int updateComment(Integer id, Integer state, String msg) { |
| 69 | ShyComments shyComments = shyCommentsMapper.selectByPrimaryKey(id); | 69 | ShyComments shyComments = shyCommentsMapper.selectByPrimaryKey(id); |
| 70 | - shyComments.setAuditor_id(auditor_id); | ||
| 71 | - shyComments.setState(json.getInteger("state")); | ||
| 72 | - shyComments.setMsg(json.getString("msg")); | 70 | + shyComments.setState(state); |
| 71 | + shyComments.setMsg(msg); | ||
| 73 | return shyCommentsMapper.updateByPrimaryKeySelective(shyComments); | 72 | return shyCommentsMapper.updateByPrimaryKeySelective(shyComments); |
| 74 | } | 73 | } |
| 75 | 74 |