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 48 */
49 49 @GetMapping("/page")
50 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 52 Integer page, Integer pageSize, String orderByClause, HttpSession session) {
53 53 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
54 54 Integer spid = sessionUser.getSpid();
... ... @@ -71,7 +71,7 @@ public class CommentsController {
71 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 75 List<ShyComments> list = commentPage.getList();
76 76 if (!list.isEmpty()) {
77 77 for (ShyComments comment : list) {
... ... @@ -83,8 +83,8 @@ public class CommentsController {
83 83 user.setUser_id(auditor_id);
84 84 user = usersService.select(user);
85 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 88 auditor = userName + email;
89 89 }
90 90 }
... ... @@ -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 158 * @param session
158 159 * @return
159 160 */
160 161 @PostMapping("/receive")
161 162 @ResponseBody
162   - public ResponseBean receive(String ids, Integer num,HttpSession session) {
  163 + public ResponseBean receive(String ids, Integer num, HttpSession session) {
163 164 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
164 165 String userId = sessionUser.getUserId();
165 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 172 @PostMapping("/retReceive")
172 173 @ResponseBody
173   - public ResponseBean retReceive(String ids,HttpSession session) {
  174 + public ResponseBean retReceive(String ids, HttpSession session) {
174 175 SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
175 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 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 225 String[] cids = ids.split(",");
226 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() && userId.equals(shyComments.getReceive_user_id())) {
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 {
234   - result = false;
  232 + if (i == 1) n++;
235 233 }
236 234 }
237   - return result;
  235 + return n;
238 236 }
239 237 }
240 238  
... ...