Merge remote-tracking branch 'origin/feature/REQ-3282' into feature/REQ-3282
This commit is contained in:
commit
18445db179
@ -0,0 +1,75 @@
|
||||
package cn.axzo.orgmanax.infra.client.profile;
|
||||
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileIdentityProfilePostReq;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileIdentityResp;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfilePersonResp;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.model.IdentityPair;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* //TODO liuyang
|
||||
* 封装对person的请求
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class PersonProfileGateway {
|
||||
|
||||
private final ProfileUserProfileClient profileUserProfileClient;
|
||||
|
||||
public ProfilePersonResp getPersonProfile(Long personId) {
|
||||
return listPersonProfiles(ListPersonProfileReq.builder().id(personId).build())
|
||||
.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<ProfilePersonResp> listPersonProfiles(ListPersonProfileReq req) {
|
||||
// TODO 需要对接新的profile收口查询接口
|
||||
return profileUserProfileClient.getPersonProfiles(ImmutableList.of(req.getId()));
|
||||
}
|
||||
|
||||
public ProfileIdentityResp getIdentityProfile(Long personId, Integer identityType) {
|
||||
return listIdentityProfiles(ListIdentityProfileReq.builder()
|
||||
.personId(personId)
|
||||
.identityType(identityType)
|
||||
.build()).stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<ProfileIdentityResp> listIdentityProfiles(ListIdentityProfileReq req) {
|
||||
// TODO 需要对接新的profile收口查询接口
|
||||
ProfileIdentityProfilePostReq r = new ProfileIdentityProfilePostReq();
|
||||
r.setIdentityIds(ImmutableList.of(req.getIdentityId()));
|
||||
r.setIdentityType(req.getIdentityType());
|
||||
return profileUserProfileClient.postProfileByIdentityIdsAndIdentityTypeExcludeIsDelete(r);
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public static class ListPersonProfileReq {
|
||||
private Long id;
|
||||
private Collection<Long> ids;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public static class ListIdentityProfileReq {
|
||||
private Long personId;
|
||||
private Long identityId;
|
||||
private Integer identityType;
|
||||
private Collection<IdentityPair> identityPairs;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.orgmanax.infra.client.pudge.dto;
|
||||
package cn.axzo.orgmanax.infra.client.profile.dto.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -1,67 +0,0 @@
|
||||
package cn.axzo.orgmanax.infra.client.pudge;
|
||||
|
||||
import cn.axzo.orgmanax.infra.client.pudge.dto.IdentityPair;
|
||||
import cn.axzo.orgmanax.infra.client.pudge.dto.IdentityProfile;
|
||||
import cn.axzo.orgmanax.infra.client.pudge.dto.PersonProfile;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* //TODO liuyang
|
||||
* 封装对person的请求
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PersonProfileGateway {
|
||||
|
||||
public PersonProfile getPersonProfile(Long personId) {
|
||||
return listPersonProfiles(ListPersonProfileReq.builder().id(personId).build())
|
||||
.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<PersonProfile> listPersonProfiles(ListPersonProfileReq req) {
|
||||
// TODO
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
public IdentityProfile getIdentityProfile(Long personId, Integer identityType) {
|
||||
return listIdentityProfiles(ListIdentityProfileReq.builder()
|
||||
.personId(personId)
|
||||
.identityType(identityType)
|
||||
.build()).stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<IdentityProfile> listIdentityProfiles(ListIdentityProfileReq req) {
|
||||
// TODO
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public static class ListPersonProfileReq {
|
||||
private Long id;
|
||||
private Set<Long> ids;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public static class ListIdentityProfileReq {
|
||||
private Long personId;
|
||||
private Long identityId;
|
||||
private Integer identityType;
|
||||
private Set<IdentityPair> identityPairs;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package cn.axzo.orgmanax.infra.client.pudge.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* XXX:尽量复用 client 对这个类的定义。
|
||||
*/
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class IdentityProfile {
|
||||
private Long personId;
|
||||
private Long identityId;
|
||||
private Long identityType;
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package cn.axzo.orgmanax.infra.client.pudge.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* XXX:尽量复用 client 对这个类的定义。
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class PersonProfile {
|
||||
private Long id;
|
||||
private String phone;
|
||||
private String realName;
|
||||
private String idNumber;
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package cn.axzo.orgmanax.infra.client.pudge.enums;
|
||||
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Getter
|
||||
public enum IdentityType {
|
||||
NOT_SUPPORT(0, "NOT_SUPPORT", "无效类型"),
|
||||
WORKER(1, "WORKER", "工人"),
|
||||
WORKER_LEADER(2, "WORKER_LEADER", "班组长"),
|
||||
PRACTITIONER(3, "PRACTITIONER", "从业人员"),
|
||||
REGULATOR(4, "REGULATOR", "监管人员"),
|
||||
OPERATOR(5, "OPERATOR", "运营人员");
|
||||
|
||||
private final Integer code;
|
||||
private final String message;
|
||||
private final String desc;
|
||||
|
||||
public static IdentityType getIdentityType(Integer code) {
|
||||
IdentityType[] values = values();
|
||||
for (IdentityType item : values) {
|
||||
if (item.getCode().equals(code)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ package cn.axzo.orgmanax.infra.dao.orguser.repository;
|
||||
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.orgmanax.api.orguser.req.ListOrgUserReq;
|
||||
import cn.axzo.orgmanax.infra.client.pudge.dto.PersonProfile;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfilePersonResp;
|
||||
import cn.axzo.orgmanax.infra.dao.orguser.entity.OrgUser;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@ -61,7 +61,7 @@ public interface OrgUserQueryRepository {
|
||||
*
|
||||
* @see ListOrgUserReq#getNeedPersonProfile()
|
||||
*/
|
||||
private PersonProfile personProfile;
|
||||
private ProfilePersonResp personProfile;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,8 +4,8 @@ import cn.axzo.foundation.dao.support.converter.PageConverter;
|
||||
import cn.axzo.foundation.dao.support.mysql.QueryWrapperHelper;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.orgmanax.api.orguser.req.ListOrgUserReq;
|
||||
import cn.axzo.orgmanax.infra.client.pudge.PersonProfileGateway;
|
||||
import cn.axzo.orgmanax.infra.client.pudge.dto.PersonProfile;
|
||||
import cn.axzo.orgmanax.infra.client.profile.PersonProfileGateway;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfilePersonResp;
|
||||
import cn.axzo.orgmanax.infra.dao.orguser.dao.OrgUserDao;
|
||||
import cn.axzo.orgmanax.infra.dao.orguser.entity.OrgUser;
|
||||
import cn.axzo.orgmanax.infra.dao.orguser.repository.OrgUserQueryRepository;
|
||||
@ -57,9 +57,9 @@ public class OrgUserQueryRepositoryImpl implements OrgUserQueryRepository {
|
||||
return;
|
||||
}
|
||||
Set<Long> personIds = records.stream().map(OrgUser::getPersonId).collect(Collectors.toSet());
|
||||
Map<Long, PersonProfile> personsById = profileGateway.listPersonProfiles(PersonProfileGateway.ListPersonProfileReq.builder()
|
||||
Map<Long, ProfilePersonResp> personsById = profileGateway.listPersonProfiles(PersonProfileGateway.ListPersonProfileReq.builder()
|
||||
.ids(personIds)
|
||||
.build()).stream().collect(Collectors.toMap(PersonProfile::getId, Function.identity()));
|
||||
.build()).stream().collect(Collectors.toMap(ProfilePersonResp::getId, Function.identity()));
|
||||
|
||||
records.forEach(r -> r.setPersonProfile(personsById.get(r.getPersonId())));
|
||||
}
|
||||
|
||||
@ -4,9 +4,9 @@ import cn.axzo.foundation.event.support.Event;
|
||||
import cn.axzo.foundation.event.support.producer.EventProducer;
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||
import cn.axzo.orgmanax.infra.client.pudge.PersonProfileGateway;
|
||||
import cn.axzo.orgmanax.infra.client.pudge.dto.IdentityProfile;
|
||||
import cn.axzo.orgmanax.infra.client.pudge.dto.PersonProfile;
|
||||
import cn.axzo.orgmanax.infra.client.profile.PersonProfileGateway;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileIdentityResp;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfilePersonResp;
|
||||
import cn.axzo.orgmanax.infra.dao.cooperateship.repository.CooperateShipQueryRepository;
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import cn.axzo.orgmanax.infra.dao.node.repository.NodeQueryRepository;
|
||||
@ -57,17 +57,17 @@ public class NodeUserFoundationServiceImpl implements NodeUserFoundationService
|
||||
.orElseThrow(() -> BizResultCode.ENTITY_NOT_FOUND.toException("部门不存在{}", param.getNodeId()));
|
||||
|
||||
// 人是否存在
|
||||
PersonProfile personProfile = profileGateway.getPersonProfile(param.getPersonId());
|
||||
ProfilePersonResp personProfile = profileGateway.getPersonProfile(param.getPersonId());
|
||||
Axssert.checkNonNull(personProfile, "用户不存在");
|
||||
// 人员身份是否存在
|
||||
IdentityProfile identityProfile = profileGateway.getIdentityProfile(param.getPersonId(), param.getIdentityType());
|
||||
ProfileIdentityResp identityProfile = profileGateway.getIdentityProfile(param.getPersonId(), param.getIdentityType());
|
||||
Axssert.checkNonNull(personProfile, "用户身份不存在");
|
||||
|
||||
// 转换为领域对象
|
||||
// 持久化 -> mapstruct?
|
||||
OrganizationalNodeUser nodeUser = param.toEntity();
|
||||
// assemble person info
|
||||
nodeUser.setIdentityId(identityProfile.getIdentityId());
|
||||
nodeUser.setIdentityId(identityProfile.getId());
|
||||
nodeUser.setPhone(personProfile.getPhone());
|
||||
nodeUser.setRealName(personProfile.getRealName());
|
||||
nodeUser.setIdNumber(personProfile.getIdNumber());
|
||||
@ -110,16 +110,16 @@ public class NodeUserFoundationServiceImpl implements NodeUserFoundationService
|
||||
NodeUserUpsertRepository.UpdateReq updateReq = BeanUtil.toBean(req, NodeUserUpsertRepository.UpdateReq.class);
|
||||
// 刷新用户基本资料
|
||||
if (BooleanUtil.isTrue(req.getRefreshPersonProfile())) {
|
||||
PersonProfile personProfile = profileGateway.getPersonProfile(dbNodeUser.getPersonId());
|
||||
ProfilePersonResp personProfile = profileGateway.getPersonProfile(dbNodeUser.getPersonId());
|
||||
Axssert.checkNonNull(personProfile, "用户不存在");
|
||||
// 人员身份是否存在
|
||||
IdentityProfile identityProfile = profileGateway.getIdentityProfile(dbNodeUser.getPersonId(), dbNodeUser.getIdentityType());
|
||||
ProfileIdentityResp identityProfile = profileGateway.getIdentityProfile(dbNodeUser.getPersonId(), dbNodeUser.getIdentityType());
|
||||
Axssert.checkNonNull(personProfile, "用户身份不存在");
|
||||
|
||||
// 转换为领域对象
|
||||
// 持久化 -> mapstruct?
|
||||
// assemble person info
|
||||
updateReq.setIdentityId(identityProfile.getIdentityId());
|
||||
updateReq.setIdentityId(identityProfile.getId());
|
||||
updateReq.setPhone(personProfile.getPhone());
|
||||
updateReq.setRealName(personProfile.getRealName());
|
||||
updateReq.setIdNumber(personProfile.getIdNumber());
|
||||
|
||||
@ -191,4 +191,6 @@ public class CreateUnitReq {
|
||||
*/
|
||||
private Long operatorId;
|
||||
|
||||
private Boolean createWorkspace;
|
||||
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import cn.axzo.orgmanax.server.unit.service.dto.CreateUnitResp;
|
||||
import cn.axzo.orgmanax.server.unit.service.dto.UpdateUnitReq;
|
||||
import cn.axzo.orgmanax.server.unit.service.dto.UpdateUnitResp;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -54,6 +55,10 @@ public class UnitServiceImpl implements UnitService {
|
||||
nodeCreate.setExtra(null);
|
||||
nodeCreate.setProfile(null);
|
||||
|
||||
if (BooleanUtil.isTrue(req.getCreateWorkspace())){
|
||||
// TODO: 创建租户 @liuyang
|
||||
}
|
||||
|
||||
// 创建部门
|
||||
nodeService.process(ProcessNodeReq
|
||||
.builder()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user