renkang
2026-04-02 666a4ef3cf5d9838795487918621a4232859506d
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.doumee.cloud.admin;
 
import com.doumee.api.BaseController;
import com.doumee.core.annotation.excel.ExcelExporter;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.dao.business.model.YwGateway;
import com.doumee.service.business.YwGatewayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.doumee.config.annotation.CloudRequiredPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
 
/**
 * 网关管理
 * @author renkang
 * @date 2026/04/02
 */
@Api(tags = "网关管理")
@RestController
@RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX + "/business/ywGateway")
public class YwGatewayCloudController extends BaseController {
 
    @Autowired
    private YwGatewayService ywGatewayService;
 
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
    @CloudRequiredPermission("business:ywgateway:create")
    public ApiResponse create(@RequestBody YwGateway ywGateway, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        ywGateway.setLoginUserInfo(this.getLoginUser(token));
        return ApiResponse.success(ywGatewayService.create(ywGateway));
    }
 
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @CloudRequiredPermission("business:ywgateway:delete")
    public ApiResponse deleteById(@PathVariable Integer id, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        ywGatewayService.deleteById(id, this.getLoginUser(token));
        return ApiResponse.success(null);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @CloudRequiredPermission("business:ywgateway:delete")
    public ApiResponse deleteByIdInBatch(@RequestParam String ids, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        String[] idArray = ids.split(",");
        List<Integer> idList = new ArrayList<>();
        for (String id : idArray) {
            idList.add(Integer.valueOf(id));
        }
        ywGatewayService.deleteByIdInBatch(idList, this.getLoginUser(token));
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @CloudRequiredPermission("business:ywgateway:update")
    public ApiResponse updateById(@RequestBody YwGateway ywGateway, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        ywGateway.setLoginUserInfo(this.getLoginUser(token));
        ywGatewayService.updateById(ywGateway);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("禁启用")
    @PostMapping("/updateStatusById")
    @CloudRequiredPermission("business:ywgateway:update")
    public ApiResponse updateStatusById(@RequestBody YwGateway ywGateway, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        ywGateway.setLoginUserInfo(this.getLoginUser(token));
        ywGatewayService.updateStatusById(ywGateway);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @CloudRequiredPermission("business:ywgateway:query")
    public ApiResponse<PageData<YwGateway>> findPage(@RequestBody PageWrap<YwGateway> pageWrap, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        pageWrap.getModel().setLoginUserInfo(this.getLoginUser(token));
        return ApiResponse.success(ywGatewayService.findPage(pageWrap));
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @CloudRequiredPermission("business:ywgateway:query")
    public ApiResponse findById(@PathVariable Integer id, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        return ApiResponse.success(ywGatewayService.findById(id));
    }
 
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @CloudRequiredPermission("business:ywgateway:exportExcel")
    public void exportExcel(@RequestBody PageWrap<YwGateway> pageWrap, HttpServletResponse response, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        pageWrap.getModel().setLoginUserInfo(this.getLoginUser(token));
        ExcelExporter.build(YwGateway.class).export(ywGatewayService.findPage(pageWrap).getRecords(), "网关管理", response);
    }
}