我的关注列表分页修改

This commit is contained in:
tianfeng 2026-01-28 11:46:41 +08:00
parent bd3ef34f33
commit bc2361b3c4
9 changed files with 78 additions and 37 deletions

View File

@ -0,0 +1,17 @@
package com.red.circle.common.business.dto;
import com.red.circle.framework.dto.PageQuery;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class PageReq extends PageQuery {
private Integer cursor = 1;
private Integer limit = 20;
private Boolean searchCount = true;
}

View File

@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.IdLongCmd;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicCommentListCO;
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO;
@ -125,8 +126,8 @@ public class DynamicRestController extends BaseController {
* @eo.method get
* @eo.request-type formdata
*/
@GetMapping("/my/list")
public List<DynamicListCO> listMyDynamic(@Validated DynamicMyLimitCmd cmd) {
@GetMapping("/my/page")
public PageResult<DynamicListCO> listMyDynamic(@Validated DynamicMyLimitCmd cmd) {
return dynamicService.listMyDynamic(cmd);
}

View File

@ -3,6 +3,8 @@ package com.red.circle.other.app.command.dynamic.query;
import com.google.common.collect.Lists;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.framework.dto.PageQuery;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO;
import com.red.circle.other.app.dto.cmd.dynamic.DynamicMyLimitCmd;
@ -19,11 +21,8 @@ import com.red.circle.other.infra.database.rds.service.user.user.UserSubscriptio
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.num.NumUtils;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -51,18 +50,17 @@ public class DynamicMyQryExe {
private final UserSubscriptionService userSubscriptionService;
private final UserProfileAppConvertor userProfileAppConvertor;
public List<DynamicListCO> execute(DynamicMyLimitCmd cmd) {
public PageResult<DynamicListCO> execute(DynamicMyLimitCmd cmd) {
PageResult<DynamicContent> dynamics = dynamicContentService
.pageByTimeDesc(cmd.getUserId(), cmd.getPageReq());
List<DynamicContent> dynamics = dynamicContentService
.pageByTimeDesc(cmd.getPageNumber(), cmd.getUserId());
if (CollectionUtils.isEmpty(dynamics)) {
return Lists.newArrayList();
if (CollectionUtils.isEmpty(dynamics.getRecords())) {
return PageResult.newPageResult(0);
}
Set<Long> ids = getIds(dynamics);
if (CollectionUtils.isEmpty(ids)) {
return Lists.newArrayList();
return PageResult.newPageResult(0);
}
Boolean isMySubscription = isMySubscription(cmd);
@ -79,7 +77,7 @@ public class DynamicMyQryExe {
Map<Long, Integer> commentQuantityMap = dynamicCommentService.mapCommentQuantity(ids);
Map<Long, List<DynamicPicture>> pictureMap = dynamicPictureService.mapPreviewGroup(ids);
return dynamics.stream().map(dynamic -> {
return dynamics.convert(dynamic -> {
DynamicListCO result = new DynamicListCO();
processUser(user, result);
@ -91,7 +89,7 @@ public class DynamicMyQryExe {
result.setCommentStrQuantity(NumUtils.formatInt(commentQuantityMap.get(dynamic.getId())));
return result;
}).collect(Collectors.toList());
});
}
@ -134,12 +132,12 @@ public class DynamicMyQryExe {
}
}
private Set<Long> getTagIds(List<DynamicContent> dynamics) {
return dynamics.stream().map(DynamicContent::getTagId).collect(Collectors.toSet());
private Set<Long> getTagIds(PageResult<DynamicContent> dynamics) {
return dynamics.getRecords().stream().map(DynamicContent::getTagId).collect(Collectors.toSet());
}
private Set<Long> getIds(List<DynamicContent> dynamics) {
return dynamics.stream().map(DynamicContent::getId).collect(Collectors.toSet());
private Set<Long> getIds(PageResult<DynamicContent> dynamics) {
return dynamics.getRecords().stream().map(DynamicContent::getId).collect(Collectors.toSet());
}
}

View File

@ -3,6 +3,7 @@ package com.red.circle.other.app.service.dynamic;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.IdLongCmd;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.app.command.dynamic.DynamicCheckSendPermissionCmdExe;
import com.red.circle.other.app.command.dynamic.DynamicCommentCmdExe;
import com.red.circle.other.app.command.dynamic.DynamicCommentLikeCmdExe;
@ -101,7 +102,7 @@ public class DynamicServiceImpl implements DynamicService {
}
@Override
public List<DynamicListCO> listMyDynamic(DynamicMyLimitCmd cmd) {
public PageResult<DynamicListCO> listMyDynamic(DynamicMyLimitCmd cmd) {
return dynamicMyQryExe.execute(cmd);
}

View File

@ -1,6 +1,9 @@
package com.red.circle.other.app.dto.cmd.dynamic;
import com.red.circle.common.business.dto.PageReq;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.core.dto.PageCommand;
import com.red.circle.framework.dto.PageQuery;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -15,14 +18,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class DynamicMyLimitCmd extends AppExtCommand {
/**
* 页码.
*
* @eo.required
*/
@NotNull
private Integer pageNumber;
/**
* 用户id.
*
@ -31,4 +26,6 @@ public class DynamicMyLimitCmd extends AppExtCommand {
@NotNull
private Long userId;
private PageReq pageReq;
}

View File

@ -0,0 +1,28 @@
package com.red.circle.other.app.dto.cmd.dynamic;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.core.dto.PageCommand;
import com.red.circle.framework.dto.PageQuery;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 动态-内容分页.
*
* @author pengshigang
* @since 2022-4-11
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class DynamicPageCmd extends AppExtCommand {
/**
* 用户id.
*
* @eo.required
*/
@NotNull
private Long userId;
}

View File

@ -4,6 +4,7 @@ package com.red.circle.other.app.service.dynamic;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.IdLongCmd;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicCommentListCO;
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO;
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicMessageListCO;
@ -58,7 +59,7 @@ public interface DynamicService {
/**
* 我的动态列表.
*/
List<DynamicListCO> listMyDynamic(DynamicMyLimitCmd cmd);
PageResult<DynamicListCO> listMyDynamic(DynamicMyLimitCmd cmd);
/**
* 最新动态列表.

View File

@ -1,6 +1,7 @@
package com.red.circle.other.infra.database.rds.service.dynamic;
import com.red.circle.framework.dto.PageQuery;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.mybatis.service.BaseService;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent;
@ -43,7 +44,7 @@ public interface DynamicContentService extends BaseService<DynamicContent> {
* @param pageNumber 第几页
* @param userId 创建人
*/
List<DynamicContent> pageByTimeDesc(Integer pageNumber, Long userId);
PageResult<DynamicContent> pageByTimeDesc(Long userId, PageQuery pageQuery);
/**
* 获得分页数据

View File

@ -2,6 +2,7 @@ package com.red.circle.other.infra.database.rds.service.dynamic.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.red.circle.framework.dto.PageQuery;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.mybatis.constant.PageConstant;
import com.red.circle.framework.mybatis.convertor.MybatisConvertor;
@ -73,17 +74,13 @@ public class DynamicContentServiceImpl extends
}
@Override
public List<DynamicContent> pageByTimeDesc(Integer pageNumber, Long userId) {
if (Objects.isNull(pageNumber) || pageNumber < 1) {
pageNumber = 1;
}
public PageResult<DynamicContent> pageByTimeDesc(Long userId, PageQuery pageQuery) {
return query()
.eq(DynamicContent::getDel, Boolean.FALSE)
.eq(DynamicContent::getCreateUser, userId)
.orderByDesc(DynamicContent::getCreateTime)
.last(getPageSql(pageNumber))
.list();
.page(pageQuery);
}
@Override