|
@@ -3,15 +3,23 @@ package com.ims.eval.service.impl;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.ims.common.utils.StringUtils;
|
|
|
+import com.ims.eval.config.ImaConfig;
|
|
|
import com.ims.eval.entity.OrganizationStructure;
|
|
|
import com.ims.eval.dao.OrganizationStructureMapper;
|
|
|
-import com.ims.eval.entity.custom.Menu;
|
|
|
import com.ims.eval.feign.RemoteServiceBuilder;
|
|
|
import com.ims.eval.service.IOrganizationStructureService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -26,6 +34,7 @@ import java.util.stream.Collectors;
|
|
|
* @since 2023-03-01
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class OrganizationStructureServiceImpl extends ServiceImpl<OrganizationStructureMapper, OrganizationStructure> implements IOrganizationStructureService {
|
|
|
|
|
|
private static Integer length = 0;
|
|
@@ -35,6 +44,12 @@ public class OrganizationStructureServiceImpl extends ServiceImpl<OrganizationSt
|
|
|
@Autowired
|
|
|
private RemoteServiceBuilder remoteServiceBuilder;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ImaConfig imaConfig;
|
|
|
+
|
|
|
private List<OrganizationStructure> list = new ArrayList<>();
|
|
|
|
|
|
@Override
|
|
@@ -62,6 +77,33 @@ public class OrganizationStructureServiceImpl extends ServiceImpl<OrganizationSt
|
|
|
return tr;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<OrganizationStructure> getList(String likeParentId, String parentId, String name,String type, HttpServletRequest request) {
|
|
|
+
|
|
|
+
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
+ headers.add("Blade-Auth", request.getHeader("Blade-Auth"));
|
|
|
+
|
|
|
+ HttpEntity<Map> param = new HttpEntity<>(null, headers);
|
|
|
+ ResponseEntity<String> responseEntity2 = restTemplate.postForEntity(imaConfig.getGatewayUrl() +"ims-iam-ext/sys/sysOrg/allDataNoControl?likeParentId={1}&parentId={2}&name={3}",
|
|
|
+ param, String.class, likeParentId, parentId,name);
|
|
|
+
|
|
|
+ log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
+ if(200== responseEntity2.getStatusCodeValue()){
|
|
|
+
|
|
|
+ JSONArray arr = JSONArray.parseArray(responseEntity2.getBody());
|
|
|
+ List<OrganizationStructure> list = arr.toJavaList(OrganizationStructure.class);
|
|
|
+ if(StringUtils.isNotEmpty(type)){
|
|
|
+ list = list.stream().filter(OrganizationStructure -> OrganizationStructure.getType().equals(type))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 转换为有树形结构的列表
|
|
|
*
|