Commit 5142a9d5789b36fcdb04277745f06ce126691582

Authored by 陈浩
1 parent ecb6f988

update

src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
... ... @@ -60,7 +60,7 @@ public class CommentsServiceImpl {
60 60 }
61 61  
62 62 public boolean impotComments(ShyComments shyComments) {
63   - int result = shyCommentsMapper.insert(shyComments);
  63 + int result = shyCommentsMapper.insertSelective(shyComments);
64 64 if (result == 0) {
65 65 return false;
66 66 }
... ... @@ -74,7 +74,7 @@ public class CommentsServiceImpl {
74 74 return shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
75 75 }
76 76  
77   - public PageInfo<ShyComments> getPage(String activity_id, String content, Integer is_hot, Date start_date, Date end_date, String states,Boolean receive, String auditor, Integer page, Integer pageSize, String orderByClause, Integer spid,String userId) {
  77 + public PageInfo<ShyComments> getPage(String activity_id, String content, Integer is_hot, Date start_date, Date end_date, String states, Boolean receive, String auditor, Integer page, Integer pageSize, String orderByClause, Integer spid, String userId) {
78 78 Example example = new Example(ShyComments.class);
79 79 Example.Criteria criteria = example.createCriteria();
80 80 if (CommonUtils.isNotEmpty(orderByClause)) {
... ... @@ -101,10 +101,10 @@ public class CommentsServiceImpl {
101 101 if (CommonUtils.isNotEmpty(activity_id)) {
102 102 criteria.andLike("activity_id", "%" + activity_id + "%");
103 103 }
104   - if(CommonUtils.isNotNull(receive)){
105   - criteria.andEqualTo("receive",receive);
106   - if(receive){
107   - criteria.andEqualTo("receive_user_id",userId);
  104 + if (CommonUtils.isNotNull(receive)) {
  105 + criteria.andEqualTo("receive", receive);
  106 + if (receive) {
  107 + criteria.andEqualTo("receive_user_id", userId);
108 108 }
109 109 }
110 110  
... ... @@ -146,12 +146,12 @@ public class CommentsServiceImpl {
146 146 String[] commentIds = ids.split(",");
147 147 for (String commentId : commentIds) {
148 148 ShyComments comment = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(commentId));
149   - if(!comment.getReceive() || CommonUtils.isEmpty(comment.getReceive_user_id()) || !userId.equals(comment.getReceive_user_id())){
  149 + if (!comment.getReceive() || CommonUtils.isEmpty(comment.getReceive_user_id()) || !userId.equals(comment.getReceive_user_id())) {
150 150 logger.error("领取逻辑不符,不能审核,activity_id:{}", comment.getActivity_id());
151 151 success = false;
152 152 break;
153 153 }
154   -
  154 +
155 155 JSONObject json = new JSONObject();
156 156 json.put("activity_id", comment.getActivity_id());
157 157 json.put("state", state + 2);
... ... @@ -208,8 +208,8 @@ public class CommentsServiceImpl {
208 208 example.and().andEqualTo("receive", CommonConst.RECEIVE_AFTER);
209 209 if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid);
210 210 List<ShyComments> shyCommentsList = shyCommentsMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num));
211   - if(!shyCommentsList.isEmpty()){
212   - for (ShyComments shyComments:shyCommentsList) {
  211 + if (!shyCommentsList.isEmpty()) {
  212 + for (ShyComments shyComments : shyCommentsList) {
213 213 shyComments.setReceive_user_id(userId);
214 214 shyComments.setReceive(true);
215 215 shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
... ... @@ -223,14 +223,14 @@ public class CommentsServiceImpl {
223 223 public boolean retReceive(String ids, String userId) {
224 224 boolean result = true;
225 225 String[] cids = ids.split(",");
226   - for (String cid:cids) {
  226 + for (String cid : cids) {
227 227 ShyComments shyComments = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(cid));
228   - if(shyComments.getState()==CommonConst.AUDIT_INTT && shyComments.getReceive() && shyComments.getReceive_user_id()==userId){
  228 + if (shyComments.getState() == CommonConst.AUDIT_INTT && shyComments.getReceive() && shyComments.getReceive_user_id() == userId) {
229 229 shyComments.setReceive(CommonConst.RECEIVE_BEFORE);
230 230 shyComments.setReceive_user_id(null);
231 231 int i = shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
232   - if(i!=1)result = false;
233   - }else{
  232 + if (i != 1) result = false;
  233 + } else {
234 234 result = false;
235 235 }
236 236 }
... ...
src/main/java/com/cnlive/shenhe/serviceImpl/VideosServiceImpl.java
... ... @@ -34,16 +34,16 @@ public class VideosServiceImpl {
34 34 ShyUsersMapper shyUsersMapper;
35 35  
36 36 public boolean impotVideo(ShyVideos shyVideos) {
37   - int result = shyVideosMapper.insert(shyVideos);
  37 + int result = shyVideosMapper.insertSelective(shyVideos);
38 38 if (result == 0) {
39 39 return false;
40 40 }
41 41 return true;
42 42 }
43 43  
44   - public List<ShySites> getBusiness(ShySites shySites) {
45   - List<ShySites> sitesList = shySitesMapper.select(shySites);
46   - return sitesList;
  44 + public ShyVideos selectByPrimaryKey(Integer id) {
  45 + ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(id);
  46 + return shyVideos;
47 47 }
48 48  
49 49 public List<ShyVideos> findshyVideo(ShyVideos shyVideos) {
... ... @@ -67,7 +67,7 @@ public class VideosServiceImpl {
67 67 return shyVideosMapper.updateByPrimaryKeySelective(shyVideos);
68 68 }
69 69  
70   - public PageInfo<ShyVideos> getListContent(String video_title, String start_date, String end_date, Integer state, Integer page, Integer pageSize, String video_priority, String orderByClause, Integer spid) {
  70 + public PageInfo<ShyVideos> getListContent(String video_title, String start_date, String end_date, Integer state, Boolean receive, Integer page, Integer pageSize, String video_priority, String orderByClause, Integer spid, String userId) {
71 71 Example example = new Example(ShyVideos.class);
72 72 Example.Criteria criteria = example.createCriteria();
73 73 Example.Criteria criteria2 = example.createCriteria();
... ... @@ -102,6 +102,12 @@ public class VideosServiceImpl {
102 102 if (CommonUtils.isNotNull(spid)) {
103 103 criteria.andEqualTo("spid", spid);
104 104 }
  105 + if (CommonUtils.isNotNull(receive)) {
  106 + criteria.andEqualTo("receive", receive);
  107 + if (receive == true) {
  108 + criteria.andEqualTo("receive_user_id", userId);
  109 + }
  110 + }
105 111 //默认按上传时间倒序排序
106 112 example.setOrderByClause("video_upload_time desc");
107 113 PageHelper.startPage(page, pageSize, true);
... ... @@ -115,7 +121,7 @@ public class VideosServiceImpl {
115 121 if (shyVideos.getState() != CommonConst.AUDIT_INTT) {
116 122 String auditorName = "白名单";
117 123 String auditor_id = shyVideos.getAuditor_id();
118   - if(CommonUtils.isNotEmpty(auditor_id)){
  124 + if (CommonUtils.isNotEmpty(auditor_id)) {
119 125 ShyUsers user = new ShyUsers();
120 126 user.setUser_id(auditor_id);
121 127 user = shyUsersMapper.selectOne(user);
... ... @@ -128,4 +134,56 @@ public class VideosServiceImpl {
128 134 return shyVideos;
129 135 }
130 136  
  137 + public Integer receive(String ids, Integer num, String userId, Integer spid) {
  138 + Integer n = 0;
  139 + if (CommonUtils.isNotEmpty(ids)) {
  140 + String[] cids = ids.split(",");
  141 + for (String cid : cids) {
  142 + ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(Integer.parseInt(cid));
  143 + if (CommonUtils.isNotNull(shyVideos) && shyVideos.getState() == CommonConst.AUDIT_INTT && !shyVideos.getReceive()) {
  144 + shyVideos.setReceive_user_id(userId);
  145 + shyVideos.setReceive(true);
  146 + shyVideosMapper.updateByPrimaryKeySelective(shyVideos);
  147 + n++;
  148 + }
  149 + }
  150 + } else if (CommonUtils.isNotNull(num) && num > 0) {
  151 + Example example = new Example(ShyVideos.class);
  152 + example.setOrderByClause("created_at desc");
  153 + example.and().andEqualTo("state", CommonConst.AUDIT_INTT);
  154 + example.and().andEqualTo("receive", CommonConst.RECEIVE_BEFORE);
  155 + if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid);
  156 + List<ShyVideos> shyCommentsList = shyVideosMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num));
  157 + if (!shyCommentsList.isEmpty()) {
  158 + for (ShyVideos shyComments : shyCommentsList) {
  159 + shyComments.setReceive_user_id(userId);
  160 + shyComments.setReceive(true);
  161 + shyVideosMapper.updateByPrimaryKeySelective(shyComments);
  162 + n++;
  163 + }
  164 + }
  165 + }
  166 + return n;
  167 + }
  168 +
  169 + public boolean retReceive(String ids, String userId) {
  170 + boolean result = true;
  171 + String[] cids = ids.split(",");
  172 + for (String cid : cids) {
  173 + ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(Integer.parseInt(cid));
  174 + if (shyVideos.getState() == CommonConst.AUDIT_INTT && shyVideos.getReceive() && shyVideos.getReceive_user_id() == userId) {
  175 + shyVideos.setReceive(CommonConst.RECEIVE_BEFORE);
  176 + shyVideos.setReceive_user_id(null);
  177 + int i = shyVideosMapper.updateByPrimaryKeySelective(shyVideos);
  178 + if (i != 1) {
  179 + return false;
  180 + }
  181 + } else {
  182 + return false;
  183 + }
  184 + }
  185 + return result;
  186 + }
  187 +
  188 +
131 189 }
... ...