fix:添加分页

上级 e96ed8dd
...@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/csdn/user") @RequestMapping("/csdn/user")
...@@ -32,27 +34,29 @@ public class CsdnUserController { ...@@ -32,27 +34,29 @@ public class CsdnUserController {
* *
* @return 所有数据 * @return 所有数据
*/ */
@GetMapping("/page") @PostMapping("/page")
public Result selectAll(@RequestParam Integer page public Result selectAll(@RequestBody CsdnUserInfoQuery query) {
, @RequestParam Integer pageSize final Integer userWeight = query.getUserWeight();
, @RequestParam String userName final String nickName = query.getNickName();
, @RequestParam String nickName) { final String userName = query.getUserName();
Page<CsdnUserInfo> pageParm = new Page<>(); Page<CsdnUserInfo> pageParm = new Page<>();
pageParm.setCurrent(page); pageParm.setCurrent(query.getPage());
pageParm.setSize(pageSize); pageParm.setSize(query.getPageSize());
QueryWrapper<CsdnUserInfo> wrapper = new QueryWrapper<>(); QueryWrapper<CsdnUserInfo> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("user_weight"); wrapper.orderByDesc("user_weight");
wrapper.eq("is_delete", 0); wrapper.eq("is_delete", 0);
if (StringUtils.isNotEmpty(userName)) { if (StringUtils.isNotEmpty(userName)) {
wrapper.eq("user_name", userName); wrapper.eq("user_name", userName);
} }
if (Objects.nonNull(userWeight)) {
wrapper.eq("user_weight", userWeight);
}
if (StringUtils.isNotEmpty(nickName)) { if (StringUtils.isNotEmpty(nickName)) {
wrapper.like("nick_name", nickName); wrapper.like("nick_name", nickName);
} }
return Result.ok(CsdnUserInfoDTO.Converter.INSTANCE.from(this.csdnUserInfoService.page(pageParm, wrapper))); return Result.ok(CsdnUserInfoDTO.Converter.INSTANCE.from(this.csdnUserInfoService.page(pageParm, wrapper)));
} }
/** /**
* 新增用户 * 新增用户
* *
......
package com.kwan.springbootkwan.entity;
import lombok.Data;
@Data
public class BasePage {
private Integer page;
private Integer pageSize;
}
package com.kwan.springbootkwan.entity.query; package com.kwan.springbootkwan.entity.query;
import com.kwan.springbootkwan.entity.BasePage;
import lombok.Data; import lombok.Data;
@Data @Data
public class CsdnUserInfoQuery { public class CsdnUserInfoQuery extends BasePage {
/** /**
* 主键id * 主键id
*/ */
......
...@@ -68,17 +68,16 @@ public class CsdnServiceImpl implements CsdnService { ...@@ -68,17 +68,16 @@ public class CsdnServiceImpl implements CsdnService {
wrapper.eq("is_delete", 0); wrapper.eq("is_delete", 0);
wrapper.eq("comment_status", 9); wrapper.eq("comment_status", 9);
final List<CsdnUserInfo> comments = csdnUserInfoService.list(wrapper); final List<CsdnUserInfo> comments = csdnUserInfoService.list(wrapper);
if (CollectionUtil.isNotEmpty(comments)) { if (CollectionUtil.isEmpty(comments) || comments.size() < 49) {
if (comments.size() >= 49) { //评论
csdnUserInfo.setCommentStatus(CommentStatus.COMMENT_NUM_49.getCode()); final Boolean comment = csdnCommentService.isComment(article, csdnUserInfo);
} else { if (!comment) {
//评论 csdnCommentService.comment(articleId, csdnUserInfo);
final Boolean comment = csdnCommentService.isComment(article, csdnUserInfo);
if (!comment) {
csdnCommentService.comment(articleId, csdnUserInfo);
}
} }
} }
if (CollectionUtil.isNotEmpty(comments) && comments.size() >= 49) {
csdnUserInfo.setCommentStatus(CommentStatus.COMMENT_NUM_49.getCode());
}
//收藏 //收藏
final Boolean collect = csdnCollectService.isCollect(articleId, csdnUserInfo); final Boolean collect = csdnCollectService.isCollect(articleId, csdnUserInfo);
if (!collect) { if (!collect) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册