Commit 8206b6e54fe1d29226d05cc4af2ba07bfe0472fe
1 parent
5142a9d5
update
Showing
1 changed file
with
65 additions
and
3 deletions
src/main/java/com/cnlive/shenhe/controller/VideosController.java
| ... | ... | @@ -7,12 +7,15 @@ import com.cnlive.shenhe.bean.ResponseBean; |
| 7 | 7 | import com.cnlive.shenhe.bean.SessionUser; |
| 8 | 8 | import com.cnlive.shenhe.entity.ShyUsers; |
| 9 | 9 | import com.cnlive.shenhe.entity.ShyVideos; |
| 10 | +import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl; | |
| 10 | 11 | import com.cnlive.shenhe.serviceImpl.UsersServiceImpl; |
| 11 | 12 | import com.cnlive.shenhe.serviceImpl.VideosServiceImpl; |
| 12 | 13 | import com.cnlive.shenhe.utils.AuditPass; |
| 13 | 14 | import com.cnlive.shenhe.utils.CommonConst; |
| 14 | 15 | import com.cnlive.shenhe.utils.CommonUtils; |
| 15 | 16 | import com.github.pagehelper.PageInfo; |
| 17 | +import org.slf4j.Logger; | |
| 18 | +import org.slf4j.LoggerFactory; | |
| 16 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | 20 | import org.springframework.stereotype.Controller; |
| 18 | 21 | import org.springframework.ui.Model; |
| ... | ... | @@ -27,7 +30,7 @@ import java.util.List; |
| 27 | 30 | @Controller |
| 28 | 31 | @RequestMapping("/videos") |
| 29 | 32 | public class VideosController { |
| 30 | - | |
| 33 | + private static Logger logger = LoggerFactory.getLogger(VideosController.class); | |
| 31 | 34 | @Autowired |
| 32 | 35 | AuditPass Pass; |
| 33 | 36 | @Autowired |
| ... | ... | @@ -50,6 +53,11 @@ public class VideosController { |
| 50 | 53 | public ResponseBean shenheInfo(Integer id, String activity_id, Integer state, String attr_tags, String msg, String callback, HttpSession session) { |
| 51 | 54 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 52 | 55 | String userId = sessionUser.getUserId(); |
| 56 | + ShyVideos shyVideos = videosService.selectByPrimaryKey(id); | |
| 57 | + /*if (!shyVideos.getReceive() || CommonUtils.isEmpty(shyVideos.getReceive_user_id()) || !userId.equals(shyVideos.getReceive_user_id())) { | |
| 58 | + logger.error("领取逻辑不符,不能审核,Video_id:{}", shyVideos.getVideo_id()); | |
| 59 | + return new ResponseBean(ErrorEnum.ERROR); | |
| 60 | + }*/ | |
| 53 | 61 | JSONObject result = null; |
| 54 | 62 | try { |
| 55 | 63 | result = Pass.auditPass(activity_id, state, attr_tags, msg, callback); |
| ... | ... | @@ -88,13 +96,20 @@ public class VideosController { |
| 88 | 96 | * @return |
| 89 | 97 | */ |
| 90 | 98 | @GetMapping("/page") |
| 91 | - public Object getListVideos(Model model, String video_title, String start_date, String end_date, Integer state, Integer page, Integer pageSize, String video_priority, String orderByClause, HttpSession session) { | |
| 99 | + public Object getListVideos(Model model, String video_title, String start_date, String end_date, Integer state, Boolean receive, Integer page, Integer pageSize, String video_priority, String orderByClause, HttpSession session) { | |
| 92 | 100 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 93 | 101 | Integer spid = sessionUser.getSpid(); |
| 102 | + String userId = null; | |
| 103 | + //如果是我的待审则获取本人id | |
| 104 | + if (CommonUtils.isNotNull(receive)) { | |
| 105 | + if (receive == true) { | |
| 106 | + userId = sessionUser.getUserId(); | |
| 107 | + } | |
| 108 | + } | |
| 94 | 109 | if (CommonUtils.isNull(page)) page = 1; |
| 95 | 110 | if (CommonUtils.isNull(pageSize)) pageSize = 10; |
| 96 | 111 | if (spid == 0) spid = null; |
| 97 | - PageInfo<ShyVideos> videoPage = videosService.getListContent(video_title, start_date, end_date, state, page, pageSize, video_priority, orderByClause, spid); | |
| 112 | + PageInfo<ShyVideos> videoPage = videosService.getListContent(video_title, start_date, end_date, state, receive, page, pageSize, video_priority, orderByClause, spid, userId); | |
| 98 | 113 | List<ShyVideos> list = videoPage.getList(); |
| 99 | 114 | if (!list.isEmpty()) { |
| 100 | 115 | for (ShyVideos videos : list) { |
| ... | ... | @@ -134,5 +149,52 @@ public class VideosController { |
| 134 | 149 | return "page/videoDetail.html"; |
| 135 | 150 | } |
| 136 | 151 | |
| 152 | + /** | |
| 153 | + * 认领 | |
| 154 | + * | |
| 155 | + * @param ids 根据id认领 | |
| 156 | + * @param num 认领条数 | |
| 157 | + * @param session | |
| 158 | + * @return | |
| 159 | + */ | |
| 160 | + @PostMapping("/receive") | |
| 161 | + @ResponseBody | |
| 162 | + public ResponseBean receive(String ids, Integer num, HttpSession session) { | |
| 163 | + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | |
| 164 | + String userId = sessionUser.getUserId(); | |
| 165 | + Integer spid = sessionUser.getSpid(); | |
| 166 | + //领取时要检查领取的数据是否可以领 | |
| 167 | + if (CommonUtils.isNotEmpty(ids)) { | |
| 168 | + String[] cids = ids.split(","); | |
| 169 | + for (String cid : cids) { | |
| 170 | + ShyVideos shyVideos = videosService.selectByPrimaryKey(Integer.parseInt(cid)); | |
| 171 | + if (CommonUtils.isNotNull(shyVideos)) { | |
| 172 | + if (shyVideos.getState() != CommonConst.AUDIT_INTT || shyVideos.getReceive()) { | |
| 173 | + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "您领取的内容中有已被领取或者已经被审核,请检查并重试"); | |
| 174 | + } | |
| 175 | + } else { | |
| 176 | + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "您领取的内容不存在,请检查并重试"); | |
| 177 | + | |
| 178 | + } | |
| 179 | + } | |
| 180 | + } | |
| 181 | + Integer n = videosService.receive(ids, num, userId, spid); | |
| 182 | + return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "认领到" + n + "条内容"); | |
| 183 | + } | |
| 184 | + | |
| 185 | + | |
| 186 | + @PostMapping("/retReceive") | |
| 187 | + @ResponseBody | |
| 188 | + public ResponseBean retReceive(String ids, HttpSession session) { | |
| 189 | + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | |
| 190 | + String userId = sessionUser.getUserId(); | |
| 191 | + boolean n = videosService.retReceive(ids, userId); | |
| 192 | + if (n) { | |
| 193 | + return new ResponseBean(ErrorEnum.SUCCESS); | |
| 194 | + } else { | |
| 195 | + return new ResponseBean(ErrorEnum.ERROR); | |
| 196 | + } | |
| 197 | + } | |
| 198 | + | |
| 137 | 199 | |
| 138 | 200 | } | ... | ... |