Commit ebd4ba94 authored by zhangch's avatar zhangch

适用机构的feignService接口

parent f37191ca
package com.hungraim.ltc.api;
import com.hungraim.ltc.util.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
@FeignClient("LTC-APPLY-SERVICE")
public interface OrganFeignService {
/**
* 根据organId以及isInvolveChild返回一个organIds集合
* 返回一个好办organId的ids集合,如果isInvolveChild的值为true,则包含organId的下层机构,如果为false,就只返回只存在organId的ids集合
*
* @param organId 适用机构id
* @param isInvolveChild 是否包含下层机构
* @return 返回一个ids集合
*/
@GetMapping("/api.apply/organ/child")
Result<List<Long>> getOrganChild(Long organId, Boolean isInvolveChild);
}
package com.hungraim.ltc.controller;
import com.hungraim.ltc.service.OrganService;
import com.hungraim.ltc.util.Result;
import com.hungraim.ltc.util.ResultCode;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api.apply/organ")
@AllArgsConstructor
public class OrganController {
private final OrganService organService;
/**
* 根据organId以及isInvolveChild返回一个organIds集合
* 返回一个好办organId的ids集合,如果isInvolveChild的值为true,则包含organId的下层机构,如果为false,就只返回只存在organId的ids集合
*
* @param organId 适用机构id
* @param isInvolveChild 是否包含下层机构
* @return 返回一个ids集合
*/
@GetMapping("/child")
public Result<List<Long>> getOrganChild(Long organId, Boolean isInvolveChild) {
if (null == organId || null == isInvolveChild) {
return Result.failed(ResultCode.REQUEST_PARAM_ERROR);
}
return Result.success(organService.getOrganIds(organId, isInvolveChild));
}
}
...@@ -16,21 +16,44 @@ public class OrganServiceImpl implements OrganService { ...@@ -16,21 +16,44 @@ public class OrganServiceImpl implements OrganService {
private final FndOrganMapper fndOrganMapper; private final FndOrganMapper fndOrganMapper;
/**
* 获取机构ids
*
* @param organId 父机构id
* @param organIds 机构list
*/
private void getOrganList(Long organId, List<Long> organIds) {
QueryWrapper<ChFndOrgan> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("STATUS", "1");
queryWrapper.eq("PARENT_ID", organId);
List<ChFndOrgan> organs = fndOrganMapper.selectList(queryWrapper);
if (organs != null && organs.size() != 0) {
for (ChFndOrgan chFndOrgan : organs) {
String childOrganId = chFndOrgan.getOrganId();
organIds.add(Long.valueOf(childOrganId));
if ("1".equals(chFndOrgan.getIsLeaf())) {
getOrganList(Long.valueOf(childOrganId), organIds);
}
}
}
}
@Override @Override
public List<Long> getOrganIds(Long organId, Boolean isInvolveChild) { public List<Long> getOrganIds(Long organId, Boolean isInvolveChild) {
List<Long> organIds = new ArrayList<>(); List<Long> organIds = new ArrayList<>();
if (isInvolveChild) { if (isInvolveChild) {
if (organId != null) { if (organId != null) {
organIds.add(organId); organIds.add(organId);
QueryWrapper<ChFndOrgan> queryWrapper = new QueryWrapper<>(); getOrganList(organId, organIds);
queryWrapper.eq("PARENT_ID", organId); // QueryWrapper<ChFndOrgan> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("STATUS", "1"); // queryWrapper.eq("PARENT_ID", organId);
List<ChFndOrgan> chFndOrgans = fndOrganMapper.selectList(queryWrapper); // queryWrapper.eq("STATUS", "1");
if (chFndOrgans != null) { // List<ChFndOrgan> chFndOrgans = fndOrganMapper.selectList(queryWrapper);
for (ChFndOrgan chFndOrgan : chFndOrgans) { // if (chFndOrgans != null) {
organIds.add(Long.valueOf(chFndOrgan.getOrganId())); // for (ChFndOrgan chFndOrgan : chFndOrgans) {
} // organIds.add(Long.valueOf(chFndOrgan.getOrganId()));
} // }
// }
} }
} }
return organIds; return organIds;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment