Commit ba84247c authored by 万成波's avatar 万成波

评论优化

parent 96e2a984
package com.tangguo.common.core.page; package com.tangguo.common.core.page;
import com.github.pagehelper.PageInfo;
import com.tangguo.common.constant.HttpStatus;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -79,4 +82,15 @@ public class TableDataInfo implements Serializable { ...@@ -79,4 +82,15 @@ public class TableDataInfo implements Serializable {
public void setMsg(String msg) { public void setMsg(String msg) {
this.msg = msg; this.msg = msg;
} }
public static TableDataInfo getDataTable(List<?> list) {
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(list);
rspData.setTotal(new PageInfo(list).getTotal());
return rspData;
}
} }
package com.tangguo.controller.mobile; package com.tangguo.controller.mobile;
import com.tangguo.common.core.domain.AjaxResult; import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.mauth.MobileAuth; import com.tangguo.common.mauth.MobileAuth;
import com.tangguo.common.mauth.MobileTokenHelper; import com.tangguo.common.mauth.MobileTokenHelper;
import com.tangguo.common.utils.PageUtils; import com.tangguo.common.utils.PageUtils;
...@@ -51,11 +52,11 @@ public class MBbsMomentController { ...@@ -51,11 +52,11 @@ public class MBbsMomentController {
*/ */
@MobileAuth @MobileAuth
@GetMapping("/moments") @GetMapping("/moments")
public AjaxResult getMoments(String content) { public TableDataInfo getMoments(String content) {
String username = MobileTokenHelper.getUserName(); String username = MobileTokenHelper.getUserName();
PageUtils.clearPage(); PageUtils.clearPage();
List<BbsMomentListVO> moments = this.momentService.getMoments(username, content); List<BbsMomentListVO> moments = this.momentService.getMoments(username, content);
return AjaxResult.success(moments); return TableDataInfo.getDataTable(moments);
} }
...@@ -160,10 +161,10 @@ public class MBbsMomentController { ...@@ -160,10 +161,10 @@ public class MBbsMomentController {
*/ */
@MobileAuth @MobileAuth
@GetMapping("/votes") @GetMapping("/votes")
public AjaxResult getMomentVotes(@RequestParam Long momentId, @RequestParam String optionCode) { public TableDataInfo getMomentVotes(@RequestParam Long momentId, @RequestParam String optionCode) {
PageUtils.startPage(); PageUtils.startPage();
List<BbsVoteVO> dbVotes = this.momentVoteService.getMomentVotes(momentId, optionCode); List<BbsVoteVO> dbVotes = this.momentVoteService.getMomentVotes(momentId, optionCode);
return AjaxResult.success(dbVotes); return TableDataInfo.getDataTable(dbVotes);
} }
...@@ -174,11 +175,11 @@ public class MBbsMomentController { ...@@ -174,11 +175,11 @@ public class MBbsMomentController {
*/ */
@MobileAuth @MobileAuth
@GetMapping("/comments") @GetMapping("/comments")
public AjaxResult getMomentComments(@RequestParam Long momentId) { public TableDataInfo getMomentComments(@RequestParam Long momentId) {
String userName = MobileTokenHelper.getUserName(); String userName = MobileTokenHelper.getUserName();
PageUtils.clearPage(); PageUtils.clearPage();
List<BbsCommentDetailVO> dbComments = this.momentCommentService.getMomentComments(momentId, userName); List<BbsCommentDetailVO> dbComments = this.momentCommentService.getMomentComments(momentId, userName);
return AjaxResult.success(dbComments); return TableDataInfo.getDataTable(dbComments);
} }
......
package com.tangguo.controller.mobile; package com.tangguo.controller.mobile;
import com.tangguo.common.core.domain.AjaxResult; import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.mauth.MobileAuth; import com.tangguo.common.mauth.MobileAuth;
import com.tangguo.common.utils.PageUtils; import com.tangguo.common.utils.PageUtils;
import com.tangguo.common.utils.ValidateOperations; import com.tangguo.common.utils.ValidateOperations;
...@@ -35,10 +36,10 @@ public class MBbsTopicController { ...@@ -35,10 +36,10 @@ public class MBbsTopicController {
*/ */
@MobileAuth @MobileAuth
@GetMapping("/select") @GetMapping("/select")
public AjaxResult getSelectTopics(String name) { public TableDataInfo getSelectTopics(String name) {
PageUtils.startPage(); PageUtils.startPage();
List<BbsTopicListVO> topics = this.topicService.getSelectTopics(name); List<BbsTopicListVO> topics = this.topicService.getSelectTopics(name);
return AjaxResult.success(topics); return TableDataInfo.getDataTable(topics);
} }
...@@ -78,10 +79,10 @@ public class MBbsTopicController { ...@@ -78,10 +79,10 @@ public class MBbsTopicController {
*/ */
@MobileAuth @MobileAuth
@GetMapping("/details") @GetMapping("/details")
public AjaxResult getTopicDetails(@RequestParam Long topicId) { public TableDataInfo getTopicDetails(@RequestParam Long topicId) {
PageUtils.startPage(); PageUtils.startPage();
List<BbsMomentListVO> details = this.topicService.getTopicDetails(topicId); List<BbsMomentListVO> details = this.topicService.getTopicDetails(topicId);
return AjaxResult.success(details); return TableDataInfo.getDataTable(details);
} }
} }
package com.tangguo.controller.mobile; package com.tangguo.controller.mobile;
import com.tangguo.common.core.domain.AjaxResult; import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.mauth.MobileAuth; import com.tangguo.common.mauth.MobileAuth;
import com.tangguo.common.mauth.MobileTokenHelper; import com.tangguo.common.mauth.MobileTokenHelper;
import com.tangguo.common.utils.PageUtils; import com.tangguo.common.utils.PageUtils;
...@@ -79,11 +80,11 @@ public class MBbsUserController { ...@@ -79,11 +80,11 @@ public class MBbsUserController {
*/ */
@MobileAuth @MobileAuth
@GetMapping("/moments") @GetMapping("/moments")
public AjaxResult getUserMoments(String content) { public TableDataInfo getUserMoments(String content) {
String username = MobileTokenHelper.getUserName(); String username = MobileTokenHelper.getUserName();
PageUtils.clearPage(); PageUtils.clearPage();
List<BbsMomentListVO> moments = this.momentService.getUserMoments(username, content); List<BbsMomentListVO> moments = this.momentService.getUserMoments(username, content);
return AjaxResult.success(moments); return TableDataInfo.getDataTable(moments);
} }
} }
...@@ -371,7 +371,11 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -371,7 +371,11 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("操作失败,当前动态未开启评论精选。"); throw new ServiceException("操作失败,当前动态未开启评论精选。");
} }
BbsMomentComment dbComment = this.commentService.getById(bo.getCommentId()); // 动态评论
BbsMomentComment dbComment = this.commentService.getOne(
Wrappers.lambdaQuery(BbsMomentComment.class)
.eq(BbsMomentComment::getMomentId, dbMoment.getId()).eq(BbsMomentComment::getId, bo.getCommentId())
);
if (Objects.isNull(dbComment)) { if (Objects.isNull(dbComment)) {
throw new ServiceException("操作失败,未查询到当前动态评论数据。"); throw new ServiceException("操作失败,未查询到当前动态评论数据。");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment