动态相关列表分页修改
This commit is contained in:
parent
bc2361b3c4
commit
33e0ab816e
@ -34,15 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 动态 前端控制器.
|
||||
* </p>
|
||||
*
|
||||
* @author pengshigang
|
||||
* @eo.api-type http
|
||||
* @eo.groupName 动态服务
|
||||
* @eo.path /dynamic
|
||||
* @since 2022-04-14
|
||||
* 动态相关接口
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -114,7 +106,7 @@ public class DynamicRestController extends BaseController {
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@GetMapping("/list/follow")
|
||||
public List<DynamicListCO> listDynamicFollow(@Validated DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicListCO> listDynamicFollow(@Validated DynamicLimitCmd cmd) {
|
||||
return dynamicService.listDynamicFollow(cmd);
|
||||
}
|
||||
|
||||
@ -140,7 +132,7 @@ public class DynamicRestController extends BaseController {
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@GetMapping("/list/latest")
|
||||
public List<DynamicListCO> listDynamicLatest(@Validated DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicListCO> listDynamicLatest(@Validated DynamicLimitCmd cmd) {
|
||||
return dynamicService.listDynamicLatest(cmd);
|
||||
}
|
||||
|
||||
@ -248,7 +240,7 @@ public class DynamicRestController extends BaseController {
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@GetMapping("/list/message")
|
||||
public List<DynamicMessageListCO> listDynamicMessage(@Validated DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicMessageListCO> listDynamicMessage(@Validated DynamicLimitCmd cmd) {
|
||||
return dynamicService.listDynamicMessage(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.red.circle.other.app.command.dynamic.query;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
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.DynamicLimitCmd;
|
||||
@ -58,33 +59,32 @@ public class DynamicFollowQryExe {
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
private final UserSubscriptionService userSubscriptionService;
|
||||
|
||||
public List<DynamicListCO> execute(DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicListCO> execute(DynamicLimitCmd cmd) {
|
||||
|
||||
// 获取关注人列表
|
||||
List<UserSubscription> userSubscriptions = userSubscriptionService
|
||||
.listByUserId(cmd.requiredReqUserId(), null, null);
|
||||
|
||||
if (CollectionUtils.isEmpty(userSubscriptions)) {
|
||||
return Lists.newArrayList();
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
List<Long> list = userSubscriptions.stream().map(UserSubscription::getSubscribeUserId).toList();
|
||||
List<DynamicTimeline> timelines = dynamicTimelineService
|
||||
PageResult<DynamicTimeline> timelines = dynamicTimelineService
|
||||
.pageByTimeDesc(list, userRegionGateway.getRegionId(cmd.getReqUserId()),
|
||||
cmd.getPageNumber(), Boolean.TRUE);
|
||||
cmd.getPageReq(), Boolean.TRUE);
|
||||
|
||||
// List<DynamicTimeline> timelines = getPageByTimeDesc(cmd);
|
||||
if (CollectionUtils.isEmpty(timelines)) {
|
||||
return Lists.newArrayList();
|
||||
if (CollectionUtils.isEmpty(timelines.getRecords())) {
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
|
||||
Set<Long> contentIds = getContentIds(timelines);
|
||||
if (CollectionUtils.isEmpty(contentIds)) {
|
||||
return Lists.newArrayList();
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
List<DynamicContent> contentList = dynamicContentService.listByIds(contentIds);
|
||||
Set<Long> userIds = getUserIds(contentList);
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return Lists.newArrayList();
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
|
||||
//自己是否已点赞
|
||||
@ -97,7 +97,7 @@ public class DynamicFollowQryExe {
|
||||
Map<Long, Integer> commentQuantityMap = dynamicCommentService.mapCommentQuantity(contentIds);
|
||||
Map<Long, List<DynamicPicture>> pictureMap = dynamicPictureService.mapPreviewGroup(contentIds);
|
||||
|
||||
return timelines.stream().map(timeline -> {
|
||||
return timelines.convert(timeline -> {
|
||||
|
||||
DynamicContent dynamic = contentMap.get(timeline.getDynamicContentId());
|
||||
if (Objects.isNull(dynamic) || dynamic.getDel()) {
|
||||
@ -124,16 +124,10 @@ public class DynamicFollowQryExe {
|
||||
result.setCommentStrQuantity(NumUtils.formatInt(commentQuantityMap.get(dynamic.getId())));
|
||||
|
||||
return result;
|
||||
}).filter(Objects::nonNull).toList();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private List<DynamicTimeline> getPageByTimeDesc(DynamicLimitCmd cmd) {
|
||||
return dynamicTimelineService
|
||||
.pageByTimeDesc(userRegionGateway.getRegionId(cmd.getReqUserId()),
|
||||
cmd.getPageNumber(), cmd.getReqUserId(), Boolean.FALSE);
|
||||
}
|
||||
|
||||
private Map<Long, Boolean> getLikeMap(DynamicLimitCmd cmd, Set<Long> contentIds) {
|
||||
return dynamicLikeService
|
||||
.mapByContentIdsByUserId(contentIds, cmd.getReqUserId());
|
||||
@ -175,8 +169,8 @@ public class DynamicFollowQryExe {
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private Set<Long> getContentIds(List<DynamicTimeline> dynamics) {
|
||||
return dynamics.stream().map(DynamicTimeline::getDynamicContentId).collect(Collectors.toSet());
|
||||
private Set<Long> getContentIds(PageResult<DynamicTimeline> dynamics) {
|
||||
return dynamics.getRecords().stream().map(DynamicTimeline::getDynamicContentId).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private Map<Long, DynamicContent> mapDynamicContent(List<DynamicContent> contents) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.red.circle.other.app.command.dynamic.query;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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.DynamicLimitCmd;
|
||||
@ -51,20 +52,20 @@ public class DynamicLatestQryExe {
|
||||
private final UserSubscriptionService userSubscriptionService;
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
|
||||
public List<DynamicListCO> execute(DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicListCO> execute(DynamicLimitCmd cmd) {
|
||||
|
||||
List<DynamicContent> dynamics = dynamicContentService
|
||||
.pageByTimeDesc(cmd.getPageNumber(), userRegionGateway.getRegionId(cmd.getReqUserId()),
|
||||
PageResult<DynamicContent> dynamics = dynamicContentService
|
||||
.pageByTimeDesc(cmd.getPageReq(), userRegionGateway.getRegionId(cmd.getReqUserId()),
|
||||
cmd.requireReqSysOrigin());
|
||||
|
||||
if (CollectionUtils.isEmpty(dynamics)) {
|
||||
return Lists.newArrayList();
|
||||
if (CollectionUtils.isEmpty(dynamics.getRecords())) {
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
|
||||
Set<Long> ids = getIds(dynamics);
|
||||
Set<Long> userIds = getUserIds(dynamics);
|
||||
if (CollectionUtils.isEmpty(ids) || CollectionUtils.isEmpty(userIds)) {
|
||||
return Lists.newArrayList();
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
|
||||
//自己是否已点赞
|
||||
@ -77,7 +78,7 @@ public class DynamicLatestQryExe {
|
||||
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();
|
||||
UserProfileDTO userProfile = userProfileMap.get(dynamic.getCreateUser());
|
||||
@ -91,7 +92,7 @@ public class DynamicLatestQryExe {
|
||||
result.setCommentStrQuantity(NumUtils.formatInt(commentQuantityMap.get(dynamic.getId())));
|
||||
|
||||
return result;
|
||||
}).collect(Collectors.toList());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -134,17 +135,17 @@ public class DynamicLatestQryExe {
|
||||
}
|
||||
}
|
||||
|
||||
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> getUserIds(List<DynamicContent> dynamics) {
|
||||
return dynamics.stream().map(DynamicContent::getCreateUser)
|
||||
private Set<Long> getUserIds(PageResult<DynamicContent> dynamics) {
|
||||
return dynamics.getRecords().stream().map(DynamicContent::getCreateUser)
|
||||
.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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.red.circle.other.app.command.dynamic.query;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.red.circle.common.business.enums.DynamicMessageEnum;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.other.app.dto.clientobject.dynamic.DynamicMessageListCO;
|
||||
import com.red.circle.other.app.dto.cmd.dynamic.DynamicLimitCmd;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
@ -35,16 +36,17 @@ public class DynamicMessageQryExe {
|
||||
private final DynamicContentService dynamicContentService;
|
||||
private final DynamicMessageService dynamicMessageService;
|
||||
|
||||
public List<DynamicMessageListCO> execute(DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicMessageListCO> execute(DynamicLimitCmd cmd) {
|
||||
|
||||
List<DynamicMessage> messages = getMessages(cmd);
|
||||
if (CollectionUtils.isEmpty(messages)) {
|
||||
return Lists.newArrayList();
|
||||
PageResult<DynamicMessage> messages = getMessages(cmd);
|
||||
if (CollectionUtils.isEmpty(messages.getRecords())) {
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
|
||||
Map<Long, UserProfile> userMap = userProfileGateway.mapByUserIds(getUserIds(messages));
|
||||
Map<Long, DynamicContent> contentMap = getContentMap(messages);
|
||||
|
||||
return messages.stream().map(message -> {
|
||||
return messages.convert(message -> {
|
||||
|
||||
DynamicContent dynamicContent = contentMap.get(message.getDynamicContentId());
|
||||
if (Objects.isNull(dynamicContent)) {
|
||||
@ -72,23 +74,23 @@ public class DynamicMessageQryExe {
|
||||
messageCO.setUserNickname(user.getUserNickname());
|
||||
return messageCO;
|
||||
|
||||
}).filter(Objects::nonNull).toList();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private Map<Long, DynamicContent> getContentMap(List<DynamicMessage> messages) {
|
||||
private Map<Long, DynamicContent> getContentMap(PageResult<DynamicMessage> messages) {
|
||||
return dynamicContentService
|
||||
.mapByIds(messages.stream().map(DynamicMessage::getDynamicContentId).collect(
|
||||
.mapByIds(messages.getRecords().stream().map(DynamicMessage::getDynamicContentId).collect(
|
||||
Collectors.toSet()));
|
||||
}
|
||||
|
||||
private List<DynamicMessage> getMessages(DynamicLimitCmd cmd) {
|
||||
return dynamicMessageService.pageByTimeDesc(cmd.getPageNumber(), cmd.getReqUserId());
|
||||
private PageResult<DynamicMessage> getMessages(DynamicLimitCmd cmd) {
|
||||
return dynamicMessageService.pageByTimeDesc(cmd.getPageReq(), cmd.getReqUserId());
|
||||
}
|
||||
|
||||
private Set<Long> getUserIds(List<DynamicMessage> messages) {
|
||||
private Set<Long> getUserIds(PageResult<DynamicMessage> messages) {
|
||||
|
||||
return messages.stream().map(DynamicMessage::getCreateUser)
|
||||
return messages.getRecords().stream().map(DynamicMessage::getCreateUser)
|
||||
.filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
|
||||
import com.red.circle.common.business.dto.PageReq;
|
||||
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.clientobject.dynamic.DynamicPictureCO;
|
||||
@ -60,12 +62,13 @@ public class DynamicPopularQryExe {
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
|
||||
public List<DynamicListCO> execute(DynamicLimitCmd cmd) {
|
||||
PageReq pageReq = cmd.getPageReq();
|
||||
|
||||
//热门动态
|
||||
List<DynamicPopular> populars = getPopulars(cmd);
|
||||
|
||||
//大于第一页没数据则返回
|
||||
if (CollectionUtils.isEmpty(populars) && cmd.getPageNumber() > 1) {
|
||||
if (CollectionUtils.isEmpty(populars) && pageReq.getCursor() > 1) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
@ -78,7 +81,7 @@ public class DynamicPopularQryExe {
|
||||
|
||||
List<DynamicContent> resultList = Lists.newArrayList();
|
||||
//置顶动态,如果当前页码非第一页则无视置顶动态
|
||||
if (cmd.getPageNumber() <= 1) {
|
||||
if (pageReq.getCursor() <= 1) {
|
||||
resultList.addAll(getHotDynamic(topDynamicIds));
|
||||
}
|
||||
//处理热门动态列表
|
||||
@ -157,9 +160,9 @@ public class DynamicPopularQryExe {
|
||||
}
|
||||
|
||||
private List<DynamicContent> getTmpContentList(DynamicLimitCmd cmd) {
|
||||
return dynamicContentService.pageByTimeDesc(1,
|
||||
return dynamicContentService.pageByTimeDesc(cmd.getPageReq(),
|
||||
userRegionGateway.getRegionId(cmd.getReqUserId()),
|
||||
cmd.requireReqSysOrigin());
|
||||
cmd.requireReqSysOrigin()).getRecords().stream().toList();
|
||||
}
|
||||
|
||||
private List<DynamicContent> getHotDynamic(List<Long> contentIds) {
|
||||
@ -198,8 +201,9 @@ public class DynamicPopularQryExe {
|
||||
}
|
||||
|
||||
private List<DynamicPopular> getPopulars(DynamicLimitCmd cmd) {
|
||||
PageReq pageReq = cmd.getPageReq();
|
||||
return dynamicPopularService
|
||||
.pageDynamic(cmd.getReqSysOrigin().getOrigin(), cmd.getPageNumber(), 20,
|
||||
.pageDynamic(cmd.getReqSysOrigin().getOrigin(), pageReq.getCursor(), pageReq.getLimit(),
|
||||
userRegionGateway.getRegionId(cmd.getReqUserId()));
|
||||
}
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ public class DynamicServiceImpl implements DynamicService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DynamicListCO> listDynamicFollow(DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicListCO> listDynamicFollow(DynamicLimitCmd cmd) {
|
||||
return dynamicFollowQryExe.execute(cmd);
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class DynamicServiceImpl implements DynamicService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DynamicListCO> listDynamicLatest(DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicListCO> listDynamicLatest(DynamicLimitCmd cmd) {
|
||||
return dynamicLatestQryExe.execute(cmd);
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ public class DynamicServiceImpl implements DynamicService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DynamicMessageListCO> listDynamicMessage(DynamicLimitCmd cmd) {
|
||||
public PageResult<DynamicMessageListCO> listDynamicMessage(DynamicLimitCmd cmd) {
|
||||
return dynamicMessageQryExe.execute(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
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 jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ -16,11 +16,8 @@ import lombok.EqualsAndHashCode;
|
||||
public class DynamicLimitCmd extends AppExtCommand {
|
||||
|
||||
/**
|
||||
* 页码.
|
||||
*
|
||||
* @eo.required
|
||||
* 分页参数.
|
||||
*/
|
||||
@NotNull(message = "pageNumber required.")
|
||||
private Integer pageNumber;
|
||||
private PageReq pageReq;
|
||||
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public interface DynamicService {
|
||||
/**
|
||||
* 动态关注列表.
|
||||
*/
|
||||
List<DynamicListCO> listDynamicFollow(DynamicLimitCmd cmd);
|
||||
PageResult<DynamicListCO> listDynamicFollow(DynamicLimitCmd cmd);
|
||||
|
||||
/**
|
||||
* 我的动态列表.
|
||||
@ -64,7 +64,7 @@ public interface DynamicService {
|
||||
/**
|
||||
* 最新动态列表.
|
||||
*/
|
||||
List<DynamicListCO> listDynamicLatest(DynamicLimitCmd cmd);
|
||||
PageResult<DynamicListCO> listDynamicLatest(DynamicLimitCmd cmd);
|
||||
|
||||
/**
|
||||
* 热门动态列表.
|
||||
@ -110,7 +110,7 @@ public interface DynamicService {
|
||||
/**
|
||||
* 我的消息列表.
|
||||
*/
|
||||
List<DynamicMessageListCO> listDynamicMessage(DynamicLimitCmd cmd);
|
||||
PageResult<DynamicMessageListCO> listDynamicMessage(DynamicLimitCmd cmd);
|
||||
|
||||
/**
|
||||
* 删除自己全部消息.
|
||||
|
||||
@ -33,10 +33,8 @@ public interface DynamicContentService extends BaseService<DynamicContent> {
|
||||
|
||||
/**
|
||||
* 获得分页数据
|
||||
*
|
||||
* @param pageNumber 第几页
|
||||
*/
|
||||
List<DynamicContent> pageByTimeDesc(Integer pageNumber, String region, String sysOrigin);
|
||||
PageResult<DynamicContent> pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin);
|
||||
|
||||
/**
|
||||
* 获得分页数据
|
||||
|
||||
@ -2,6 +2,8 @@ package com.red.circle.other.infra.database.rds.service.dynamic;
|
||||
|
||||
|
||||
import com.red.circle.common.business.enums.DynamicMessageEnum;
|
||||
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.DynamicMessage;
|
||||
import java.util.Collection;
|
||||
@ -44,7 +46,7 @@ public interface DynamicMessageService extends BaseService<DynamicMessage> {
|
||||
* @param pageNumber 第几页
|
||||
* @param toUserId 被评价人或点赞ID
|
||||
*/
|
||||
List<DynamicMessage> pageByTimeDesc(Integer pageNumber, Long toUserId);
|
||||
PageResult<DynamicMessage> pageByTimeDesc(PageQuery pageQuery, Long toUserId);
|
||||
|
||||
/**
|
||||
* 我的消息列表统计
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
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.DynamicTimeline;
|
||||
import java.util.List;
|
||||
@ -35,8 +37,17 @@ public interface DynamicTimelineService extends BaseService<DynamicTimeline> {
|
||||
*/
|
||||
List<DynamicTimeline> pageByTimeDesc(String region, Integer pageNumber, Long createUser,
|
||||
Boolean isOwn);
|
||||
List<DynamicTimeline> pageByTimeDesc(List<Long> ids, String region, Integer pageNumber,
|
||||
Boolean isOwn);
|
||||
|
||||
/**
|
||||
* 获得分页数据 (使用PageQuery)
|
||||
*
|
||||
* @param ids 用户id列表
|
||||
* @param region 地区
|
||||
* @param pageQuery 分页参数
|
||||
* @param isOwn 是否为自己发布的动态
|
||||
*/
|
||||
PageResult<DynamicTimeline> pageByTimeDesc(List<Long> ids, String region, PageQuery pageQuery,
|
||||
Boolean isOwn);
|
||||
|
||||
/**
|
||||
* 获得自己发布过的动态
|
||||
|
||||
@ -57,20 +57,14 @@ public class DynamicContentServiceImpl extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DynamicContent> pageByTimeDesc(Integer pageNumber, String region, String sysOrigin) {
|
||||
public PageResult<DynamicContent> pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin) {
|
||||
|
||||
if (Objects.isNull(pageNumber) || pageNumber < 1) {
|
||||
pageNumber = 1;
|
||||
}
|
||||
|
||||
return Optional.ofNullable(query()
|
||||
return query()
|
||||
.eq(DynamicContent::getDel, Boolean.FALSE)
|
||||
.eq(DynamicContent::getSysOrigin, sysOrigin)
|
||||
.eq(DynamicContent::getRegion, region)
|
||||
.orderByDesc(DynamicContent::getCreateTime)
|
||||
.last(getPageSql(pageNumber))
|
||||
.list())
|
||||
.orElse(Lists.newArrayList());
|
||||
.page(pageQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.red.circle.other.infra.database.rds.service.dynamic.impl;
|
||||
|
||||
import com.red.circle.common.business.enums.DynamicMessageEnum;
|
||||
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.service.impl.BaseServiceImpl;
|
||||
import com.red.circle.other.infra.database.rds.dao.dynamic.DynamicMessageDAO;
|
||||
@ -91,18 +93,13 @@ public class DynamicMessageServiceImpl extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DynamicMessage> pageByTimeDesc(Integer pageNumber, Long toUserId) {
|
||||
|
||||
if (Objects.isNull(pageNumber) || pageNumber < 1) {
|
||||
pageNumber = 1;
|
||||
}
|
||||
public PageResult<DynamicMessage> pageByTimeDesc(PageQuery pageQuery, Long toUserId) {
|
||||
|
||||
return query()
|
||||
.eq(DynamicMessage::getToUserId, toUserId)
|
||||
.eq(DynamicMessage::getDel, Boolean.FALSE)
|
||||
.orderByDesc(DynamicMessage::getCreateTime)
|
||||
.last(getPageSql(pageNumber))
|
||||
.list();
|
||||
.page(pageQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.red.circle.other.infra.database.rds.service.dynamic.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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.service.impl.BaseServiceImpl;
|
||||
import com.red.circle.other.infra.database.rds.dao.dynamic.DynamicTimelineDAO;
|
||||
@ -64,29 +66,26 @@ public class DynamicTimelineServiceImpl extends
|
||||
.orderByDesc(DynamicTimeline::getCreateTime)
|
||||
.last(getPageSql(pageNumber))
|
||||
.list();
|
||||
} @Override
|
||||
public List<DynamicTimeline> pageByTimeDesc(List<Long> ids, String region, Integer pageNumber,
|
||||
Boolean isOwn) {
|
||||
|
||||
if (Objects.isNull(pageNumber) || pageNumber < 1) {
|
||||
pageNumber = 1;
|
||||
}
|
||||
|
||||
return query()
|
||||
.in(DynamicTimeline::getCreateUser, ids)
|
||||
.eq(DynamicTimeline::getOwn, isOwn)
|
||||
.in(DynamicTimeline::getRegion, region, "")
|
||||
.orderByDesc(DynamicTimeline::getCreateTime)
|
||||
.last(getPageSql(pageNumber))
|
||||
.list();
|
||||
}
|
||||
|
||||
|
||||
private String getPageSql(Integer pageNumber) {
|
||||
|
||||
return String.format("LIMIT %s, %s", (pageNumber - 1) * PageConstant.DEFAULT_LIMIT_SIZE,
|
||||
PageConstant.DEFAULT_LIMIT_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DynamicTimeline> pageByTimeDesc(List<Long> ids, String region, PageQuery pageQuery,
|
||||
Boolean isOwn) {
|
||||
return query()
|
||||
.in(DynamicTimeline::getCreateUser, ids)
|
||||
.eq(DynamicTimeline::getOwn, isOwn)
|
||||
.in(DynamicTimeline::getRegion, region, "")
|
||||
.orderByDesc(DynamicTimeline::getCreateTime)
|
||||
.page(pageQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DynamicTimeline> ownListByUserId(Long userId) {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user