package com.skyline.electricity.controller; import org.springframework.stereotype.*; import com.skyline.electricity.service.*; import org.springframework.beans.factory.annotation.*; import com.skyline.electricity.interceptor.*; import org.apache.commons.lang3.*; import io.swagger.annotations.*; import org.springframework.web.bind.annotation.*; import com.skyline.electricity.entity.*; import java.util.*; @Controller @RequestMapping({ "/interceptor" }) @Api("基于SpringBoot的廊坊热电厂三维可视化系统") @CrossOrigin public class InterceptorController { @Autowired private InfoSynchService infoSynchService; @RequestMapping(value = { "/getUserInfo" }, method = { RequestMethod.POST }) @ApiOperation("获取前端页面传送的session信息") @ResponseBody public Object getUserInfo(final String code) { final Map map = new HashMap(); final IAMUtils iamUtils = new IAMUtils(); if (code != null) { String tokenOfCode = null; tokenOfCode = iamUtils.getTokenByCode(code); if (StringUtils.isNotBlank((CharSequence)tokenOfCode)) { Object userInfo = null; try { userInfo = iamUtils.getUserInfoFromIam(tokenOfCode); } catch (Exception e) { e.printStackTrace(); } if (userInfo != null && !"".equals(userInfo)) { map.put("userInfo", userInfo); map.put("msg", "success"); map.put("code", "0"); return map; } map.put("userInfo", null); map.put("msg", "failure"); map.put("code", "-1"); return map; } } return null; } @RequestMapping(value = { "/getUserInfoByToken" }, method = { RequestMethod.POST }) @ApiOperation("获取前端页面传送的token信息") @ResponseBody public Object getUserInfoByToken(final String token) { final Map map = new HashMap(); final IAMUtils iamUtils = new IAMUtils(); if (token == null) { return null; } Object userInfo = null; try { userInfo = iamUtils.getUserInfoFromIam(token); } catch (Exception e) { e.printStackTrace(); } if (userInfo != null && !"".equals(userInfo)) { map.put("userInfo", userInfo); map.put("msg", "success"); map.put("code", "0"); return map; } map.put("userInfo", null); map.put("msg", "failure"); map.put("code", "-1"); return map; } @RequestMapping(value = { "/judgePermissions" }, method = { RequestMethod.POST }) @ApiOperation("判断当前用户是否拥有权限") @ResponseBody public Object judgePermissions(final String id) { final List permissionsList = (List)this.infoSynchService.getPermissions(); final List idList = new ArrayList(); for (final Permissions permissions : permissionsList) { idList.add(permissions.getUser_id()); } final boolean flag = idList.contains(id); return flag; } @RequestMapping(value = { "/testConfig" }, method = { RequestMethod.POST }) @ApiOperation("测试读取配置文件内容") @ResponseBody public Object testConfig() { final IAMUtils iamUtils = new IAMUtils(); final Object info = iamUtils.getUserInfoFromIam("ooo"); return info; } }