我的关注列表分页修改
This commit is contained in:
parent
bd3ef34f33
commit
bc2361b3c4
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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.AppExtCommand;
|
||||||
import com.red.circle.common.business.dto.cmd.IdLongCmd;
|
import com.red.circle.common.business.dto.cmd.IdLongCmd;
|
||||||
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
|
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.framework.web.controller.BaseController;
|
||||||
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicCommentListCO;
|
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.DynamicListCO;
|
||||||
@ -125,8 +126,8 @@ public class DynamicRestController extends BaseController {
|
|||||||
* @eo.method get
|
* @eo.method get
|
||||||
* @eo.request-type formdata
|
* @eo.request-type formdata
|
||||||
*/
|
*/
|
||||||
@GetMapping("/my/list")
|
@GetMapping("/my/page")
|
||||||
public List<DynamicListCO> listMyDynamic(@Validated DynamicMyLimitCmd cmd) {
|
public PageResult<DynamicListCO> listMyDynamic(@Validated DynamicMyLimitCmd cmd) {
|
||||||
return dynamicService.listMyDynamic(cmd);
|
return dynamicService.listMyDynamic(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package com.red.circle.other.app.command.dynamic.query;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
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.convertor.user.UserProfileAppConvertor;
|
||||||
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO;
|
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO;
|
||||||
import com.red.circle.other.app.dto.cmd.dynamic.DynamicMyLimitCmd;
|
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.other.inner.model.dto.user.UserProfileDTO;
|
||||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||||
import com.red.circle.tool.core.num.NumUtils;
|
import com.red.circle.tool.core.num.NumUtils;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -51,18 +50,17 @@ public class DynamicMyQryExe {
|
|||||||
private final UserSubscriptionService userSubscriptionService;
|
private final UserSubscriptionService userSubscriptionService;
|
||||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
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
|
if (CollectionUtils.isEmpty(dynamics.getRecords())) {
|
||||||
.pageByTimeDesc(cmd.getPageNumber(), cmd.getUserId());
|
return PageResult.newPageResult(0);
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(dynamics)) {
|
|
||||||
return Lists.newArrayList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Long> ids = getIds(dynamics);
|
Set<Long> ids = getIds(dynamics);
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
return Lists.newArrayList();
|
return PageResult.newPageResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean isMySubscription = isMySubscription(cmd);
|
Boolean isMySubscription = isMySubscription(cmd);
|
||||||
@ -79,7 +77,7 @@ public class DynamicMyQryExe {
|
|||||||
Map<Long, Integer> commentQuantityMap = dynamicCommentService.mapCommentQuantity(ids);
|
Map<Long, Integer> commentQuantityMap = dynamicCommentService.mapCommentQuantity(ids);
|
||||||
Map<Long, List<DynamicPicture>> pictureMap = dynamicPictureService.mapPreviewGroup(ids);
|
Map<Long, List<DynamicPicture>> pictureMap = dynamicPictureService.mapPreviewGroup(ids);
|
||||||
|
|
||||||
return dynamics.stream().map(dynamic -> {
|
return dynamics.convert(dynamic -> {
|
||||||
|
|
||||||
DynamicListCO result = new DynamicListCO();
|
DynamicListCO result = new DynamicListCO();
|
||||||
processUser(user, result);
|
processUser(user, result);
|
||||||
@ -91,7 +89,7 @@ public class DynamicMyQryExe {
|
|||||||
result.setCommentStrQuantity(NumUtils.formatInt(commentQuantityMap.get(dynamic.getId())));
|
result.setCommentStrQuantity(NumUtils.formatInt(commentQuantityMap.get(dynamic.getId())));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}).collect(Collectors.toList());
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,12 +132,12 @@ public class DynamicMyQryExe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Long> getTagIds(List<DynamicContent> dynamics) {
|
private Set<Long> getTagIds(PageResult<DynamicContent> dynamics) {
|
||||||
return dynamics.stream().map(DynamicContent::getTagId).collect(Collectors.toSet());
|
return dynamics.getRecords().stream().map(DynamicContent::getTagId).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Long> getIds(List<DynamicContent> dynamics) {
|
private Set<Long> getIds(PageResult<DynamicContent> dynamics) {
|
||||||
return dynamics.stream().map(DynamicContent::getId).collect(Collectors.toSet());
|
return dynamics.getRecords().stream().map(DynamicContent::getId).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.AppExtCommand;
|
||||||
import com.red.circle.common.business.dto.cmd.IdLongCmd;
|
import com.red.circle.common.business.dto.cmd.IdLongCmd;
|
||||||
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
|
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.DynamicCheckSendPermissionCmdExe;
|
||||||
import com.red.circle.other.app.command.dynamic.DynamicCommentCmdExe;
|
import com.red.circle.other.app.command.dynamic.DynamicCommentCmdExe;
|
||||||
import com.red.circle.other.app.command.dynamic.DynamicCommentLikeCmdExe;
|
import com.red.circle.other.app.command.dynamic.DynamicCommentLikeCmdExe;
|
||||||
@ -101,7 +102,7 @@ public class DynamicServiceImpl implements DynamicService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DynamicListCO> listMyDynamic(DynamicMyLimitCmd cmd) {
|
public PageResult<DynamicListCO> listMyDynamic(DynamicMyLimitCmd cmd) {
|
||||||
return dynamicMyQryExe.execute(cmd);
|
return dynamicMyQryExe.execute(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package com.red.circle.other.app.dto.cmd.dynamic;
|
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.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 jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -15,14 +18,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class DynamicMyLimitCmd extends AppExtCommand {
|
public class DynamicMyLimitCmd extends AppExtCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* 页码.
|
|
||||||
*
|
|
||||||
* @eo.required
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
private Integer pageNumber;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户id.
|
* 用户id.
|
||||||
*
|
*
|
||||||
@ -31,4 +26,6 @@ public class DynamicMyLimitCmd extends AppExtCommand {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
private PageReq pageReq;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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.AppExtCommand;
|
||||||
import com.red.circle.common.business.dto.cmd.IdLongCmd;
|
import com.red.circle.common.business.dto.cmd.IdLongCmd;
|
||||||
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
|
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.DynamicCommentListCO;
|
||||||
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO;
|
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO;
|
||||||
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicMessageListCO;
|
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最新动态列表.
|
* 最新动态列表.
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.red.circle.other.infra.database.rds.service.dynamic;
|
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.dto.PageResult;
|
||||||
import com.red.circle.framework.mybatis.service.BaseService;
|
import com.red.circle.framework.mybatis.service.BaseService;
|
||||||
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent;
|
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent;
|
||||||
@ -43,7 +44,7 @@ public interface DynamicContentService extends BaseService<DynamicContent> {
|
|||||||
* @param pageNumber 第几页
|
* @param pageNumber 第几页
|
||||||
* @param userId 创建人
|
* @param userId 创建人
|
||||||
*/
|
*/
|
||||||
List<DynamicContent> pageByTimeDesc(Integer pageNumber, Long userId);
|
PageResult<DynamicContent> pageByTimeDesc(Long userId, PageQuery pageQuery);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得分页数据
|
* 获得分页数据
|
||||||
|
|||||||
@ -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.Lists;
|
||||||
import com.google.common.collect.Maps;
|
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.dto.PageResult;
|
||||||
import com.red.circle.framework.mybatis.constant.PageConstant;
|
import com.red.circle.framework.mybatis.constant.PageConstant;
|
||||||
import com.red.circle.framework.mybatis.convertor.MybatisConvertor;
|
import com.red.circle.framework.mybatis.convertor.MybatisConvertor;
|
||||||
@ -73,17 +74,13 @@ public class DynamicContentServiceImpl extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DynamicContent> pageByTimeDesc(Integer pageNumber, Long userId) {
|
public PageResult<DynamicContent> pageByTimeDesc(Long userId, PageQuery pageQuery) {
|
||||||
if (Objects.isNull(pageNumber) || pageNumber < 1) {
|
|
||||||
pageNumber = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return query()
|
return query()
|
||||||
.eq(DynamicContent::getDel, Boolean.FALSE)
|
.eq(DynamicContent::getDel, Boolean.FALSE)
|
||||||
.eq(DynamicContent::getCreateUser, userId)
|
.eq(DynamicContent::getCreateUser, userId)
|
||||||
.orderByDesc(DynamicContent::getCreateTime)
|
.orderByDesc(DynamicContent::getCreateTime)
|
||||||
.last(getPageSql(pageNumber))
|
.page(pageQuery);
|
||||||
.list();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user