chen.lin
2 天以前 9140aee230de0ef41de9682a9353fbd372e2bcaa
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
package com.vincent.rsf.server.system.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.server.common.domain.BaseParam;
import com.vincent.rsf.server.common.domain.PageParam;
import com.vincent.rsf.server.system.entity.OpenApiApp;
import com.vincent.rsf.server.system.service.OpenApiAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import java.util.Arrays;
import java.util.Map;
 
@RestController
public class OpenApiAppController extends BaseController {
 
    @Autowired
    private OpenApiAppService openApiAppService;
 
    @PreAuthorize("hasAuthority('system:openApiApp:list')")
    @PostMapping("/openApiApp/page")
    public R page(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
        PageParam<OpenApiApp, BaseParam> pageParam = new PageParam<>(baseParam, OpenApiApp.class);
        LambdaQueryWrapper<OpenApiApp> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByDesc(OpenApiApp::getId);
        Page<OpenApiApp> page = openApiAppService.page(pageParam, wrapper);
        return R.ok().add(page);
    }
 
    @PreAuthorize("hasAuthority('system:openApiApp:list')")
    @PostMapping("/openApiApp/list")
    public R list(@RequestBody Map<String, Object> map) {
        return R.ok().add(openApiAppService.list(new LambdaQueryWrapper<OpenApiApp>().orderByDesc(OpenApiApp::getId)));
    }
 
    @PreAuthorize("hasAuthority('system:openApiApp:list')")
    @PostMapping("/openApiApp/many/{ids}")
    public R many(@PathVariable String[] ids) {
        return R.ok().add(openApiAppService.listByIds(Arrays.asList(ids)));
    }
 
    @PreAuthorize("hasAuthority('system:openApiApp:list')")
    @GetMapping("/openApiApp/{id}")
    public R get(@PathVariable String id) {
        return R.ok().add(openApiAppService.getById(id));
    }
 
    @PreAuthorize("hasAuthority('system:openApiApp:save')")
    @PostMapping("/openApiApp/save")
    public R save(@RequestBody OpenApiApp app) {
        if (openApiAppService.save(app)) {
            return R.ok("Save Success").add(app);
        }
        return R.error("Save Fail");
    }
 
    @PreAuthorize("hasAuthority('system:openApiApp:update')")
    @PostMapping("/openApiApp/update")
    public R update(@RequestBody OpenApiApp app) {
        if (openApiAppService.updateById(app)) {
            return R.ok("Update Success").add(app);
        }
        return R.error("Update Fail");
    }
 
    @PreAuthorize("hasAuthority('system:openApiApp:remove')")
    @PostMapping("/openApiApp/remove/{ids}")
    public R remove(@PathVariable String[] ids) {
        if (openApiAppService.removeByIds(Arrays.asList(ids))) {
            return R.ok("Remove Success");
        }
        return R.error("Remove Fail");
    }
}