Commit 49306b4e77099de5b89fb9407c91ca835ebdfef4
1 parent
e0af38fb
音频数据认领功能
Showing
4 changed files
with
74 additions
and
4 deletions
src/main/java/com/cnlive/shenhe/api/AudioControllerApi.java
| @@ -68,6 +68,7 @@ public class AudioControllerApi { | @@ -68,6 +68,7 @@ public class AudioControllerApi { | ||
| 68 | return new ResponseBean(ErrorEnum.SUCCESS); | 68 | return new ResponseBean(ErrorEnum.SUCCESS); |
| 69 | } | 69 | } |
| 70 | shyAudio.setCreateTime(new Date()); | 70 | shyAudio.setCreateTime(new Date()); |
| 71 | + shyAudio.setState(0); | ||
| 71 | audioService.importAudioMsg(shyAudio); | 72 | audioService.importAudioMsg(shyAudio); |
| 72 | } catch (Exception e) { | 73 | } catch (Exception e) { |
| 73 | e.printStackTrace(); | 74 | e.printStackTrace(); |
src/main/java/com/cnlive/shenhe/controller/AudioController.java
| 1 | package com.cnlive.shenhe.controller; | 1 | package com.cnlive.shenhe.controller; |
| 2 | 2 | ||
| 3 | +import com.cnlive.shenhe.bean.ErrorEnum; | ||
| 4 | +import com.cnlive.shenhe.bean.ResponseBean; | ||
| 3 | import com.cnlive.shenhe.bean.SessionUser; | 5 | import com.cnlive.shenhe.bean.SessionUser; |
| 4 | import com.cnlive.shenhe.entity.ShyAudio; | 6 | import com.cnlive.shenhe.entity.ShyAudio; |
| 5 | import com.cnlive.shenhe.entity.ShySites; | 7 | import com.cnlive.shenhe.entity.ShySites; |
| 6 | import com.cnlive.shenhe.entity.ShyUsers; | 8 | import com.cnlive.shenhe.entity.ShyUsers; |
| 9 | +import com.cnlive.shenhe.entity.ShyVideos; | ||
| 7 | import com.cnlive.shenhe.serviceImpl.AudioServiceImpl; | 10 | import com.cnlive.shenhe.serviceImpl.AudioServiceImpl; |
| 8 | import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; | 11 | import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; |
| 9 | import com.cnlive.shenhe.serviceImpl.UsersServiceImpl; | 12 | import com.cnlive.shenhe.serviceImpl.UsersServiceImpl; |
| @@ -16,7 +19,9 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -16,7 +19,9 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
| 16 | import org.springframework.stereotype.Controller; | 19 | import org.springframework.stereotype.Controller; |
| 17 | import org.springframework.ui.Model; | 20 | import org.springframework.ui.Model; |
| 18 | import org.springframework.web.bind.annotation.GetMapping; | 21 | import org.springframework.web.bind.annotation.GetMapping; |
| 22 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 19 | import org.springframework.web.bind.annotation.RequestMapping; | 23 | import org.springframework.web.bind.annotation.RequestMapping; |
| 24 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
| 20 | 25 | ||
| 21 | import javax.servlet.http.HttpSession; | 26 | import javax.servlet.http.HttpSession; |
| 22 | import java.util.List; | 27 | import java.util.List; |
| @@ -127,4 +132,29 @@ public class AudioController extends BaseController { | @@ -127,4 +132,29 @@ public class AudioController extends BaseController { | ||
| 127 | return "page/audio.html"; | 132 | return "page/audio.html"; |
| 128 | } | 133 | } |
| 129 | 134 | ||
| 135 | + | ||
| 136 | + @PostMapping("/receive") | ||
| 137 | + @ResponseBody | ||
| 138 | + public ResponseBean receive(String ids, Integer num, HttpSession session) { | ||
| 139 | + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | ||
| 140 | + String userId = sessionUser.getUserId(); | ||
| 141 | + Integer spid = sessionUser.getSpid(); | ||
| 142 | + //领取时要检查领取的数据是否可以领 | ||
| 143 | + if (CommonUtils.isNotEmpty(ids)) { | ||
| 144 | + String[] cids = ids.split(","); | ||
| 145 | + for (String cid : cids) { | ||
| 146 | + ShyAudio shyAudio = audioService.selectByPrimaryKey(Integer.parseInt(cid)); | ||
| 147 | + if (CommonUtils.isNotNull(shyAudio)) { | ||
| 148 | + if (shyAudio.getState() != CommonConst.AUDIT_INTT || shyAudio.getReceive()==CommonConst.RECEIVE_AFTER) { | ||
| 149 | + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "您领取的内容中有已被领取或者已经被审核,请检查并重试"); | ||
| 150 | + } | ||
| 151 | + } else { | ||
| 152 | + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "您领取的内容不存在,请检查并重试"); | ||
| 153 | + | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + Integer n = audioService.receive(ids, num, userId, spid); | ||
| 158 | + return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "认领到" + n + "条内容"); | ||
| 159 | + } | ||
| 130 | } | 160 | } |
src/main/java/com/cnlive/shenhe/serviceImpl/AudioServiceImpl.java
| 1 | package com.cnlive.shenhe.serviceImpl; | 1 | package com.cnlive.shenhe.serviceImpl; |
| 2 | 2 | ||
| 3 | import com.cnlive.shenhe.entity.ShyAudio; | 3 | import com.cnlive.shenhe.entity.ShyAudio; |
| 4 | +import com.cnlive.shenhe.entity.ShyVideos; | ||
| 4 | import com.cnlive.shenhe.mapper.ShyAudioMapper; | 5 | import com.cnlive.shenhe.mapper.ShyAudioMapper; |
| 5 | import com.cnlive.shenhe.utils.CommonConst; | 6 | import com.cnlive.shenhe.utils.CommonConst; |
| 6 | import com.cnlive.shenhe.utils.CommonUtils; | 7 | import com.cnlive.shenhe.utils.CommonUtils; |
| 7 | import com.github.pagehelper.PageHelper; | 8 | import com.github.pagehelper.PageHelper; |
| 8 | import com.github.pagehelper.PageInfo; | 9 | import com.github.pagehelper.PageInfo; |
| 10 | +import org.apache.ibatis.session.RowBounds; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 11 | import tk.mybatis.mapper.entity.Example; | 13 | import tk.mybatis.mapper.entity.Example; |
| @@ -33,6 +35,43 @@ public class AudioServiceImpl { | @@ -33,6 +35,43 @@ public class AudioServiceImpl { | ||
| 33 | return shyAudioMapper.updateByPrimaryKeySelective(ShyAudio); | 35 | return shyAudioMapper.updateByPrimaryKeySelective(ShyAudio); |
| 34 | } | 36 | } |
| 35 | 37 | ||
| 38 | + public ShyAudio selectByPrimaryKey(Integer id) { | ||
| 39 | + ShyAudio shyAudio = shyAudioMapper.selectByPrimaryKey(id); | ||
| 40 | + return shyAudio; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public Integer receive(String ids, Integer num, String userId, Integer spid) { | ||
| 44 | + Integer n = 0; | ||
| 45 | + if (CommonUtils.isNotEmpty(ids)) { | ||
| 46 | + String[] cids = ids.split(","); | ||
| 47 | + for (String cid : cids) { | ||
| 48 | + ShyAudio shyAudio = shyAudioMapper.selectByPrimaryKey(Integer.parseInt(cid)); | ||
| 49 | + if (CommonUtils.isNotNull(shyAudio) && shyAudio.getState() == CommonConst.AUDIT_INTT && shyAudio.getReceive()==CommonConst.RECEIVE_BEFORE) { | ||
| 50 | + shyAudio.setReceive_user_id(userId); | ||
| 51 | + shyAudio.setReceive(CommonConst.RECEIVE_AFTER); | ||
| 52 | + shyAudioMapper.updateByPrimaryKeySelective(shyAudio); | ||
| 53 | + n++; | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + } else if (CommonUtils.isNotNull(num) && num > 0) { | ||
| 57 | + Example example = new Example(ShyAudio.class); | ||
| 58 | + example.setOrderByClause("createTime desc"); | ||
| 59 | + example.and().andEqualTo("state", CommonConst.AUDIT_INTT); | ||
| 60 | + example.and().andEqualTo("receive", CommonConst.RECEIVE_BEFORE); | ||
| 61 | + if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid); | ||
| 62 | + List<ShyAudio> shyCommentsList = shyAudioMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num)); | ||
| 63 | + if (!shyCommentsList.isEmpty()) { | ||
| 64 | + for (ShyAudio shyComments : shyCommentsList) { | ||
| 65 | + shyComments.setReceive_user_id(userId); | ||
| 66 | + shyComments.setReceive(CommonConst.RECEIVE_AFTER); | ||
| 67 | + shyAudioMapper.updateByPrimaryKeySelective(shyComments); | ||
| 68 | + n++; | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + return n; | ||
| 73 | + } | ||
| 74 | + | ||
| 36 | //分页查询音频数据 | 75 | //分页查询音频数据 |
| 37 | public PageInfo<ShyAudio> getListContent(String video_title, String start_date, String end_date, Integer state, Integer receive, Integer page, Integer pageSize, String video_priority, String orderByClause, Integer spid, String userId, String sp_Id) { | 76 | public PageInfo<ShyAudio> getListContent(String video_title, String start_date, String end_date, Integer state, Integer receive, Integer page, Integer pageSize, String video_priority, String orderByClause, Integer spid, String userId, String sp_Id) { |
| 38 | Example example = new Example(ShyAudio.class); | 77 | Example example = new Example(ShyAudio.class); |
src/main/resources/templates/page/audio.html
| @@ -258,13 +258,13 @@ | @@ -258,13 +258,13 @@ | ||
| 258 | <button class="btn btn-info btn-sm" th:style="${state1 eq '0' && receive1 eq 'false'} ? 'display: none ' : ' '">查看</button> | 258 | <button class="btn btn-info btn-sm" th:style="${state1 eq '0' && receive1 eq 'false'} ? 'display: none ' : ' '">查看</button> |
| 259 | </a> | 259 | </a> |
| 260 | <span th:if="${audio.state==0 and audio.receive==0}"> </span> | 260 | <span th:if="${audio.state==0 and audio.receive==0}"> </span> |
| 261 | - <a th:href="@{'javascript:applyReceive('+${video.id}+')'}" | 261 | + <a th:href="@{'javascript:applyReceive('+${audio.id}+')'}" |
| 262 | th:if="${audio.state==0 and audio.receive==0}"> | 262 | th:if="${audio.state==0 and audio.receive==0}"> |
| 263 | <button class="btn btn-primary btn-sm">认领</button> | 263 | <button class="btn btn-primary btn-sm">认领</button> |
| 264 | </a> | 264 | </a> |
| 265 | - <span th:if="${audio.state==0 and audio.receive==1 and session.sessionUser.userId==video.receive_user_id}"> </span> | ||
| 266 | - <a th:href="@{'javascript:applyRetReceive('+${video.id}+')'}" | ||
| 267 | - th:if="${audio.state==0 and audio.receive==1 and session.sessionUser.userId==video.receive_user_id}"> | 265 | + <span th:if="${audio.state==0 and audio.receive==1 and session.sessionUser.userId==audio.receive_user_id}"> </span> |
| 266 | + <a th:href="@{'javascript:applyRetReceive('+${audio.id}+')'}" | ||
| 267 | + th:if="${audio.state==0 and audio.receive==1 and session.sessionUser.userId==audio.receive_user_id}"> | ||
| 268 | <button class="btn btn-warning btn-sm">退领</button> | 268 | <button class="btn btn-warning btn-sm">退领</button> |
| 269 | </a> | 269 | </a> |
| 270 | </td> | 270 | </td> |