package com.hotent.portal.controller;

import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.hotent.base.enums.ResponseErrorEnums;
import com.hotent.base.feign.UCFeignService;
import com.hotent.base.query.PageBean;
import com.hotent.base.query.PageList;
import com.hotent.base.query.QueryFilter;
import com.hotent.base.query.QueryOP;
import com.hotent.base.util.*;
import com.hotent.sys.persistence.model.SysAuthUser;
import com.hotent.uc.api.impl.model.Org;
import com.hotent.uc.api.impl.model.Role;
import com.hotent.uc.api.impl.model.UserFacade;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hotent.base.annotation.ApiGroup;
import com.hotent.base.constants.ApiGroupConsts;
import com.hotent.base.controller.BaseController;
import com.hotent.base.model.CommonResult;
import com.hotent.portal.params.SaveRightsVo;
import com.hotent.sys.persistence.manager.SysAuthUserManager;
import com.hotent.uc.api.impl.util.ContextUtil;
import com.hotent.uc.api.impl.util.PermissionCalc;
import com.hotent.uc.api.model.IUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 
 * 
 * @company 广州宏天软件股份有限公司
 * @author zhangxianwen
 * @email zhangxw@jee-soft.cn
 * @date 2018年7月9日
 */
@SuppressWarnings("rawtypes")
@RestController
@RequestMapping("/sys/authUser/v1/")
@Api(tags="通用权限设置")
@ApiGroup(group= {ApiGroupConsts.GROUP_PORTAL})
public class SysAuthUserController extends BaseController {
	@Resource
	SysAuthUserManager sysAuthUserManager;
	@Resource
	PermissionCalc permssionCalc;

	@Resource
	UCFeignService ucFeignService;

