From 31b72609daaa69eb4229008df13c3085db6a6eff Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 13 Mar 2026 15:30:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=88=86=E9=A1=B5=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/user/api/UserProfileClientApi.java | 2 +- .../app/user/UserBaseInfoRestController.java | 3 +- .../app/user/UserBaseInfoServiceImpl.java | 46 +++++++++++-------- .../service/app/user/UserBaseInfoService.java | 3 +- .../gateway/user/UserProfileGateway.java | 3 +- .../service/user/user/BaseInfoService.java | 3 +- .../user/user/impl/BaseInfoServiceImpl.java | 22 ++++++++- .../gateway/user/UserProfileGatewayImpl.java | 27 +++++++---- .../user/UserProfileInnerConvertor.java | 3 ++ .../user/user/UserProfileClientEndpoint.java | 2 +- .../user/user/UserProfileClientService.java | 2 +- .../impl/UserProfileClientServiceImpl.java | 2 +- 12 files changed, 80 insertions(+), 38 deletions(-) diff --git a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/user/user/api/UserProfileClientApi.java b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/user/user/api/UserProfileClientApi.java index 84306f84..72daa97b 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/user/user/api/UserProfileClientApi.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/user/user/api/UserProfileClientApi.java @@ -96,7 +96,7 @@ public interface UserProfileClientApi { * 分页查询用户信息 */ @PostMapping("/pageListQuery") - ResultResponse> pageListQuery(@RequestBody UserProfileListQryCmd query); + ResultResponse> pageListQuery(@RequestBody UserProfileListQryCmd query); /** * 获取用户资料集合. diff --git a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/UserBaseInfoRestController.java b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/UserBaseInfoRestController.java index 82555134..90e4276b 100644 --- a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/UserBaseInfoRestController.java +++ b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/UserBaseInfoRestController.java @@ -8,6 +8,7 @@ import com.red.circle.console.app.dto.clienobject.user.UserProfileListCO; import com.red.circle.console.app.dto.clienobject.user.UserVipEquityCO; import com.red.circle.console.app.service.app.user.UserBaseInfoService; import com.red.circle.console.infra.annotations.OpsOperationReqLog; +import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.web.controller.BaseController; import com.red.circle.tool.core.tuple.ImmutableKeyValuePair; import com.red.circle.other.inner.model.cmd.user.UserBaseInfoCmd; @@ -45,7 +46,7 @@ public class UserBaseInfoRestController extends BaseController { * 用户分页列表. */ @PostMapping("/page") - public List userLisPage( + public PageResult userLisPage( @RequestBody UserProfileListQryCmd query) { return userBaseInfoService.pageListQuery(query); } diff --git a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserBaseInfoServiceImpl.java b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserBaseInfoServiceImpl.java index 8169454e..6d936270 100644 --- a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserBaseInfoServiceImpl.java +++ b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserBaseInfoServiceImpl.java @@ -14,6 +14,7 @@ import com.red.circle.external.inner.endpoint.message.NewsletterClient; import com.red.circle.external.inner.model.cmd.message.NewsletterResultCmd; import com.red.circle.external.inner.model.enums.message.NewsletterEvent; import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.ResultResponse; import com.red.circle.other.inner.asserts.RoomErrorCode; import com.red.circle.other.inner.endpoint.live.RoomManagerClient; @@ -100,21 +101,21 @@ public class UserBaseInfoServiceImpl implements @Override - public List pageListQuery(UserProfileListQryCmd query) { + public PageResult pageListQuery(UserProfileListQryCmd query) { appendUserProfileListQuery(query); if (StringUtils.isNotBlank(query.getAccount()) && CollectionUtils.isEmpty(query.getUserIds())) { - return Lists.newArrayList(); + return PageResult.newPageResult(0); } - List userProfiles = ResponseAssert.requiredSuccess( + PageResult userProfiles = ResponseAssert.requiredSuccess( userProfileClient.pageListQuery(query)); - if (CollectionUtils.isEmpty(userProfiles)) { - return Lists.newArrayList(); + if (CollectionUtils.isEmpty(userProfiles.getRecords())) { + return PageResult.newPageResult(0); } - Set userIds = userProfiles.stream().map(UserProfileDTO::getId) + Set userIds = userProfiles.getRecords().stream().map(UserProfileDTO::getId) .collect(Collectors.toSet()); Map userGoldBalanceMap = ResponseAssert.requiredSuccess(walletGoldClient @@ -133,20 +134,27 @@ public class UserBaseInfoServiceImpl implements userProfileClient .mapRegisterInfo(userIds)); - return userProfiles.stream().map(userProfile -> - new UserProfileListCO() - .setId(userProfile.getId()) - .setUserProfile(userProfile) - .setGoldBalance(Optional.ofNullable(userGoldBalanceMap.get(userProfile.getId())) - .map(BigDecimal::valueOf).orElse(BigDecimal.ZERO)) - .setDiamondBalance(userDiamondBalanceMap.get(userProfile.getId())) - .setSalaryDiamondBalance(userSalaryDiamondBalanceMap.get(userProfile.getId())) - .setLastActiveTime(Optional.ofNullable(userExpandMap.get(userProfile.getId())) - .map(UserExpandDTO::getLastActiveTime) - .orElse(null)) - .setUserRegisterInfo(Optional.ofNullable(userRegisterInfoMap.get(userProfile.getId())) - .orElse(null)) + List collect = userProfiles.getRecords().stream().map(userProfile -> + new UserProfileListCO() + .setId(userProfile.getId()) + .setUserProfile(userProfile) + .setGoldBalance(Optional.ofNullable(userGoldBalanceMap.get(userProfile.getId())) + .map(BigDecimal::valueOf).orElse(BigDecimal.ZERO)) + .setDiamondBalance(userDiamondBalanceMap.get(userProfile.getId())) + .setSalaryDiamondBalance(userSalaryDiamondBalanceMap.get(userProfile.getId())) + .setLastActiveTime(Optional.ofNullable(userExpandMap.get(userProfile.getId())) + .map(UserExpandDTO::getLastActiveTime) + .orElse(null)) + .setUserRegisterInfo(Optional.ofNullable(userRegisterInfoMap.get(userProfile.getId())) + .orElse(null)) ).collect(Collectors.toList()); + + PageResult result = new PageResult<>(); + result.setRecords(collect); + result.setTotal(userProfiles.getTotal()); + result.setCurrent(userProfiles.getCurrent()); + result.setSize(userProfiles.getSize()); + return result; } @Override diff --git a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/service/app/user/UserBaseInfoService.java b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/service/app/user/UserBaseInfoService.java index d5dbe99b..fff0b956 100644 --- a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/service/app/user/UserBaseInfoService.java +++ b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/service/app/user/UserBaseInfoService.java @@ -6,6 +6,7 @@ import com.red.circle.console.app.dto.clienobject.user.UserIdentityCO; import com.red.circle.console.app.dto.clienobject.user.UserProfileDetailCO; import com.red.circle.console.app.dto.clienobject.user.UserProfileListCO; import com.red.circle.console.app.dto.clienobject.user.UserVipEquityCO; +import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.ResultResponse; import com.red.circle.other.inner.model.cmd.count.PropsSaleQuotaQryCmd; import com.red.circle.other.inner.model.cmd.count.SysOriginUserQryCmd; @@ -30,7 +31,7 @@ public interface UserBaseInfoService { /** * 分页查询用户资料 */ - List pageListQuery(UserProfileListQryCmd query); + PageResult pageListQuery(UserProfileListQryCmd query); /** * 查询系统用户数量 diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java index 9a1dbda8..2c5d1c7d 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java @@ -1,6 +1,7 @@ package com.red.circle.other.domain.gateway.user; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; +import com.red.circle.framework.dto.PageResult; import com.red.circle.other.domain.model.user.NobleAbilityCO; import com.red.circle.other.inner.enums.material.PropsVipActualEquityEnum; import com.red.circle.tool.core.tuple.ImmutableKeyValuePair; @@ -32,7 +33,7 @@ public interface UserProfileGateway { /** * 分页查询用户信息 */ - List pageListQuery(UserProfileListQryCmd query); + PageResult pageListQuery(UserProfileListQryCmd query); /** * 获取账号信息. diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/BaseInfoService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/BaseInfoService.java index e760e516..369c383e 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/BaseInfoService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/BaseInfoService.java @@ -3,6 +3,7 @@ package com.red.circle.other.infra.database.rds.service.user.user; import com.google.common.collect.Maps; import com.red.circle.common.business.enums.AccountStatusEnum; +import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.inner.model.cmd.count.SysOriginUserQryCmd; import com.red.circle.other.inner.model.dto.pet.UserBaseInfoDTO; @@ -56,7 +57,7 @@ public interface BaseInfoService extends BaseService { */ Long maxUserAccount(Long start, Long end); - List pageQuery(UserBaseInfoPageQryCmd query); + PageResult pageQuery(UserBaseInfoPageQryCmd query); /** * 修改用户头像 diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/BaseInfoServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/BaseInfoServiceImpl.java index 88a70ad4..b42ba707 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/BaseInfoServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/BaseInfoServiceImpl.java @@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.google.common.collect.Maps; import com.red.circle.common.business.enums.AccountStatusEnum; import com.red.circle.common.business.enums.GenderEnum; +import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.mybatis.constant.PageConstant; +import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; import com.red.circle.other.infra.convertor.user.SysUserBaseInfoConvertor; import com.red.circle.other.infra.database.rds.dao.user.user.BaseInfoDAO; @@ -145,8 +147,24 @@ public class BaseInfoServiceImpl extends BaseServiceImpl @Override - public List pageQuery(UserBaseInfoPageQryCmd query) { - return baseInfoDAO.pageQuery(query); + public PageResult pageQuery(UserBaseInfoPageQryCmd query) { + return this.query() + .eq(Objects.nonNull(query.getDel()), BaseInfo::getDel, query.getDel()) + .in(Objects.nonNull(query.getUserIds()) && !query.getUserIds().isEmpty(), BaseInfo::getId, query.getUserIds()) + .eq(Objects.nonNull(query.getUserSex()), BaseInfo::getUserSex, query.getUserSex()) + .eq(Objects.nonNull(query.getUserType()), BaseInfo::getUserType, query.getUserType()) + .ge(Objects.nonNull(query.getStartCreateDate()), TimestampBaseEntity::getCreateTime, query.getStartCreateDate()) + .le(Objects.nonNull(query.getEndCreateDate()), TimestampBaseEntity::getCreateTime, query.getEndCreateDate()) + .eq(StringUtils.isNotBlank(query.getCountryCode()), BaseInfo::getCountryCode, query.getCountryCode()) + .inSql(StringUtils.isNotBlank(query.getAuthType()), BaseInfo::getId, + "SELECT uri.user_id FROM user_register_info uri WHERE uri.auth_type = '" + query.getAuthType() + "'") + .inSql(StringUtils.isNotBlank(query.getOriginPlatform()), BaseInfo::getId, + "SELECT uri.user_id FROM user_register_info uri WHERE uri.origin_platform = '" + query.getOriginPlatform() + "'") + .in(Objects.nonNull(query.getSysOrigins()) && !query.getSysOrigins().isEmpty(), BaseInfo::getOriginSys, query.getSysOrigins()) + .inSql(StringUtils.isNotBlank(query.getDeviceId()), BaseInfo::getId, + "SELECT ulmd.user_id FROM user_latest_mobile_device ulmd WHERE ulmd.imei = '" + query.getDeviceId() + "'") + .orderByDesc(BaseInfo::getId) + .page(query.getPageQuery()); } @Override diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java index 23d96d11..f1df252a 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java @@ -7,6 +7,7 @@ import com.google.common.collect.Sets; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.common.business.core.level.LevelUtils; import com.red.circle.external.inner.endpoint.message.ImAccountClient; +import com.red.circle.framework.dto.PageResult; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.UserRunProfileTransportGateway; import com.red.circle.other.domain.model.user.OwnSpecialId; @@ -117,25 +118,33 @@ public class UserProfileGatewayImpl implements UserProfileGateway { } @Override - public List pageListQuery(UserProfileListQryCmd query) { - List userBaseInfos = baseInfoService.pageQuery( + public PageResult pageListQuery(UserProfileListQryCmd query) { + PageResult userBaseInfos = baseInfoService.pageQuery( userProfileInfraConvertor.toUserBaseInfoPageQryCmd(query) ); - if (CollectionUtils.isEmpty(userBaseInfos)) { - return Lists.newArrayList(); + if (CollectionUtils.isEmpty(userBaseInfos.getRecords())) { + return PageResult.newPageResult(0); } return listUserProfiles(userBaseInfos); } - private List listUserProfiles(List userBaseInfos) { + private PageResult listUserProfiles(PageResult pageResult) { Map userSpecialIdMap = userSpecialIdService.mapByUserIds( - userBaseInfos.stream().map(BaseInfo::getId).collect( + pageResult.getRecords().stream().map(BaseInfo::getId).collect( Collectors.toSet())); - return userBaseInfos.stream() - .map(baseInfo -> mergeUserProfile(userSpecialIdMap.get(baseInfo.getId()), baseInfo)) - .collect(Collectors.toList()); + + List collect = pageResult.getRecords().stream() + .map(baseInfo -> mergeUserProfile(userSpecialIdMap.get(baseInfo.getId()), baseInfo)) + .collect(Collectors.toList()); + + PageResult result = new PageResult<>(); + result.setRecords(collect); + result.setTotal(pageResult.getTotal()); + result.setCurrent(pageResult.getCurrent()); + result.setSize(pageResult.getSize()); + return result; } @Override diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/convertor/user/UserProfileInnerConvertor.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/convertor/user/UserProfileInnerConvertor.java index 95cf82ed..3ea601c0 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/convertor/user/UserProfileInnerConvertor.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/convertor/user/UserProfileInnerConvertor.java @@ -2,6 +2,7 @@ package com.red.circle.other.app.inner.convertor.user; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.framework.core.convertor.ConvertorModel; +import com.red.circle.framework.dto.PageResult; import com.red.circle.mq.business.model.event.user.LoginLoggerEvent; import com.red.circle.other.domain.model.user.UserConsumptionLevel; import com.red.circle.other.domain.model.user.UserProfile; @@ -104,5 +105,7 @@ public interface UserProfileInnerConvertor { List toListUserProfileDTO(List userProfiles); + PageResult toListUserProfileDTO(PageResult userProfiles); + Map toMapUserProfileDTO(Map map); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/user/user/UserProfileClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/user/user/UserProfileClientEndpoint.java index d6132275..ce1da828 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/user/user/UserProfileClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/user/user/UserProfileClientEndpoint.java @@ -102,7 +102,7 @@ public class UserProfileClientEndpoint implements UserProfileClientApi { @Override - public ResultResponse> pageListQuery(UserProfileListQryCmd query) { + public ResultResponse> pageListQuery(UserProfileListQryCmd query) { return ResultResponse.success(userProfileClientService.pageListQuery(query)); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/UserProfileClientService.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/UserProfileClientService.java index ab56d5ca..92bbed58 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/UserProfileClientService.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/UserProfileClientService.java @@ -64,7 +64,7 @@ public interface UserProfileClientService { /** * 分页查询用户资料 */ - List pageListQuery(UserProfileListQryCmd query); + PageResult pageListQuery(UserProfileListQryCmd query); /** * 获取用户资料集合. diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserProfileClientServiceImpl.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserProfileClientServiceImpl.java index 0fd506f9..7b277e35 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserProfileClientServiceImpl.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserProfileClientServiceImpl.java @@ -180,7 +180,7 @@ public class UserProfileClientServiceImpl implements UserProfileClientService { @Override - public List pageListQuery(UserProfileListQryCmd query) { + public PageResult pageListQuery(UserProfileListQryCmd query) { return userProfileInnerConvertor.toListUserProfileDTO(userProfileGateway.pageListQuery(query)); }