Commit 43d81996c4a3511f611718dc09b81d05fa369517

Authored by 周伟鹏
1 parent 32831ec3

update

src/main/java/com/cnlive/shenhe/controller/CommentsController.java
@@ -48,7 +48,7 @@ public class CommentsController { @@ -48,7 +48,7 @@ public class CommentsController {
48 */ 48 */
49 @GetMapping("/page") 49 @GetMapping("/page")
50 public String getPage(Model model, String activity_id, String content, Integer is_hot, 50 public String getPage(Model model, String activity_id, String content, Integer is_hot,
51 - String start_date, String end_date, String state,Boolean receive, 51 + String start_date, String end_date, String state, Boolean receive,
52 Integer page, Integer pageSize, String orderByClause, HttpSession session) { 52 Integer page, Integer pageSize, String orderByClause, HttpSession session) {
53 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); 53 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
54 Integer spid = sessionUser.getSpid(); 54 Integer spid = sessionUser.getSpid();
@@ -71,7 +71,7 @@ public class CommentsController { @@ -71,7 +71,7 @@ public class CommentsController {
71 } catch (Exception e) { 71 } catch (Exception e) {
72 } 72 }
73 } 73 }
74 - PageInfo<ShyComments> commentPage = commentsService.getPage(activity_id, content, is_hot, sDate, eDate, state,receive, null, page, pageSize, orderByClause, spid,userId); 74 + PageInfo<ShyComments> commentPage = commentsService.getPage(activity_id, content, is_hot, sDate, eDate, state, receive, null, page, pageSize, orderByClause, spid, userId);
75 List<ShyComments> list = commentPage.getList(); 75 List<ShyComments> list = commentPage.getList();
76 if (!list.isEmpty()) { 76 if (!list.isEmpty()) {
77 for (ShyComments comment : list) { 77 for (ShyComments comment : list) {
@@ -83,8 +83,8 @@ public class CommentsController { @@ -83,8 +83,8 @@ public class CommentsController {
83 user.setUser_id(auditor_id); 83 user.setUser_id(auditor_id);
84 user = usersService.select(user); 84 user = usersService.select(user);
85 if (CommonUtils.isNotNull(user)) { 85 if (CommonUtils.isNotNull(user)) {
86 - String userName = CommonUtils.isEmpty(user.getUsername())?"":user.getUsername();  
87 - String email = CommonUtils.isEmpty(user.getEmail())?"":user.getEmail(); 86 + String userName = CommonUtils.isEmpty(user.getUsername()) ? "" : user.getUsername();
  87 + String email = CommonUtils.isEmpty(user.getEmail()) ? "" : user.getEmail();
88 auditor = userName + email; 88 auditor = userName + email;
89 } 89 }
90 } 90 }
@@ -152,33 +152,30 @@ public class CommentsController { @@ -152,33 +152,30 @@ public class CommentsController {
152 152
153 /** 153 /**
154 * 认领 154 * 认领
155 - * @param ids 根据id认领  
156 - * @param num 认领条数 155 + *
  156 + * @param ids 根据id认领
  157 + * @param num 认领条数
157 * @param session 158 * @param session
158 * @return 159 * @return
159 */ 160 */
160 @PostMapping("/receive") 161 @PostMapping("/receive")
161 @ResponseBody 162 @ResponseBody
162 - public ResponseBean receive(String ids, Integer num,HttpSession session) { 163 + public ResponseBean receive(String ids, Integer num, HttpSession session) {
163 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); 164 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
164 String userId = sessionUser.getUserId(); 165 String userId = sessionUser.getUserId();
165 Integer spid = sessionUser.getSpid(); 166 Integer spid = sessionUser.getSpid();
166 - Integer n = commentsService.receive(ids, num, userId,spid);  
167 - return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(),"认领到"+n+"条内容"); 167 + Integer n = commentsService.receive(ids, num, userId, spid);
  168 + return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "认领到" + n + "条内容");
168 } 169 }
169 170
170 171
171 @PostMapping("/retReceive") 172 @PostMapping("/retReceive")
172 @ResponseBody 173 @ResponseBody
173 - public ResponseBean retReceive(String ids,HttpSession session) { 174 + public ResponseBean retReceive(String ids, HttpSession session) {
174 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); 175 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
175 String userId = sessionUser.getUserId(); 176 String userId = sessionUser.getUserId();
176 - boolean n = commentsService.retReceive(ids, userId);  
177 - if(n){  
178 - return new ResponseBean();  
179 - }else{  
180 - return new ResponseBean(ErrorEnum.ERROR);  
181 - } 177 + Integer n = commentsService.retReceive(ids, userId);
  178 + return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "退领了" + n + "条内容");
182 } 179 }
183 180
184 } 181 }
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
@@ -220,21 +220,19 @@ public class CommentsServiceImpl { @@ -220,21 +220,19 @@ public class CommentsServiceImpl {
220 return n; 220 return n;
221 } 221 }
222 222
223 - public boolean retReceive(String ids, String userId) {  
224 - boolean result = true; 223 + public Integer retReceive(String ids, String userId) {
  224 + Integer n = 0;
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() && userId.equals(shyComments.getReceive_user_id())) {
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 {  
234 - result = false; 232 + if (i == 1) n++;
235 } 233 }
236 } 234 }
237 - return result; 235 + return n;
238 } 236 }
239 } 237 }
240 238