	@RequestMapping(value="getRights", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "获取权限", httpMethod = "GET", notes = "获取权限")
	public  ArrayNode getRights(
			@ApiParam(name="id",value="id")@RequestParam  String id,
			@ApiParam(name="objType",value="objType")@RequestParam  String objType) throws Exception {
		try {
			return sysAuthUserManager.getRights(id, objType);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	@RequestMapping(value="getRightsAndDefaultRightType", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "获取权限和系统默认的权限类型", httpMethod = "GET", notes = "获取权限和系统默认的权限类型")
	public  Map<String, Object> getRightsAndDefaultRightType(
			@ApiParam(name="id",value="id")@RequestParam  String id,
			@ApiParam(name="objType",value="objType")@RequestParam  String objType) throws Exception {
		try {
			Map<String, Object> result = new HashMap<>();
			result.put("right", sysAuthUserManager.getRights(id, objType));
			result.put("type", AppUtil.getBean("defaultObjectRightType"));
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	@RequestMapping(value="saveRights", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "保存权限", httpMethod = "POST", notes = "保存节点json 配置")
	public CommonResult<String> saveRights(@ApiParam(name="vo",value="节点保存对象")@RequestBody SaveRightsVo rightsVo) throws Exception {
		String[] saveRightsIds = rightsVo.getId().split(",");
		String objType = rightsVo.getObjType();
		String ownerNameJson = rightsVo.getOwnerNameJson();
		try {
			for(int i = 0; i < saveRightsIds.length; i++) {
				sysAuthUserManager.saveRights(saveRightsIds[i], objType, ownerNameJson);
			}
			IUser currentUser = ContextUtil.getCurrentUser();
			sysAuthUserManager.delUserMenuCache(currentUser.getUserId());
            sysAuthUserManager.delUserMenu();
			return new CommonResult<String>("保存成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new CommonResult<String>(false,"保存权限失败"+e.getMessage());
		}
	}

	@RequestMapping(value="saveAppAuthOnlyPart", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "保存应用权限(仅部分更新)", httpMethod = "POST", notes = "保存应用权限(仅部分更新)")
	public CommonResult<String> saveAppAuthOnlyPart(@ApiParam(name="json", value="应用授权json", required = true)@RequestBody String json) throws Exception {
		JSONObject jsonObj = JSONUtil.parseObj(json);
		String appId = jsonObj.getStr("appId");
		String type = jsonObj.getStr("type");
		String ids = jsonObj.getStr("ids");
		String names = jsonObj.getStr("names");
		if(StringUtil.isEmpty(appId) || StringUtil.isEmpty(type)) {
			return new CommonResult<String>("保存成功");
		}

		try {
			String objType = "app";
			LambdaQueryWrapper<SysAuthUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
			lambdaQueryWrapper.eq(SysAuthUser::getAuthorizeId, appId);
			lambdaQueryWrapper.eq(SysAuthUser::getObjType, objType);
			List<SysAuthUser> authUserList = sysAuthUserManager.getBaseMapper().selectList(lambdaQueryWrapper);
			List<String> authList = authUserList.stream()
					.filter(obj -> type.equals(obj.getRightType()))
					.map(SysAuthUser::getOwnerId)
					.collect(Collectors.toList());

			if("everyone".equals(type)) {
				if(authUserList!=null && authUserList.size()>0) {
					return new CommonResult<String>(false,"还包含有其他授权，请与管理员联系，保存失败！");
				}
				SysAuthUser defUser = new SysAuthUser();
				defUser.setId(UniqueIdUtil.getSuid());
				defUser.setAuthorizeId(appId);
				defUser.setRightType(type);
				defUser.setObjType(objType);
				sysAuthUserManager.saveOrUpdate(defUser);
			} else {
				String[] arrIds = ids.split(",");
				String[] arrNames = names.split(",");
				for (int i = 0; i < arrIds.length; i++) {
					String id = arrIds[i];
					String name = arrNames[i];
					if (!authList.contains(id)) {
						SysAuthUser defUser = new SysAuthUser();
						defUser.setId(UniqueIdUtil.getSuid());
						defUser.setAuthorizeId(appId);
						defUser.setOwnerId(id);
						defUser.setOwnerName(name);
						defUser.setRightType(type);
						defUser.setObjType(objType);
						sysAuthUserManager.saveOrUpdate(defUser);
					}
				}
			}
			IUser currentUser = ContextUtil.getCurrentUser();
			sysAuthUserManager.delUserMenuCache(currentUser.getUserId());
			sysAuthUserManager.delUserMenu();
			return new CommonResult<String>("保存成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new CommonResult<String>(false,"保存权限失败"+e.getMessage());
		}
	}

	@RequestMapping(value="delAppAuthOnlyPart", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "删除应用权限(仅部分删除)", httpMethod = "POST", notes = "删除应用权限(仅部分删除)")
	public CommonResult<String> delAppAuthOnlyPart(@ApiParam(name="json", value="应用授权json", required = true)@RequestBody String json) throws Exception {
		JSONObject jsonObj = JSONUtil.parseObj(json);
		String appId = jsonObj.getStr("appId");
		String type = jsonObj.getStr("type");
		String ids = jsonObj.getStr("ids");

		if(StringUtil.isEmpty(appId) || StringUtil.isEmpty(type)) {
			return new CommonResult<String>("保存成功");
		}

		try {
			String objType = "app";
			if("everyone".equals(type)) {
				sysAuthUserManager.delByAuthorizeIdOnlyPart(appId, "everyone", objType);
			} else {
				sysAuthUserManager.delByAuthorizeIdOnlyPart2(appId, ids, type, objType);
			}

			IUser currentUser = ContextUtil.getCurrentUser();
			sysAuthUserManager.delUserMenuCache(currentUser.getUserId());
			sysAuthUserManager.delUserMenu();
			return new CommonResult<String>("保存成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new CommonResult<String>(false,"保存权限失败"+e.getMessage());
		}
	}

	//查询应用授权 应用/组织和组织/用户/角色关系信息
	@RequestMapping(value="getAppAuthExtPage",method=RequestMethod.GET, produces = {"application/json; charset=utf-8" })
	@ApiOperation(value = "查询应用授权 应用/组织和组织/用户/角色关系信息", httpMethod = "POST", notes = "查询应用授权 应用/组织和组织/用户/角色关系信息")
	public List<Map<String, String>> getMobileAppAuthExtPage(
			@ApiParam(name="appId",value="应用id", required = true)@RequestParam(required=true) String appId,
			@ApiParam(name="orgId",value="组织id", required = true)@RequestParam(required=true) String orgId) throws Exception{
		if(StringUtil.isEmpty(orgId)) {
			return new ArrayList<Map<String, String>>();
		}

		List<Map<String, String>> result = new ArrayList<>();
		//获取当前应用的权限
		ArrayNode arrayNode = sysAuthUserManager.getRights(appId, "app");
		for (int i = 0; i < arrayNode.size(); i++) {
			JsonNode jsonNode = arrayNode.get(i);
			String type = jsonNode.get("type").textValue();
			if("everyone".equals(type)) {
				Map<String, String> map = new HashedMap();
				map.put("type", type);
				result.add(map);
			} if("role".equals(type)) {
				String ids = jsonNode.get("id").textValue();
				String names = jsonNode.get("name").textValue();
				ArrayNode array = ucFeignService.getRoleByIdsAndExtOrgId(ids, orgId);
				for (JsonNode node : array) {
					Map<String, String> map = new HashedMap();
					map.put("id", node.get("ID_").textValue());
					map.put("code", node.get("CODE_").textValue());
					map.put("name", node.get("NAME_").textValue());
					map.put("orgId", node.get("ORG_ID_").textValue());
					map.put("orgName", node.get("ORG_NAME_").textValue());
					map.put("orgPath", node.get("ORG_PATH_").textValue());
					map.put("type", type);
					result.add(map);
				}
			} else if("org".equals(type)) {
				String ids = jsonNode.get("id").textValue();
				String names = jsonNode.get("name").textValue();
				ArrayNode array = ucFeignService.getOrgByIdsAndCurOrgId(ids, orgId);
				for (JsonNode node : array) {
					Map<String, String> map = new HashedMap();
					map.put("id", node.get("ID_").textValue());
					map.put("code", node.get("CODE_").textValue());
					map.put("name", node.get("NAME_").textValue());
					map.put("orgId", node.get("ORG_ID_").textValue());
					map.put("orgName", node.get("ORG_NAME_").textValue());
					map.put("orgPath", node.get("ORG_PATH_").textValue());
					map.put("type", type);
					result.add(map);
				}
			} else if("user".equals(type)) {
				String ids = jsonNode.get("id").textValue();
				String names = jsonNode.get("name").textValue();
				ArrayNode array = ucFeignService.getUserByIdsAndExtOrgId(ids, orgId);
				for (JsonNode node : array) {
					Map<String, String> map = new HashedMap();
					map.put("id", node.get("ID_").textValue());
					map.put("name", node.get("FULLNAME_").textValue());
					map.put("code", node.get("ACCOUNT_").textValue());
					map.put("orgId", node.get("ORG_ID_").textValue());
					map.put("orgName", node.get("ORG_NAME_").textValue());
					map.put("orgPath", node.get("ORG_PATH_").textValue());
					map.put("type", type);
					result.add(map);
				}
			}
		}
		return result;
	}

	@PostMapping(value="batchSaveRights", produces = {"application/json; charset=utf-8" })
	@ApiOperation(value = "批量保存权限", httpMethod = "POST", notes = "保存节点json 配置")
	public CommonResult<String> batchSaveRights(@ApiParam(name="vo",value="节点保存对象")@RequestBody SaveRightsVo rightsVos) throws Exception {
		try {
			sysAuthUserManager.batchSaveRights(rightsVos.getIds(),rightsVos.getObjType(),rightsVos.getOwnerNameJson());
			IUser currentUser = ContextUtil.getCurrentUser();
			sysAuthUserManager.delUserMenuCache(currentUser.getUserId());
            sysAuthUserManager.delUserMenu();
			return new CommonResult<String>("保存成功");
		}catch (Exception e) {
			e.printStackTrace();
			return new CommonResult<String>(false,"保存权限失败"+e.getMessage());
		}
	}

	@RequestMapping(value="getAuthorizeIdsByUserMap", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "通过objType获取当前用户权限", httpMethod = "GET", notes = "通过objType获取当前用户权限")
	public List<String> getAuthorizeIdsByUserMap(@ApiParam(name="objType",value="objType")@RequestParam String objType) throws Exception {
		return sysAuthUserManager.getAuthorizeIdsByUserMap(objType);
	}


	@RequestMapping(value="hasRights", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "判断用户对某个模块数据是否有权限", httpMethod = "GET", notes = "判断用户对某个模块数据是否有权限")
	public boolean hasRights(@ApiParam(name="authorizeId",value="authorizeId")@RequestParam String authorizeId) throws Exception {
		return sysAuthUserManager.hasRights(authorizeId);
	}
	
	@RequestMapping(value="calcPermssion", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "根据权限数据判断当前人是否有权限", httpMethod = "GET", notes = "根据权限数据判断当前人是否有权限")
	public boolean calcPermssion(@ApiParam(name="permssionJson",value="权限定义json数据")@RequestParam String permssionJson) throws Exception {
		Map<String, Set<String>>  currentMap = permssionCalc.getCurrentProfiles();
		return permssionCalc.hasRight(permssionJson, currentMap);
	}
	
	@RequestMapping(value="calcAllPermssion", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "根据权限数据批量判断当前人是否有权限", httpMethod = "GET", notes = "根据权限数据批量判断当前人是否有权限")
	public ObjectNode calcAllPermssion(@ApiParam(name="permssionJson",value="权限定义json数据")@RequestParam String permssionJson) throws Exception {
		ObjectNode res=sysAuthUserManager.calcAllPermssion(permssionJson);
		return res;
	}

	@RequestMapping(value = "getUserRightMap", method = RequestMethod.GET, produces = {"application/json;charset=utf-8"})
	@ApiOperation(value = "获取用户权限",httpMethod = "GET", notes = "获取用户权限")
	public Map<String,Set<String>> getUserRightMapStr() throws Exception{
		return sysAuthUserManager.getUserRightMap();
	}

	/**
	 * 根据应用id 获取 授权按钮信息
	 * @author: 梁宏锦
	 * @date: 2024/04/12
	 * @param appId: 应用id
	 * @param objType: 授权对象类型 app/indexColumn
	 * @param userId: 用户id
	 * @return: com.hotent.base.model.CommonResult<java.util.List<java.lang.String>>
	 **/
	@RequestMapping(value = "getUserRighBtntByAppId", method = RequestMethod.GET, produces = {"application/json;charset=utf-8"})
	@ApiOperation(value = "根据应用id 获取 授权按钮信息", httpMethod = "GET", notes = "根据应用id 获取 授权按钮信息")
	public CommonResult<List<String>> getUserRighBtntByAppId(
			@ApiParam(name="appId",value="应用id") @RequestParam("appId") String appId,
			@ApiParam(name="objType",value="授权对象类型") @RequestParam("objType") String objType,
			@ApiParam(name="userId",value="用户id") @RequestParam("userId") String userId
	) throws Exception{
		appId = (appId.indexOf('_')!=-1? appId.substring(appId.indexOf('_') + 1): appId);

		Map<String, Map<String, String>> rmap = ucFeignService.getUserRightMapByIds(userId);
		Map<String, String> userRightMap = rmap.get(userId);
		if(userRightMap.get("position")!=null) {
			userRightMap.put("pos", userRightMap.get("position"));
		}

		List<Map<String, Object>> list = sysAuthUserManager.getUserRighBtntByAppId(userRightMap, appId, objType);
		List<String> resList = list.stream().map(map -> (String)map.get("RIGHT_TYPE_")).collect(Collectors.toList());
		CommonResult<List<String>> result = new CommonResult<List<String>>(true,"查询成功");
		result.setValue(resList);
		return result;
	}

	/**
	 * 根据应用id 获取 授权信息
	 * @author: 梁宏锦
	 * @date: 2024/04/12
	 * @param appId: 应用id
	 * @param objType: 类型 app/layoutManage/indexColumn/datav
	 * @param userId: 用户id
	 * @return: java.util.Map<java.lang.String,java.lang.Object>
	 **/
	@RequestMapping(value="getRightsFullInfoByAppId", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	@ApiOperation(value = "根据应用id 获取 授权信息", httpMethod = "GET", notes = "根据应用id 获取 授权信息")
	public CommonResult<ArrayNode> getRightsFullInfoByAppId(
			@ApiParam(name="appId", value="appId")@RequestParam  String appId,
			@ApiParam(name="objType", value="objType")@RequestParam  String objType,
			@ApiParam(name="userId", value="用户id", required = false) @RequestParam(required = false) String userId) throws Exception {
		appId = (appId.indexOf('_')!=-1? appId.substring(appId.indexOf('_') + 1): appId);
		if("datav".equals(objType)) {
			//传入类型为：datav 数据匹配类型为layoutManage 转换一下
			objType = "layoutManage";
		}
		try {
			Map<String, String> userRightMap = new HashedMap();
			if(StringUtil.isNotEmpty(userId)) {
				Map<String, Map<String, String>> rmap = ucFeignService.getUserRightMapByIds(userId);
				userRightMap = rmap.get(userId);
				if(userRightMap.get("position")!=null) {
					userRightMap.put("pos", userRightMap.get("position"));
				}
				userRightMap.remove("position");
			}

			ArrayNode reusltNode = JsonUtil.createArrayNode();
			ArrayNode arrayNode = sysAuthUserManager.getRights(appId, objType);
			for (int i = 0; i < arrayNode.size() ; i++) {
				JsonNode jsonNode = arrayNode.get(i);

				String type = jsonNode.get("type").textValue();
				String title = jsonNode.get("title").textValue();

				ObjectNode objNode = JsonUtil.createObjectNode();
				objNode.put("type", type);
				objNode.put("title", title);

				if("everyone".equals(type)) {
					objNode.put("showFlag", true);
					reusltNode.add(objNode);
				} else {
					String name = jsonNode.get("name").textValue();
					String ids = jsonNode.get("id").textValue();
					objNode.put("name", name);
					objNode.put("id", ids);

					if(StringUtil.isNotEmpty(userId)) {
						String tmp = userRightMap.get(type);
						tmp = StringUtil.isEmpty(tmp) ? "" : tmp.replaceAll("'", "");
						boolean showFlag = this.hasDuplicates(tmp, ids);
						objNode.put("showFlag", showFlag);
					}

					Map<String, Object> map = this.getRightsFullInfo(type, ids);
					List<ObjectNode> rightInfoList = (List<ObjectNode>)map.get("info");
					ArrayNode RightInfoArrayNode = JsonUtil.listToArrayNode(rightInfoList);
					objNode.put("info", RightInfoArrayNode);
					reusltNode.add(objNode);
				}
			}

			CommonResult<ArrayNode> result = new CommonResult(ResponseErrorEnums.SUCCESS_OPTION);
			result.setValue(reusltNode);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	private boolean hasDuplicates(String str1, String str2) {
		List<String> list1 = Arrays.stream(str1.split(","))
				.collect(Collectors.toList());
		List<String> list2 = Arrays.stream(str2.split(","))
				.collect(Collectors.toList());

		List<String> intersection = new ArrayList<>(list1);
		intersection.retainAll(list2);
		return !intersection.isEmpty();
	}

	/**
	 * 根据用户id 获取 用户/组织/岗位/角色的完整信息
	 * @author: 梁宏锦
	 * @date: 2024/04/12
	 * @param userId: 用户id
	 * @return: java.util.Map<java.lang.String,java.lang.Object>
	 **/
	@RequestMapping(value="getUserRightInfoByUserId", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	public CommonResult<Map<String, Map<String, Object>>> getUserRightInfoByUserId(
			@ApiParam(name="userId",value="userId")@RequestParam  String userId) throws Exception {
		try {
			Map<String, Map<String, String>> rmap = ucFeignService.getUserRightMapByIds(userId);
			Map<String, String> userRightMap = rmap.get(userId);
			if(userRightMap.get("position")!=null) {
				userRightMap.put("pos", userRightMap.get("position"));
			}
			userRightMap.remove("position");

			Map<String, Map<String, Object>> result = new HashedMap();
			for (Map.Entry<String, String> entry : userRightMap.entrySet()) {
				String type = entry.getKey();
				String ids = entry.getValue();
				ids = StringUtil.isEmpty(ids)? "": ids.replaceAll("'", "");
				Map<String, Object> map = this.getRightsFullInfo(type, ids);
				result.put(type, map);
			}

			CommonResult<Map<String, Map<String, Object>>> res = new CommonResult(ResponseErrorEnums.SUCCESS_OPTION);
			res.setValue(result);
			return res;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * 根据类型和id 获取 信息
	 * @author: 梁宏锦
	 * @date: 2024/04/12
	 * @param type: 类型 role/org/pos/user
	 * @param ids: id
	 * @return: java.util.Map<java.lang.String,java.lang.Object>
	 **/
	private Map<String, Object> getRightsFullInfo(String type, String ids) {
		Map<String, Object> map = new HashedMap();
		if ("role".equals(type)) {
			List<ObjectNode> roleList = new ArrayList<>();
			List<String> idList = Arrays.asList(ids.split(","));
			for (int j = 0; j < idList.size() ; j++) {
				String id = idList.get(j);
				CommonResult<ObjectNode> commonResult = ucFeignService.getRoleByIdOrCode(id);
				if (BeanUtils.isNotEmpty(commonResult)){
					ObjectNode node = commonResult.getValue();
					roleList.add(node);
				}
			}
			map.put("info", roleList);
		} else if ("org".equals(type)) {
			List<ObjectNode> orgList = new ArrayList<>();
			List<String> idList = Arrays.asList(ids.split(","));
			for (int j = 0; j < idList.size() ; j++) {
				String id = idList.get(j);
				ObjectNode node = ucFeignService.getOrgById(id);
				if (BeanUtils.isNotEmpty(node)){
					orgList.add(node);
				}
			}
			map.put("info", orgList);
		} else if ("pos".equals(type)) {
			List<ObjectNode> userList = new ArrayList<>();
			List<String> idList = Arrays.asList(ids.split(","));
			for (int j = 0; j < idList.size() ; j++) {
				String id = idList.get(j);
				CommonResult<ObjectNode> commonResult = ucFeignService.getPostByIdOrCode(id);
				if (BeanUtils.isNotEmpty(commonResult)){
					ObjectNode node = commonResult.getValue();
					userList.add(node);
				}
			}
			map.put("info", userList);
		} else if ("user".equals(type)) {
			List<JsonNode> userList = new ArrayList<>();
			List<String> idList = Arrays.asList(ids.split(","));
			for (int j = 0; j < idList.size() ; j++) {
				String id = idList.get(j);
				CommonResult<JsonNode> commonResult = ucFeignService.getUserById(id);
				if (BeanUtils.isNotEmpty(commonResult)){
					JsonNode node = commonResult.getValue();
					userList.add(node);
				}
			}
			map.put("info", userList);
		} else if ("job".equals(type)) {
			List<ObjectNode> jobList = new ArrayList<>();
			List<String> idList = Arrays.asList(ids.split(","));
			for (int j = 0; j < idList.size() ; j++) {
				String id = idList.get(j);
				ObjectNode node = ucFeignService.getJobByIdOrCode(id);
				if (BeanUtils.isNotEmpty(node)){
					jobList.add(node);
				}
			}
			map.put("info", jobList);
		}
		return map;
	}
}
