feat(用户): 新增BD列表接口
This commit is contained in:
parent
a8207f7272
commit
e9df734dae
@ -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<BdPageCO> bdPage(BdTeamPageQryCmd qryCmd) {
|
||||
return teamBdService.bdPage(qryCmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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<BdPageCO> pageResult(BdTeamPageQryCmd qryCmd) {
|
||||
boolean b = administratorService.existsAdmin(qryCmd.getUserId());
|
||||
if(!b) {
|
||||
ResponseAssert.failure(CommonErrorCode.OPERATING_FAILURE);
|
||||
}
|
||||
|
||||
PageResult<BusinessDevelopmentBaseInfo> 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<Long> userIds = getUserIds(pageResult.getRecords());
|
||||
Map<Long, UserProfileDTO> 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<Long> getUserIds(Collection<BusinessDevelopmentBaseInfo> 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());
|
||||
}
|
||||
|
||||
}
|
||||
@ -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<BdPageCO> bdPage(BdTeamPageQryCmd qryCmd) {
|
||||
return bdListQryExe.pageResult(qryCmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* BD信息表.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
@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;
|
||||
|
||||
}
|
||||
@ -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<BdPageCO> bdPage(BdTeamPageQryCmd qryCmd);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user