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,7 +60,7 @@ public class CommentsServiceImpl {
60 } 60 }
61 61
62 public boolean impotComments(ShyComments shyComments) { 62 public boolean impotComments(ShyComments shyComments) {
63 - int result = shyCommentsMapper.insert(shyComments); 63 + int result = shyCommentsMapper.insertSelective(shyComments);
64 if (result == 0) { 64 if (result == 0) {
65 return false; 65 return false;
66 } 66 }
@@ -74,7 +74,7 @@ public class CommentsServiceImpl { @@ -74,7 +74,7 @@ public class CommentsServiceImpl {
74 return shyCommentsMapper.updateByPrimaryKeySelective(shyComments); 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 Example example = new Example(ShyComments.class); 78 Example example = new Example(ShyComments.class);
79 Example.Criteria criteria = example.createCriteria(); 79 Example.Criteria criteria = example.createCriteria();
80 if (CommonUtils.isNotEmpty(orderByClause)) { 80 if (CommonUtils.isNotEmpty(orderByClause)) {
@@ -101,10 +101,10 @@ public class CommentsServiceImpl { @@ -101,10 +101,10 @@ public class CommentsServiceImpl {
101 if (CommonUtils.isNotEmpty(activity_id)) { 101 if (CommonUtils.isNotEmpty(activity_id)) {
102 criteria.andLike("activity_id", "%" + activity_id + "%"); 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,12 +146,12 @@ public class CommentsServiceImpl {
146 String[] commentIds = ids.split(","); 146 String[] commentIds = ids.split(",");
147 for (String commentId : commentIds) { 147 for (String commentId : commentIds) {
148 ShyComments comment = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(commentId)); 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 logger.error("领取逻辑不符,不能审核,activity_id:{}", comment.getActivity_id()); 150 logger.error("领取逻辑不符,不能审核,activity_id:{}", comment.getActivity_id());
151 success = false; 151 success = false;
152 break; 152 break;
153 } 153 }
154 - 154 +
155 JSONObject json = new JSONObject(); 155 JSONObject json = new JSONObject();
156 json.put("activity_id", comment.getActivity_id()); 156 json.put("activity_id", comment.getActivity_id());
157 json.put("state", state + 2); 157 json.put("state", state + 2);
@@ -208,8 +208,8 @@ public class CommentsServiceImpl { @@ -208,8 +208,8 @@ public class CommentsServiceImpl {
208 example.and().andEqualTo("receive", CommonConst.RECEIVE_AFTER); 208 example.and().andEqualTo("receive", CommonConst.RECEIVE_AFTER);
209 if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid); 209 if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid);
210 List<ShyComments> shyCommentsList = shyCommentsMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num)); 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 shyComments.setReceive_user_id(userId); 213 shyComments.setReceive_user_id(userId);
214 shyComments.setReceive(true); 214 shyComments.setReceive(true);
215 shyCommentsMapper.updateByPrimaryKeySelective(shyComments); 215 shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
@@ -223,14 +223,14 @@ public class CommentsServiceImpl { @@ -223,14 +223,14 @@ public class CommentsServiceImpl {
223 public boolean retReceive(String ids, String userId) { 223 public boolean retReceive(String ids, String userId) {
224 boolean result = true; 224 boolean result = true;
225 String[] cids = ids.split(","); 225 String[] cids = ids.split(",");
226 - for (String cid:cids) { 226 + for (String cid : cids) {
227 ShyComments shyComments = shyCommentsMapper.selectByPrimaryKey(Integer.parseInt(cid)); 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 shyComments.setReceive(CommonConst.RECEIVE_BEFORE); 229 shyComments.setReceive(CommonConst.RECEIVE_BEFORE);
230 shyComments.setReceive_user_id(null); 230 shyComments.setReceive_user_id(null);
231 int i = shyCommentsMapper.updateByPrimaryKeySelective(shyComments); 231 int i = shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
232 - if(i!=1)result = false;  
233 - }else{ 232 + if (i != 1) result = false;
  233 + } else {
234 result = false; 234 result = false;
235 } 235 }
236 } 236 }
src/main/java/com/cnlive/shenhe/serviceImpl/VideosServiceImpl.java
@@ -34,16 +34,16 @@ public class VideosServiceImpl { @@ -34,16 +34,16 @@ public class VideosServiceImpl {
34 ShyUsersMapper shyUsersMapper; 34 ShyUsersMapper shyUsersMapper;
35 35
36 public boolean impotVideo(ShyVideos shyVideos) { 36 public boolean impotVideo(ShyVideos shyVideos) {
37 - int result = shyVideosMapper.insert(shyVideos); 37 + int result = shyVideosMapper.insertSelective(shyVideos);
38 if (result == 0) { 38 if (result == 0) {
39 return false; 39 return false;
40 } 40 }
41 return true; 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 public List<ShyVideos> findshyVideo(ShyVideos shyVideos) { 49 public List<ShyVideos> findshyVideo(ShyVideos shyVideos) {
@@ -67,7 +67,7 @@ public class VideosServiceImpl { @@ -67,7 +67,7 @@ public class VideosServiceImpl {
67 return shyVideosMapper.updateByPrimaryKeySelective(shyVideos); 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 Example example = new Example(ShyVideos.class); 71 Example example = new Example(ShyVideos.class);
72 Example.Criteria criteria = example.createCriteria(); 72 Example.Criteria criteria = example.createCriteria();
73 Example.Criteria criteria2 = example.createCriteria(); 73 Example.Criteria criteria2 = example.createCriteria();
@@ -102,6 +102,12 @@ public class VideosServiceImpl { @@ -102,6 +102,12 @@ public class VideosServiceImpl {
102 if (CommonUtils.isNotNull(spid)) { 102 if (CommonUtils.isNotNull(spid)) {
103 criteria.andEqualTo("spid", spid); 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 example.setOrderByClause("video_upload_time desc"); 112 example.setOrderByClause("video_upload_time desc");
107 PageHelper.startPage(page, pageSize, true); 113 PageHelper.startPage(page, pageSize, true);
@@ -115,7 +121,7 @@ public class VideosServiceImpl { @@ -115,7 +121,7 @@ public class VideosServiceImpl {
115 if (shyVideos.getState() != CommonConst.AUDIT_INTT) { 121 if (shyVideos.getState() != CommonConst.AUDIT_INTT) {
116 String auditorName = "白名单"; 122 String auditorName = "白名单";
117 String auditor_id = shyVideos.getAuditor_id(); 123 String auditor_id = shyVideos.getAuditor_id();
118 - if(CommonUtils.isNotEmpty(auditor_id)){ 124 + if (CommonUtils.isNotEmpty(auditor_id)) {
119 ShyUsers user = new ShyUsers(); 125 ShyUsers user = new ShyUsers();
120 user.setUser_id(auditor_id); 126 user.setUser_id(auditor_id);
121 user = shyUsersMapper.selectOne(user); 127 user = shyUsersMapper.selectOne(user);
@@ -128,4 +134,56 @@ public class VideosServiceImpl { @@ -128,4 +134,56 @@ public class VideosServiceImpl {
128 return shyVideos; 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 }