From fc92197004fdc9f6cf1f4a5ef3e38f7f0c2f3b31 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 29 Dec 2025 20:05:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=B6=E6=97=8F=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=AD=89=E7=BA=A7=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/family/FamilyListExe.java | 50 ++++++----- .../rds/dao/family/FamilyBaseInfoDAO.java | 13 +++ .../rds/dto/family/FamilyWithLevelDTO.java | 83 +++++++++++++++++++ .../dao/family/FamilyBaseInfoDAO.xml | 26 ++++++ 4 files changed, 151 insertions(+), 21 deletions(-) create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dto/family/FamilyWithLevelDTO.java diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyListExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyListExe.java index aa091539..c93a1a8a 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyListExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyListExe.java @@ -1,18 +1,17 @@ package com.red.circle.other.app.command.family; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.red.circle.framework.dto.PageResult; -import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import com.red.circle.other.app.dto.clientobject.family.FamilyListCO; import com.red.circle.other.app.dto.cmd.family.FamilyListCmd; -import com.red.circle.other.infra.database.rds.entity.family.FamilyBaseInfo; +import com.red.circle.other.infra.database.rds.dao.family.FamilyBaseInfoDAO; +import com.red.circle.other.infra.database.rds.dto.family.FamilyWithLevelDTO; import com.red.circle.other.infra.database.rds.entity.family.FamilyLevelConfig; -import com.red.circle.other.infra.database.rds.service.family.FamilyBaseInfoService; import com.red.circle.other.infra.database.rds.service.family.FamilyLevelConfigService; import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService; import com.red.circle.tool.core.collection.CollectionUtils; +import com.red.circle.tool.core.text.StringUtils; import java.util.List; import java.util.Map; import java.util.Optional; @@ -20,7 +19,6 @@ import java.util.Set; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; /** * 家族列表查询. @@ -29,34 +27,41 @@ import org.springframework.util.StringUtils; @RequiredArgsConstructor public class FamilyListExe { - private final FamilyBaseInfoService familyBaseInfoService; private final FamilyLevelConfigService familyLevelConfigService; private final FamilyMemberInfoService familyMemberInfoService; + private final FamilyBaseInfoDAO familyBaseInfoDAO; public PageResult execute(FamilyListCmd cmd) { - Page page = new Page<>(); - IPage baseInfoIPage = familyBaseInfoService.page(page, - Wrappers.lambdaQuery() - .eq(StringUtils.hasText(cmd.getFamilyAccount()), FamilyBaseInfo::getFamilyAccount, cmd.getFamilyAccount()) - .orderByDesc(TimestampBaseEntity::getCreateTime)); + Page page = new Page<>(cmd.getCurrent(), cmd.getSize()); + + Long familyAccount = null; + if (StringUtils.isNotBlank(cmd.getFamilyAccount())) { + try { + familyAccount = Long.parseLong(cmd.getFamilyAccount()); + } catch (NumberFormatException e) { + return PageResult.newPageResult(0); + } + } + + IPage familyPage = familyBaseInfoDAO.pageWithLevel(page, familyAccount); PageResult pageResult = new PageResult<>(); - pageResult.setCurrent(page.getCurrent()); - pageResult.setSize(page.getSize()); - pageResult.setTotal(baseInfoIPage.getTotal()); + pageResult.setCurrent(familyPage.getCurrent()); + pageResult.setSize(familyPage.getSize()); + pageResult.setTotal(familyPage.getTotal()); - if (CollectionUtils.isEmpty(baseInfoIPage.getRecords())) { - return PageResult.newPageResult(0); + if (CollectionUtils.isEmpty(familyPage.getRecords())) { + return pageResult; } - List familyList = baseInfoIPage.getRecords(); + List familyList = familyPage.getRecords(); Set familyIds = familyList.stream() - .map(FamilyBaseInfo::getId) + .map(FamilyWithLevelDTO::getId) .collect(Collectors.toSet()); Set levelIds = familyList.stream() - .map(FamilyBaseInfo::getFamilyLevelId) + .map(FamilyWithLevelDTO::getFamilyLevelId) .collect(Collectors.toSet()); Map memberCountMap = familyMemberInfoService.mapMemberCountByFamilyIds(familyIds); @@ -74,10 +79,13 @@ public class FamilyListExe { .setFamilyIntro(family.getFamilyIntro()) .setFamilyNotice(family.getFamilyNotice()) .setCurrentMember(currentMember.intValue()) - .setFamilyLevel(Optional.ofNullable(levelConfig.getLevelKey()) + .setFamilyLevel(Optional.ofNullable(levelConfig) + .map(FamilyLevelConfig::getLevelKey) .map(key -> Integer.parseInt(key.substring(6))) .orElse(0)) - .setMaxMember(levelConfig.getMaxMember()); + .setMaxMember(Optional.ofNullable(levelConfig) + .map(FamilyLevelConfig::getMaxMember) + .orElse(0)); }).toList(); pageResult.setRecords(records); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/family/FamilyBaseInfoDAO.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/family/FamilyBaseInfoDAO.java index ee94e2e3..90621a41 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/family/FamilyBaseInfoDAO.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/family/FamilyBaseInfoDAO.java @@ -1,8 +1,12 @@ package com.red.circle.other.infra.database.rds.dao.family; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.red.circle.framework.mybatis.dao.BaseDAO; +import com.red.circle.other.infra.database.rds.dto.family.FamilyWithLevelDTO; import com.red.circle.other.infra.database.rds.entity.family.FamilyBaseInfo; +import org.apache.ibatis.annotations.Param; /** *

@@ -16,4 +20,13 @@ public interface FamilyBaseInfoDAO extends BaseDAO { Long maxAccount(); + /** + * 按等级经验分页查询家族列表 + * + * @param page 分页参数 + * @param familyAccount 家族账号(可选) + * @return 家族信息列表 + */ + IPage pageWithLevel(Page page, @Param("familyAccount") Long familyAccount); + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dto/family/FamilyWithLevelDTO.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dto/family/FamilyWithLevelDTO.java new file mode 100644 index 00000000..ae886731 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dto/family/FamilyWithLevelDTO.java @@ -0,0 +1,83 @@ +package com.red.circle.other.infra.database.rds.dto.family; + +import lombok.Data; + +import java.math.BigDecimal; +import java.sql.Timestamp; + +/** + * 家族基础信息带等级经验DTO + */ +@Data +public class FamilyWithLevelDTO { + + /** + * 家族ID + */ + private Long id; + + /** + * 来源系统 + */ + private String sysOrigin; + + /** + * 家族账号 + */ + private String familyAccount; + + /** + * 家族头像 + */ + private String familyAvatar; + + /** + * 家族名称 + */ + private String familyName; + + /** + * 家族等级ID + */ + private Long familyLevelId; + + /** + * 家族状态 + */ + private String familyStatus; + + /** + * 家族介绍 + */ + private String familyIntro; + + /** + * 家族公告 + */ + private String familyNotice; + + /** + * 创建时间 + */ + private Timestamp createTime; + + /** + * 创建用户 + */ + private Long createUser; + + /** + * 修改时间 + */ + private Timestamp updateTime; + + /** + * 修改用户 + */ + private Long updateUser; + + /** + * 家族经验值 + */ + private BigDecimal exp; +} diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/family/FamilyBaseInfoDAO.xml b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/family/FamilyBaseInfoDAO.xml index 7427fe06..72980638 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/family/FamilyBaseInfoDAO.xml +++ b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/family/FamilyBaseInfoDAO.xml @@ -8,4 +8,30 @@ FROM family_base_info + +