评论列表分页处理,banner 搜索接口处理

This commit is contained in:
tianfeng 2026-01-28 18:03:42 +08:00
parent ce495fc09e
commit f98a4cc460
9 changed files with 27 additions and 41 deletions

View File

@ -80,7 +80,7 @@ public class DynamicRestController extends BaseController {
* @eo.request-type formdata * @eo.request-type formdata
*/ */
@GetMapping("/list/comment") @GetMapping("/list/comment")
public List<DynamicCommentListCO> listDynamicComment(@Validated DynamicCommentLimitCmd cmd) { public PageResult<DynamicCommentListCO> listDynamicComment(@Validated DynamicCommentLimitCmd cmd) {
return dynamicService.listDynamicComment(cmd); return dynamicService.listDynamicComment(cmd);
} }

View File

@ -121,21 +121,6 @@ public class DynamicCommentCmdExe {
DynamicContent dynamicContent = dynamicContentService.getById(cmd.getId()); DynamicContent dynamicContent = dynamicContentService.getById(cmd.getId());
ResponseAssert.notNull(DynamicErrorCode.CONTENT_IS_NULL, dynamicContent); ResponseAssert.notNull(DynamicErrorCode.CONTENT_IS_NULL, dynamicContent);
ResponseAssert.isFalse(DynamicErrorCode.CONTENT_DELETE, dynamicContent.getDel()); ResponseAssert.isFalse(DynamicErrorCode.CONTENT_DELETE, dynamicContent.getDel());
if (SensitiveWordFilter.checkSensitiveWord(cmd.getContent())){
// 封禁账号及设备
// userAccountCommon.punishmentPro(new PunishmentAccountCmd()
// .setBeOptUserId(cmd.getReqUserId())
// .setOptUserId(cmd.requiredReqUserId())
// .setStatus(AccountStatusEnum.ARCHIVE)
// .setDescription("【动态涉及敏感词】封号+设备-" + cmd.getContent())
// );
//
// UserProfile userProfile = new UserProfile();
// userProfile.setId(cmd.getReqUserId());
// userProfile.setCheckStatus(AccountStatusEnum.ARCHIVE.name());
// userProfileGateway.updateSelectiveById(userProfile);
ResponseAssert.isTrue(DynamicErrorCode.SENSITIVE_WORD_ERROR, Boolean.FALSE);
}
return dynamicContent; return dynamicContent;
} }

View File

@ -2,6 +2,7 @@ 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.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.cmd.dynamic.DynamicCommentLimitCmd; import com.red.circle.other.app.dto.cmd.dynamic.DynamicCommentLimitCmd;
import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.UserProfileGateway;
@ -42,22 +43,22 @@ public class DynamicCommentQryExe {
private final DynamicCommentService dynamicCommentService; private final DynamicCommentService dynamicCommentService;
private final DynamicCommentLikeService dynamicCommentLikeService; private final DynamicCommentLikeService dynamicCommentLikeService;
public List<DynamicCommentListCO> execute(DynamicCommentLimitCmd cmd) { public PageResult<DynamicCommentListCO> execute(DynamicCommentLimitCmd cmd) {
DynamicContent dynamicContent = dynamicContentService.getById(cmd.getDynamicId()); DynamicContent dynamicContent = dynamicContentService.getById(cmd.getDynamicId());
ResponseAssert.notNull(DynamicErrorCode.CONTENT_IS_NULL, dynamicContent); ResponseAssert.notNull(DynamicErrorCode.CONTENT_IS_NULL, dynamicContent);
ResponseAssert.isFalse(DynamicErrorCode.CONTENT_DELETE, dynamicContent.getDel()); ResponseAssert.isFalse(DynamicErrorCode.CONTENT_DELETE, dynamicContent.getDel());
List<DynamicComment> comments = pageData(cmd); PageResult<DynamicComment> comments = pageData(cmd);
if (CollectionUtils.isEmpty(comments)) { if (CollectionUtils.isEmpty(comments.getRecords())) {
return Lists.newArrayList(); return PageResult.newPageResult(0);
} }
Map<Long, UserProfile> userMap = Map<Long, UserProfile> userMap =
userProfileGateway.mapByUserIds(getUserIds(comments)); userProfileGateway.mapByUserIds(getUserIds(comments));
Map<Long, Boolean> commentLikeMap = getCommentLikeMap(cmd, comments); Map<Long, Boolean> commentLikeMap = getCommentLikeMap(cmd, comments);
return comments.stream().map(comment -> { return comments.convert(comment -> {
DynamicCommentListCO listCO = new DynamicCommentListCO(); DynamicCommentListCO listCO = new DynamicCommentListCO();
UserProfile createUser = userMap.get(comment.getCreateUser()); UserProfile createUser = userMap.get(comment.getCreateUser());
@ -90,7 +91,7 @@ public class DynamicCommentQryExe {
return listCO; return listCO;
}).filter(Objects::nonNull).collect(Collectors.toList()); });
} }
private Boolean getLike(Map<Long, Boolean> commentLikeMap, DynamicComment comment) { private Boolean getLike(Map<Long, Boolean> commentLikeMap, DynamicComment comment) {
@ -98,9 +99,9 @@ public class DynamicCommentQryExe {
} }
private Map<Long, Boolean> getCommentLikeMap(DynamicCommentLimitCmd cmd, private Map<Long, Boolean> getCommentLikeMap(DynamicCommentLimitCmd cmd,
List<DynamicComment> comments) { PageResult<DynamicComment> comments) {
return dynamicCommentLikeService return dynamicCommentLikeService
.mapByCommentIdsByUserId(comments.stream().map(DynamicComment::getId).collect( .mapByCommentIdsByUserId(comments.getRecords().stream().map(DynamicComment::getId).collect(
Collectors.toSet()), cmd.getReqUserId()); Collectors.toSet()), cmd.getReqUserId());
} }
@ -111,19 +112,19 @@ public class DynamicCommentQryExe {
.orElse(0L)); .orElse(0L));
} }
private Set<Long> getUserIds(List<DynamicComment> comments) { private Set<Long> getUserIds(PageResult<DynamicComment> comments) {
Set<Long> userIds = comments.stream().map(DynamicComment::getCreateUser) Set<Long> userIds = comments.getRecords().stream().map(DynamicComment::getCreateUser)
.filter(Objects::nonNull).collect(Collectors.toSet()); .filter(Objects::nonNull).collect(Collectors.toSet());
userIds.addAll(comments.stream().map(DynamicComment::getToUserId).filter(Objects::nonNull) userIds.addAll(comments.getRecords().stream().map(DynamicComment::getToUserId).filter(Objects::nonNull)
.collect(Collectors.toSet())); .collect(Collectors.toSet()));
return userIds; return userIds;
} }
private List<DynamicComment> pageData(DynamicCommentLimitCmd cmd) { private PageResult<DynamicComment> pageData(DynamicCommentLimitCmd cmd) {
return dynamicCommentService.pageByTimeDesc(cmd.getPageNumber(), cmd.getDynamicId()); return dynamicCommentService.pageByTimeDesc(cmd.getPageReq(), cmd.getDynamicId());
} }
} }

