feat(REQ-3136): 提供三方项目人员查询接口 step2 提供实现

This commit is contained in:
周敏 2024-10-30 10:26:19 +08:00
parent 84c278533a
commit 40d18046cb
4 changed files with 72 additions and 7 deletions

View File

@ -0,0 +1,12 @@
###
POST localhost:8080/api/thirdPart/listProjectPeople
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJOVF9PTVNfV0VCOjkwMDA0MDAzMjIiLCJyblN0ciI6IndWbXF6d1VYWG5sZ2lHRm1MRmpHVXdzdGVac0xrbkpnIn0.fapfkozDj51dA2lFmCmIkv7ZFaLVOFGzn6OAyvndW1c
{
"thirdCode": "taizhou",
"thirdProjectId": "Jh0Cj4e%2BJhtDDYYdhmkV0flbxjUPOZXzS4z%2BAXKMf%2B8=",
"thirdUniquePersonIds": [],
"needThirdPerson": true
}

View File

@ -12,8 +12,10 @@ import lombok.NoArgsConstructor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid;
import java.util.List;
import java.util.Set;
@ -40,6 +42,6 @@ public interface ThirdPartPersonApi {
* @param param
* @return
*/
@PostMapping("/api/thirdPart/listPerson")
ApiResult<List<ThirdProjectPersonRes>> listThirdProjectPeople(ListThirdProjectPeopleReq param);
@PostMapping("/api/thirdPart/listProjectPeople")
ApiResult<List<ThirdProjectPersonRes>> listThirdProjectPeople(@RequestBody @Valid ListThirdProjectPeopleReq param);
}

View File

@ -5,6 +5,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Set;
@ -17,10 +18,12 @@ public class ListThirdProjectPeopleReq implements Serializable {
/**
* 三方名称code
*/
@NotBlank(message = "thirdCode不能为空")
private String thirdCode;
/**
* '三方项目编号'
*/
@NotBlank(message = "thirdProjectId不能为空")
private String thirdProjectId;
/**
* 三方人员唯一ID

View File

@ -1,18 +1,30 @@
package cn.axzo.riven.third.controller;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.riven.client.common.enums.ThirdCodeEnum;
import cn.axzo.riven.client.feign.ThirdPartPersonApi;
import cn.axzo.riven.client.req.ListThirdProjectPeopleReq;
import cn.axzo.riven.client.res.ThirdPartPersonRes;
import cn.axzo.riven.client.res.ThirdPersonRes;
import cn.axzo.riven.client.res.ThirdProjectPersonRes;
import cn.axzo.riven.third.dao.ThirdPersonDao;
import cn.axzo.riven.third.dao.ThirdProjectPersonDao;
import cn.axzo.riven.third.entity.ThirdPerson;
import cn.axzo.riven.third.entity.ThirdProjectPerson;
import cn.axzo.riven.third.service.ThirdPersonService;
import com.google.common.collect.ImmutableList;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author zhongpeng
@ -23,18 +35,54 @@ import java.util.List;
public class ThirdPartPersonController implements ThirdPartPersonApi {
private final ThirdPersonService thirdPersonService;
private final ThirdProjectPersonDao thirdProjectPersonDao;
private final ThirdPersonDao thirdPersonDao;
@Override
public ApiResult<ThirdPartPersonRes> getThirdPartPerson(Long personId, ThirdCodeEnum thirdCode) {
ThirdPartPersonRes thirdPartPersonRes = thirdPersonService.getThirdPartPerson(personId,thirdCode);
ThirdPartPersonRes thirdPartPersonRes = thirdPersonService.getThirdPartPerson(personId, thirdCode);
return ApiResult.ok(thirdPartPersonRes);
}
@Override
public ApiResult<List<ThirdProjectPersonRes>> listThirdProjectPeople(ListThirdProjectPeopleReq param) {
// TODO
return ApiResult.ok(ImmutableList.of());
List<ThirdProjectPersonRes> result = thirdProjectPersonDao.lambdaQuery()
.eq(ThirdProjectPerson::getThirdCode, param.getThirdCode())
.eq(ThirdProjectPerson::getThirdProjectId, param.getThirdProjectId())
.in(CollUtil.isNotEmpty(param.getThirdUniquePersonIds()), ThirdProjectPerson::getThirdUniquePersonId, param.getThirdUniquePersonIds())
.eq(ThirdProjectPerson::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.list()
.stream().map(e -> BeanUtil.toBean(e, ThirdProjectPersonRes.class))
.collect(Collectors.toList());
assembleThirdPersonIfNeed(result, param);
return ApiResult.ok(result);
}
private void assembleThirdPersonIfNeed(List<ThirdProjectPersonRes> result, ListThirdProjectPeopleReq param) {
if (result.isEmpty()) {
return;
}
if (!BooleanUtil.isTrue(param.getNeedThirdPerson())) {
return;
}
Set<String> thirdPersonIds = result.stream()
.map(ThirdProjectPersonRes::getThirdUniquePersonId)
.filter(StrUtil::isNotBlank)
.collect(Collectors.toSet());
if (thirdPersonIds.isEmpty()) {
return;
}
Map<String, ThirdPerson> thirdPersonMap = thirdPersonDao.lambdaQuery()
.eq(ThirdPerson::getThirdCode, param.getThirdCode())
.in(ThirdPerson::getThirdUniquePersonId, thirdPersonIds)
.eq(ThirdPerson::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.list().stream()
.collect(Collectors.toMap(ThirdPerson::getThirdUniquePersonId, Function.identity()));
result.forEach(t -> {
ThirdPerson thirdPerson = thirdPersonMap.get(t.getThirdUniquePersonId());
t.setThirdPersonRes(thirdPerson == null ? null : BeanUtil.toBean(thirdPerson, ThirdPersonRes.class));
});
}
}