| | |
| | | } |
| | | |
| | | /** |
| | | * GeoServer的图层名键 |
| | | */ |
| | | public static String permsGeoTabKey(String key) { |
| | | return "perms:geo:tab:" + key; |
| | | } |
| | | |
| | | /** |
| | | * 图层授权键 |
| | | */ |
| | | public static String permsLayerKey(String key) { |
| | |
| | | |
| | | CloseableHttpClient client = null; |
| | | HttpResponse proxyResponse = null; |
| | | |
| | | try { |
| | | client = this.createHttpClient(); |
| | | proxyResponse = client.execute(host, proxyRequest); |
| | |
| | | } |
| | | |
| | | private void copeGeoService(HttpResponse proxyResponse, HttpServletRequest request, HttpServletResponse response, ResEntity res) throws IOException { |
| | | if (StaticData.GET_CAPABILITIES.equals(request.getParameter(StaticData.REQUEST))) { |
| | | if (StaticData.GET_CAPABILITIES.equals(res.getBak())) { |
| | | // |
| | | } |
| | | |
| | |
| | | public List<ResEntity> selectAllRes(); |
| | | |
| | | /** |
| | | * 根据用户Uid查询GeoServer的图层名 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public List<String> selectTabs(String uid); |
| | | |
| | | /** |
| | | * 查询所有GeoServer的图层名 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<String> selectAllTabs(); |
| | | |
| | | /** |
| | | * 根据用户Uid查询菜单授权 |
| | | * |
| | | * @param uid |
| | |
| | | |
| | | @Override |
| | | public List<ResEntity> selectRes(String uid) { |
| | | return selectResByUid(uid, false); |
| | | } |
| | | |
| | | @Override |
| | | public List<ResEntity> selectAllRes() { |
| | | return selectResByUid(StaticData.ADMIN, true); |
| | | } |
| | | |
| | | private List<ResEntity> selectResByUid(String uid, boolean isAll) { |
| | | String key = RedisCacheKey.permsResKey(uid); |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | | return (List<ResEntity>) obj; |
| | | } |
| | | |
| | | List<ResEntity> list = permsMapper.selectRes(uid); |
| | | List<ResEntity> list = isAll ? permsMapper.selectAllRes() : permsMapper.selectRes(uid); |
| | | if (list != null && list.size() > 0) { |
| | | redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ResEntity> selectAllRes() { |
| | | return permsMapper.selectAllRes(); |
| | | public List<String> selectTabs(String uid) { |
| | | return selectTabsByUid(uid, false); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> selectAllTabs() { |
| | | return selectTabsByUid(StaticData.ADMIN, true); |
| | | } |
| | | |
| | | private List<String> selectTabsByUid(String uid, boolean isAll) { |
| | | String key = RedisCacheKey.permsGeoTabKey(uid); |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof List<?>) { |
| | | return (List<String>) obj; |
| | | } |
| | | |
| | | List<String> list = isAll ? permsMapper.selectAllTabs() : permsMapper.selectTabs(uid); |
| | | if (list != null && list.size() > 0) { |
| | | redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return url; |
| | | } |
| | | |
| | | String str = req.getQueryString(); |
| | | if (!StaticData.GET_CAPABILITIES.equals(req.getParameter(StaticData.REQUEST))) { |
| | | // |
| | | String str = req.getQueryString(), layers = req.getParameter("layers"); |
| | | if (!StaticData.GET_CAPABILITIES.equals(req.getParameter(StaticData.REQUEST)) && null != layers) { |
| | | int start = str.indexOf("layers"); |
| | | int end = str.indexOf("&", start); |
| | | layers = filterGeoLayers(ue, layers); |
| | | |
| | | str = str.replace(str.substring(start, end > -1 ? end : str.length()), "layers=" + layers); |
| | | } else { |
| | | entity.setBak(StaticData.GET_CAPABILITIES); |
| | | } |
| | | |
| | | return url + (url.contains("?") ? "&" : "?") + str; |
| | | } |
| | | |
| | | /** |
| | | * 过滤GeoServer图层 |
| | | */ |
| | | private String filterGeoLayers(UserEntity ue, String layers) { |
| | | List<String> tabs = StaticData.ADMIN.equals(ue.getUid()) ? permsService.selectAllTabs() : permsService.selectTabs(ue.getUid()); |
| | | if (null == tabs || tabs.isEmpty()) { |
| | | return ""; |
| | | } |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | String[] strs = layers.split(StaticData.COMMA); |
| | | for (String str : strs) { |
| | | if (tabs.contains(str)) { |
| | | sb.append(str).append(","); |
| | | } |
| | | } |
| | | sb.deleteCharAt(sb.length() - 1); |
| | | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 转发请求 |
| | | */ |
| | | private void forward(HttpServletRequest request, HttpServletResponse response, ResEntity entity, String url) throws Exception { |
| | |
| | | </select> |
| | | |
| | | <select id="selectAllRes" resultType="com.moon.server.entity.sys.ResEntity"> |
| | | select distinct e.* |
| | | select e.* |
| | | from lf.sys_res e |
| | | where e.status between 1 and 2 |
| | | order by e.id; |
| | | </select> |
| | | |
| | | <select id="selectTabs" resultType="java.lang.String"> |
| | | select distinct e.tab |
| | | from lf.sys_user a |
| | | inner join lf.sys_role_user b on a.id = b.userid |
| | | inner join lf.sys_role_layer c on b.roleid = c.roleid |
| | | inner join lf.sys_layer d on c.layerid = d.id |
| | | inner join lf.sys_res e on d.resid = e.id |
| | | <where> |
| | | d.status between 1 and 2 and e.status between 1 and 2 and e.category = 2 and length(e.tab) > 0 |
| | | <if test="uid != null"> |
| | | and a.uid = #{uid} |
| | | </if> |
| | | </where> |
| | | order by e.id; |
| | | </select> |
| | | |
| | | <select id="selectAllTabs" resultType="java.lang.String"> |
| | | select e.tab |
| | | from lf.sys_res e |
| | | where e.status between 1 and 2 and category = 2 and length(e.tab) > 0 |
| | | order by e.id; |
| | | </select> |
| | | |
| | | <select id="selectMenus" resultType="com.moon.server.entity.all.MenusAuthEntity"> |
| | | select distinct e.id,e.pid,e.cn_name,e.en_name,e.url,e.perms,e.type,e.css,e.icon,e.level,e.order_num,e.is_show |
| | | from lf.sys_user a |