月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-07-25 604778b34a84b62208106d03f7c8dfaa28151024
WMTS代理服务,添加Rest风格代理
已修改4个文件
30 ■■■■ 文件已修改
src/main/java/com/moon/server/controller/sys/ProxyController.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/entity/all/SettingData.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/helper/HttpHelper.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/service/sys/ProxyService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/controller/sys/ProxyController.java
@@ -39,7 +39,22 @@
    @RequestMapping(value = {"/{token}/{id}/**"})
    public void proxyUrl(@NotNull @PathVariable String token, @NotNull @PathVariable int id, HttpServletRequest req, HttpServletResponse res) {
        try {
            proxyService.proxyUrl(token, id, req, res);
            proxyService.proxyUrl(token, id, false, req, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            WebHelper.writeStr2Page(res, ex.getMessage());
        }
    }
    @ApiOperation(value = "URL代理", notes = "URL代理")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "path", required = true, example = "1eb2ea8f-5cfd-4e6c-95c9-17ab0f7bce71"),
            @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "path", required = true, example = "1"),
    })
    @RequestMapping(value = {"/rest/{token}/{id}/**"})
    public void proxyRestUrl(@NotNull @PathVariable String token, @NotNull @PathVariable int id, HttpServletRequest req, HttpServletResponse res) {
        try {
            proxyService.proxyUrl(token, id, true, req, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            WebHelper.writeStr2Page(res, ex.getMessage());
src/main/java/com/moon/server/entity/all/SettingData.java
@@ -48,10 +48,10 @@
    /**
     * 用户访问量
     */
    public static int MAX_USER_LOGIN;
    public static int MAX_USER_LOGIN = 1000;
    /**
     * 服务上限
     */
    public static int MAX_SERVERS;
    public static int MAX_SERVERS = 100000;
}
src/main/java/com/moon/server/helper/HttpHelper.java
@@ -320,9 +320,12 @@
            proxyUrl = request.getRequestURL().substring(0, request.getRequestURL().indexOf(proxyUrl) + proxyUrl.length());
            str = str.replace(strs[0], proxyUrl);
            if (!StringHelper.isEmpty(strs[1])) {
                str = str.replace("?" + strs[1], "").replace("&" + strs[1], "");
            }
            if (StaticData.THREE == res.getFirm() && str.contains(StaticData.REST_LAYER)) {
                str = str.replace(strs[0].replace("/wmts/layer/", StaticData.REST_LAYER), proxyUrl.replace("/proxy/", "/proxy/rest/"));
            }
        }
src/main/java/com/moon/server/service/sys/ProxyService.java
@@ -47,7 +47,7 @@
    /**
     * URL代理
     */
    public void proxyUrl(String token, int resId, HttpServletRequest req, HttpServletResponse res) throws Exception {
    public void proxyUrl(String token, int resId, boolean isRest, HttpServletRequest req, HttpServletResponse res) throws Exception {
        // 3.获取用户
        UserEntity ue = getUser(req, res, token);
        if (null == ue) {