From e9df734daeefd824d2d8ef3d8d9715da0866e75b Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 8 Sep 2025 13:51:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=94=A8=E6=88=B7):=20=E6=96=B0=E5=A2=9EB?= =?UTF-8?q?D=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/team/TeamBdRestController.java | 19 +++- .../app/command/team/query/BdListQryExe.java | 87 +++++++++++++++ .../app/service/team/TeamBdServiceImpl.java | 25 +++-- .../app/dto/clientobject/team/BdPageCO.java | 100 ++++++++++++++++++ .../other/app/service/team/TeamBdService.java | 15 ++- 5 files changed, 225 insertions(+), 21 deletions(-) create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/BdListQryExe.java create mode 100644 rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdPageCO.java diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java index 5d39e57f..724c036d 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java @@ -2,12 +2,9 @@ package com.red.circle.other.adapter.app.team; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.app.AppFlowCmd; +import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.web.controller.BaseController; -import com.red.circle.other.app.dto.clientobject.team.BdAgentCountCO; -import com.red.circle.other.app.dto.clientobject.team.BdInviteMessageCO; -import com.red.circle.other.app.dto.clientobject.team.EntryBdCO; -import com.red.circle.other.app.dto.clientobject.team.TeamDbAgentMemberCO; -import com.red.circle.other.app.dto.clientobject.team.TeamDbMemberCO; +import com.red.circle.other.app.dto.clientobject.team.*; import com.red.circle.other.app.dto.cmd.team.BdInviteQryCmd; import com.red.circle.other.app.dto.cmd.team.DbInviteAgentCmd; import com.red.circle.other.app.dto.cmd.team.DbInviteMessageProcessCmd; @@ -15,6 +12,10 @@ import com.red.circle.other.app.dto.cmd.team.DbLeaderInviteBdCmd; import com.red.circle.other.app.service.team.TeamBdService; import com.red.circle.other.infra.database.mongo.entity.team.bd.MessageInviteGroup; import java.util.List; + +import com.red.circle.other.inner.model.cmd.team.bd.BdTeamPageQryCmd; +import com.red.circle.other.inner.model.dto.agency.bd.BdTeamInfoDTO; +import com.red.circle.other.inner.model.dto.agency.bd.BdTeamMemberDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; @@ -210,4 +211,12 @@ public class TeamBdRestController extends BaseController { teamBdService.processBdInviteMessage(cmd); } + /** + * BD 列表接口 + */ + @GetMapping("/page") + public PageResult bdPage(BdTeamPageQryCmd qryCmd) { + return teamBdService.bdPage(qryCmd); + } + } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/BdListQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/BdListQryExe.java new file mode 100644 index 00000000..b54fba37 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/BdListQryExe.java @@ -0,0 +1,87 @@ +package com.red.circle.other.app.command.team.query; + +import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.framework.dto.PageResult; +import com.red.circle.other.app.dto.clientobject.team.BdPageCO; +import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentBaseInfo; +import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; +import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService; +import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; +import com.red.circle.other.inner.model.cmd.team.bd.BdTeamPageQryCmd; +import com.red.circle.other.inner.model.dto.agency.bd.BdTeamInfoDTO; +import com.red.circle.other.inner.model.dto.user.UserProfileDTO; +import com.red.circle.tool.core.collection.CollectionUtils; +import com.red.circle.tool.core.text.StringUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Component; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Component +@RequiredArgsConstructor +public class BdListQryExe { + + private final BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService; + private final UserProfileClient userProfileClient; + private final AdministratorService administratorService; + + public PageResult pageResult(BdTeamPageQryCmd qryCmd) { + boolean b = administratorService.existsAdmin(qryCmd.getUserId()); + if(!b) { + ResponseAssert.failure(CommonErrorCode.OPERATING_FAILURE); + } + + PageResult pageResult = businessDevelopmentBaseInfoService.query() + .eq(Objects.nonNull(qryCmd.getUserId()), BusinessDevelopmentBaseInfo::getUserId, + qryCmd.getUserId()) + .eq(StringUtils.isNotBlank(qryCmd.getRegion()), BusinessDevelopmentBaseInfo::getRegion, + qryCmd.getRegion()) + .eq(StringUtils.isNotBlank(qryCmd.getSysOrigin()), + BusinessDevelopmentBaseInfo::getSysOrigin, + qryCmd.getSysOrigin()) + .eq(Objects.nonNull(qryCmd.getCreateUser()), BusinessDevelopmentBaseInfo::getCreateUser, + qryCmd.getCreateUser()) + .eq(Objects.nonNull(qryCmd.getBdLeadUserId()), + BusinessDevelopmentBaseInfo::getBdLeadUserId, qryCmd.getBdLeadUserId()) + .orderByDesc(BusinessDevelopmentBaseInfo::getCreateTime) + .page(qryCmd.getPageQuery()); + + if ( pageResult == null ) { + return null; + } + + Set userIds = getUserIds(pageResult.getRecords()); + Map userMap = userProfileClient.mapByUserIds(userIds).getBody(); + + return pageResult.convert(info -> new BdPageCO() + .setId(info.getId()) + .setSysOrigin(info.getSysOrigin()) + .setUserId(info.getUserId()) + .setUserProfile(userMap.get(info.getUserId())) + .setAgentCount(info.getMemberQuantity()) + .setBdLeadUserId(info.getBdLeadUserId()) + .setBdLeadUserProfile(userMap.get(info.getBdLeadUserId())) + .setContact(info.getContact()) + .setRegion(info.getRegion()) + .setCreateTime(info.getCreateTime()) + .setUpdateTime(info.getUpdateTime())); + } + + private Set getUserIds(Collection bdList) { + return Stream.of( + bdList.stream() + .map(BusinessDevelopmentBaseInfo::getUserId) + .collect(Collectors.toSet()), + bdList.stream() + .map(BusinessDevelopmentBaseInfo::getBdLeadUserId) + .collect(Collectors.toSet())) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + } + +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/team/TeamBdServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/team/TeamBdServiceImpl.java index 1ab29e80..346a1604 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/team/TeamBdServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/team/TeamBdServiceImpl.java @@ -2,27 +2,24 @@ package com.red.circle.other.app.service.team; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.app.AppFlowCmd; -import com.red.circle.other.app.command.team.query.BdAgentCountQryExe; -import com.red.circle.other.app.command.team.query.BdCheckQryExe; -import com.red.circle.other.app.command.team.query.BdInviteMessageQryExe; -import com.red.circle.other.app.command.team.query.BdLeadBdFlowQryExe; -import com.red.circle.other.app.command.team.query.BdRoleQryExe; -import com.red.circle.other.app.command.team.query.BdTeamAgentListQryExe; +import com.red.circle.framework.dto.PageResult; +import com.red.circle.other.app.command.team.query.*; import com.red.circle.other.app.command.team.BdAgentInviteExe; import com.red.circle.other.app.command.team.BdEnterSysExe; import com.red.circle.other.app.command.team.BdInviteMessageProcessExe; import com.red.circle.other.app.command.team.BdLeaderInviteBdExe; import com.red.circle.other.app.command.team.BdLeaderInviteMessageProcessExe; -import com.red.circle.other.app.dto.clientobject.team.BdAgentCountCO; -import com.red.circle.other.app.dto.clientobject.team.BdInviteMessageCO; -import com.red.circle.other.app.dto.clientobject.team.EntryBdCO; -import com.red.circle.other.app.dto.clientobject.team.TeamDbAgentMemberCO; -import com.red.circle.other.app.dto.clientobject.team.TeamDbMemberCO; +import com.red.circle.other.app.dto.clientobject.team.*; import com.red.circle.other.app.dto.cmd.team.BdInviteQryCmd; import com.red.circle.other.app.dto.cmd.team.DbInviteAgentCmd; import com.red.circle.other.app.dto.cmd.team.DbInviteMessageProcessCmd; import com.red.circle.other.app.dto.cmd.team.DbLeaderInviteBdCmd; import java.util.List; + +import com.red.circle.other.inner.endpoint.team.bd.api.BdTeamInfoClientApi; +import com.red.circle.other.inner.model.cmd.team.bd.BdTeamPageQryCmd; +import com.red.circle.other.inner.model.dto.agency.bd.BdTeamInfoDTO; +import com.red.circle.other.inner.model.dto.agency.bd.BdTeamMemberDTO; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -46,6 +43,7 @@ public class TeamBdServiceImpl implements TeamBdService { private final BdLeaderInviteBdExe bdLeaderInviteBdCmdExe; private final BdInviteMessageProcessExe bdInviteMessageProcessCmdExe; private final BdLeaderInviteMessageProcessExe bdLeaderInviteMessageProcessCmdExe; + private final BdListQryExe bdListQryExe; @Override public String getBdRole(AppExtCommand cmd) { @@ -106,4 +104,9 @@ public class TeamBdServiceImpl implements TeamBdService { public void processBdInviteMessage(DbInviteMessageProcessCmd cmd) { bdInviteMessageProcessCmdExe.execute(cmd); } + + @Override + public PageResult bdPage(BdTeamPageQryCmd qryCmd) { + return bdListQryExe.pageResult(qryCmd); + } } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdPageCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdPageCO.java new file mode 100644 index 00000000..a694f408 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdPageCO.java @@ -0,0 +1,100 @@ +package com.red.circle.other.app.dto.clientobject.team; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.red.circle.framework.dto.ClientObject; +import com.red.circle.other.inner.model.dto.user.UserProfileDTO; +import java.io.Serial; +import java.sql.Timestamp; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * BD信息表. + *

+ * + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class BdPageCO extends ClientObject { + + @Serial + private static final long serialVersionUID = 1L; + /** + * 主键标识. + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 来源app. + */ + private String sysOrigin; + + /** + * 用户id. + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long userId; + + /** + * 代理数量. + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long agentCount; + + /** + * 用户基本信息. + */ + private UserProfileDTO userProfile; + + /** + * bd lead. + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long bdLeadUserId; + + /** + * bd lead 用户基本信息. + */ + private UserProfileDTO bdLeadUserProfile; + + /** + * 创建人. + */ + private String createUserName; + + /** + * 修改人. + */ + private String updateUserName; + + /** + * 联系方式. + */ + private String contact; + + /** + * 区域. + */ + private String region; + + /** + * 区域名称. + */ + private String regionName; + + /** + * 创建时间. + */ + private Timestamp createTime; + + /** + * 修改时间. + */ + private Timestamp updateTime; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/team/TeamBdService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/team/TeamBdService.java index 607c406a..1958fb22 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/team/TeamBdService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/team/TeamBdService.java @@ -2,15 +2,16 @@ package com.red.circle.other.app.service.team; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.app.AppFlowCmd; -import com.red.circle.other.app.dto.clientobject.team.BdAgentCountCO; -import com.red.circle.other.app.dto.clientobject.team.BdInviteMessageCO; -import com.red.circle.other.app.dto.clientobject.team.EntryBdCO; -import com.red.circle.other.app.dto.clientobject.team.TeamDbAgentMemberCO; -import com.red.circle.other.app.dto.clientobject.team.TeamDbMemberCO; +import com.red.circle.framework.dto.PageResult; +import com.red.circle.other.app.dto.clientobject.team.*; import com.red.circle.other.app.dto.cmd.team.BdInviteQryCmd; import com.red.circle.other.app.dto.cmd.team.DbInviteAgentCmd; import com.red.circle.other.app.dto.cmd.team.DbInviteMessageProcessCmd; import com.red.circle.other.app.dto.cmd.team.DbLeaderInviteBdCmd; +import com.red.circle.other.inner.model.cmd.team.bd.BdTeamPageQryCmd; +import com.red.circle.other.inner.model.dto.agency.bd.BdTeamInfoDTO; +import com.red.circle.other.inner.model.dto.agency.bd.BdTeamMemberDTO; + import java.util.List; /** @@ -80,4 +81,8 @@ public interface TeamBdService { */ void processBdInviteMessage(DbInviteMessageProcessCmd cmd); + /** + * bd列表 + */ + PageResult bdPage(BdTeamPageQryCmd qryCmd); }