月球大数据地理空间分析展示平台-【后端】-月球后台服务
1
13693261870
2024-11-11 fee67ca8a0760315047a52fc4101a8f4f80b7a7f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.moon.server.controller.sys;
 
import com.moon.server.helper.WebHelper;
import com.moon.server.service.sys.ProxyService;
import com.sun.istack.NotNull;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
@SuppressWarnings("ALL")
@Api(tags = "运维管理\\代理服务")
@RestController
@RequestMapping("/proxy")
public class ProxyController {
    @Resource
    ProxyService proxyService;
 
    private static final Log log = LogFactory.getLog(ProxyController.class);
 
    @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 = {"/{token}/{id}/**"})
    public void proxyUrl(@NotNull @PathVariable String token, @NotNull @PathVariable int id, HttpServletRequest req, HttpServletResponse res) {
        try {
            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());
        }
    }
}