用户列表接口,增加分页效果
This commit is contained in:
parent
1253a404b2
commit
31b72609da
@ -96,7 +96,7 @@ public interface UserProfileClientApi {
|
||||
* 分页查询用户信息
|
||||
*/
|
||||
@PostMapping("/pageListQuery")
|
||||
ResultResponse<List<UserProfileDTO>> pageListQuery(@RequestBody UserProfileListQryCmd query);
|
||||
ResultResponse<PageResult<UserProfileDTO>> pageListQuery(@RequestBody UserProfileListQryCmd query);
|
||||
|
||||
/**
|
||||
* 获取用户资料集合.
|
||||
|
||||
@ -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<UserProfileListCO> userLisPage(
|
||||
public PageResult<UserProfileListCO> userLisPage(
|
||||
@RequestBody UserProfileListQryCmd query) {
|
||||
return userBaseInfoService.pageListQuery(query);
|
||||
}
|
||||
|
||||
@ -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<UserProfileListCO> pageListQuery(UserProfileListQryCmd query) {
|
||||
public PageResult<UserProfileListCO> pageListQuery(UserProfileListQryCmd query) {
|
||||
appendUserProfileListQuery(query);
|
||||
if (StringUtils.isNotBlank(query.getAccount())
|
||||
&& CollectionUtils.isEmpty(query.getUserIds())) {
|
||||
return Lists.newArrayList();
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
|
||||
List<UserProfileDTO> userProfiles = ResponseAssert.requiredSuccess(
|
||||
PageResult<UserProfileDTO> userProfiles = ResponseAssert.requiredSuccess(
|
||||
userProfileClient.pageListQuery(query));
|
||||
|
||||
if (CollectionUtils.isEmpty(userProfiles)) {
|
||||
return Lists.newArrayList();
|
||||
if (CollectionUtils.isEmpty(userProfiles.getRecords())) {
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
|
||||
Set<Long> userIds = userProfiles.stream().map(UserProfileDTO::getId)
|
||||
Set<Long> userIds = userProfiles.getRecords().stream().map(UserProfileDTO::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Map<Long, Long> 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<UserProfileListCO> 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<UserProfileListCO> result = new PageResult<>();
|
||||
result.setRecords(collect);
|
||||
result.setTotal(userProfiles.getTotal());
|
||||
result.setCurrent(userProfiles.getCurrent());
|
||||
result.setSize(userProfiles.getSize());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -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<UserProfileListCO> pageListQuery(UserProfileListQryCmd query);
|
||||
PageResult<UserProfileListCO> pageListQuery(UserProfileListQryCmd query);
|
||||
|
||||
/**
|
||||
* 查询系统用户数量
|
||||
|
||||
@ -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<UserProfile> pageListQuery(UserProfileListQryCmd query);
|
||||
PageResult<UserProfile> pageListQuery(UserProfileListQryCmd query);
|
||||
|
||||
/**
|
||||
* 获取账号信息.
|
||||
|
||||
@ -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<BaseInfo> {
|
||||
*/
|
||||
Long maxUserAccount(Long start, Long end);
|
||||
|
||||
List<BaseInfo> pageQuery(UserBaseInfoPageQryCmd query);
|
||||
PageResult<BaseInfo> pageQuery(UserBaseInfoPageQryCmd query);
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
|
||||
@ -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<BaseInfoDAO, BaseInfo>
|
||||
|
||||
|
||||
@Override
|
||||
public List<BaseInfo> pageQuery(UserBaseInfoPageQryCmd query) {
|
||||
return baseInfoDAO.pageQuery(query);
|
||||
public PageResult<BaseInfo> 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
|
||||
|
||||
@ -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<UserProfile> pageListQuery(UserProfileListQryCmd query) {
|
||||
List<BaseInfo> userBaseInfos = baseInfoService.pageQuery(
|
||||
public PageResult<UserProfile> pageListQuery(UserProfileListQryCmd query) {
|
||||
PageResult<BaseInfo> 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<UserProfile> listUserProfiles(List<BaseInfo> userBaseInfos) {
|
||||
private PageResult<UserProfile> listUserProfiles(PageResult<BaseInfo> pageResult) {
|
||||
Map<Long, UserSpecialId> 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<UserProfile> collect = pageResult.getRecords().stream()
|
||||
.map(baseInfo -> mergeUserProfile(userSpecialIdMap.get(baseInfo.getId()), baseInfo))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
PageResult<UserProfile> result = new PageResult<>();
|
||||
result.setRecords(collect);
|
||||
result.setTotal(pageResult.getTotal());
|
||||
result.setCurrent(pageResult.getCurrent());
|
||||
result.setSize(pageResult.getSize());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -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<UserProfileDTO> toListUserProfileDTO(List<UserProfile> userProfiles);
|
||||
|
||||
PageResult<UserProfileDTO> toListUserProfileDTO(PageResult<UserProfile> userProfiles);
|
||||
|
||||
Map<Long, UserProfileDTO> toMapUserProfileDTO(Map<Long, UserProfile> map);
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public class UserProfileClientEndpoint implements UserProfileClientApi {
|
||||
|
||||
|
||||
@Override
|
||||
public ResultResponse<List<UserProfileDTO>> pageListQuery(UserProfileListQryCmd query) {
|
||||
public ResultResponse<PageResult<UserProfileDTO>> pageListQuery(UserProfileListQryCmd query) {
|
||||
return ResultResponse.success(userProfileClientService.pageListQuery(query));
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ public interface UserProfileClientService {
|
||||
/**
|
||||
* 分页查询用户资料
|
||||
*/
|
||||
List<UserProfileDTO> pageListQuery(UserProfileListQryCmd query);
|
||||
PageResult<UserProfileDTO> pageListQuery(UserProfileListQryCmd query);
|
||||
|
||||
/**
|
||||
* 获取用户资料集合.
|
||||
|
||||
@ -180,7 +180,7 @@ public class UserProfileClientServiceImpl implements UserProfileClientService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserProfileDTO> pageListQuery(UserProfileListQryCmd query) {
|
||||
public PageResult<UserProfileDTO> pageListQuery(UserProfileListQryCmd query) {
|
||||
return userProfileInnerConvertor.toListUserProfileDTO(userProfileGateway.pageListQuery(query));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user