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
package com.vincent.rsf.openApi.controller.platform;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vincent.rsf.openApi.entity.app.App;
import com.vincent.rsf.openApi.entity.dto.CommonResponse;
import com.vincent.rsf.openApi.service.AppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * App管理Controller
 * 
 * @author vincent
 * @since 2026-01-04
 */
@RestController
@RequestMapping("/api/app")
@Api(tags = "应用管理")
public class AppController {
 
    @Autowired
    private AppService appService;
 
    @ApiOperation("分页查询应用列表")
    @GetMapping("/page")
    public CommonResponse page(@RequestParam(defaultValue = "1") Integer current,
                                @RequestParam(defaultValue = "10") Integer size) {
        Page<App> page = appService.page(new Page<>(current, size));
        return CommonResponse.ok().setData(page);
    }
 
    @ApiOperation("查询所有应用")
    @GetMapping("/list")
    public CommonResponse list() {
        List<App> list = appService.list();
        return CommonResponse.ok().setData(list);
    }
 
    @ApiOperation("根据ID查询应用")
    @GetMapping("/{id}")
    public CommonResponse getById(@PathVariable String id) {
        App app = appService.getById(id);
        return CommonResponse.ok().setData(app);
    }
 
    @ApiOperation("新增应用")
    @PostMapping
    public CommonResponse save(@RequestBody App app) {
        boolean result = appService.save(app);
        if (result) {
            appService.refreshCache();
            return CommonResponse.ok().setMsg("新增成功");
        }
        return CommonResponse.error("新增失败");
    }
 
    @ApiOperation("更新应用")
    @PutMapping
    public CommonResponse update(@RequestBody App app) {
        boolean result = appService.updateById(app);
        if (result) {
            appService.refreshCache();
            return CommonResponse.ok().setMsg("更新成功");
        }
        return CommonResponse.error("更新失败");
    }
 
    @ApiOperation("删除应用")
    @DeleteMapping("/{id}")
    public CommonResponse delete(@PathVariable String id) {
        boolean result = appService.removeById(id);
        if (result) {
            appService.refreshCache();
            return CommonResponse.ok().setMsg("删除成功");
        }
        return CommonResponse.error("删除失败");
    }
 
    @ApiOperation("批量删除应用")
    @DeleteMapping("/batch")
    public CommonResponse deleteBatch(@RequestBody List<String> ids) {
        boolean result = appService.removeByIds(ids);
        if (result) {
            appService.refreshCache();
            return CommonResponse.ok().setMsg("批量删除成功");
        }
        return CommonResponse.error("批量删除失败");
    }
 
    @ApiOperation("刷新应用缓存")
    @PostMapping("/refresh")
    public CommonResponse refresh() {
        appService.refreshCache();
        return CommonResponse.ok().setMsg("缓存刷新成功");
    }
}