View File

@ -87,7 +87,7 @@ public class DynamicServiceImpl implements DynamicService {
} }
@Override @Override
public List<DynamicCommentListCO> listDynamicComment(DynamicCommentLimitCmd cmd) { public PageResult<DynamicCommentListCO> listDynamicComment(DynamicCommentLimitCmd cmd) {
return dynamicCommentQryExe.execute(cmd); return dynamicCommentQryExe.execute(cmd);
} }

View File

@ -1,5 +1,6 @@
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 jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
@ -21,7 +22,7 @@ public class DynamicCommentLimitCmd extends AppExtCommand {
* @eo.required * @eo.required
*/ */
@NotNull @NotNull
private Integer pageNumber; private PageReq pageReq;
/** /**
* 动态内容id. * 动态内容id.

View File

@ -44,7 +44,7 @@ public interface DynamicService {
/** /**
* 动态评论列表. * 动态评论列表.
*/ */
List<DynamicCommentListCO> listDynamicComment(DynamicCommentLimitCmd cmd); PageResult<DynamicCommentListCO> listDynamicComment(DynamicCommentLimitCmd cmd);
/** /**
* 动态内容详情. * 动态内容详情.

View File

@ -1,6 +1,8 @@
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.mybatis.service.BaseService; import com.red.circle.framework.mybatis.service.BaseService;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicComment; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicComment;
import java.util.Collection; import java.util.Collection;
@ -24,7 +26,7 @@ public interface DynamicCommentService extends BaseService<DynamicComment> {
* @param pageNumber 第几页 * @param pageNumber 第几页
* @param contentId 动态内容ID * @param contentId 动态内容ID
*/ */
List<DynamicComment> pageByTimeDesc(Integer pageNumber, Long contentId); PageResult<DynamicComment> pageByTimeDesc(PageQuery pageQuery, Long contentId);
/** /**
* 获得子评论数 * 获得子评论数

View File

@ -2,6 +2,8 @@ package com.red.circle.other.infra.database.rds.service.dynamic.impl;
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.mybatis.constant.PageConstant; import com.red.circle.framework.mybatis.constant.PageConstant;
import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService; import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService;
@ -41,17 +43,12 @@ public class DynamicCommentServiceImpl extends
} }
@Override @Override
public List<DynamicComment> pageByTimeDesc(Integer pageNumber, Long contentId) { public PageResult<DynamicComment> pageByTimeDesc(PageQuery pageQuery, Long contentId) {
if (Objects.isNull(pageNumber) || pageNumber < 1) {
pageNumber = 1;
}
return query() return query()
.eq(DynamicComment::getDynamicContentId, contentId) .eq(DynamicComment::getDynamicContentId, contentId)
.orderByDesc(DynamicComment::getCreateTime) .orderByDesc(DynamicComment::getCreateTime)
.last(getPageSql(pageNumber)) .page(pageQuery);
.list();
} }
@Override @Override

View File

@ -51,7 +51,7 @@ public class BannerConfigServiceImpl extends
wrapper.in(BannerConfig::getPlatform, "", query.getPlatform()) wrapper.in(BannerConfig::getPlatform, "", query.getPlatform())
) )
.and(StringUtils.isNotBlank(query.getCountryCode()), wrapper -> .and(StringUtils.isNotBlank(query.getCountryCode()), wrapper ->
wrapper.in(BannerConfig::getCountryCode, "", query.getCountryCode()) wrapper.apply("(country_code = '' OR FIND_IN_SET({0}, country_code))", query.getCountryCode())
) )
.eq(Objects.equals(query.getShowcase(), 1), BannerConfig::getShowcase, Boolean.TRUE) .eq(Objects.equals(query.getShowcase(), 1), BannerConfig::getShowcase, Boolean.TRUE)
.gt(Objects.equals(query.getShowcase(), 1), BannerConfig::getExpiredTime, TimestampUtils.now()) .gt(Objects.equals(query.getShowcase(), 1), BannerConfig::getExpiredTime, TimestampUtils.now())