fix:添加分页

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