懒羊羊
2024-01-10 a556270e96bc6e7fa4202c466d57cc75f778c614
提交 | 用户 | 时间
71e81e 1 package ${controllerPackage};
2
3 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.web.bind.annotation.RestController;
5 import cn.stylefeng.roses.kernel.model.page.PageResult;
6 import cn.stylefeng.roses.kernel.model.response.ResponseData;
7 import ${package.EntitySpecParams}.${entity}Param;
8 import ${package.EntitySpecResult}.${entity}Result;
9 import ${package.Service}.${table.serviceName};
10 import cn.stylefeng.roses.kernel.scanner.modular.annotation.PostResource;
11 import cn.stylefeng.roses.kernel.scanner.modular.stereotype.ApiResource;
12 import io.swagger.annotations.Api;
13 import io.swagger.annotations.ApiOperation;
14 import org.springframework.web.bind.annotation.RequestBody;
15
16 import java.util.List;
17
18 /**
19  * ${tool.cleanWhite(table.comment)}控制器
20  *
21  * @author ${author}
22  * @Date ${tool.currentTime()}
23  */
24 @RestController
25 @ApiResource(name = "${tool.cleanWhite(table.comment)}管理", path = "/${tool.lowerFirst(entity)}")
26 @Api(tags = "${tool.cleanWhite(table.comment)}")
27 public class ${entity}Controller {
28
29     <% var lowerEntity = tool.lowerFirst(entity); %>
30     <% var lowerEntityService = lowerEntity + 'Service'; %>
31
32     @Autowired
33     private ${entity}Service ${lowerEntityService};
34
35     /**
36      * 新增
37      *
38      * @author ${author}
39      * @Date ${date}
40      */
41     @PostResource(name = "添加", path = "/add")
42     @ApiOperation("新增")
43     public ResponseData add(@RequestBody ${entity}Param param) {
44         ${lowerEntityService}.add(param);
45         return ResponseData.success();
46     }
47
48     /**
49      * 修改
50      *
51      * @author ${author}
52      * @Date ${date}
53      */
54     @PostResource(name = "修改", path = "/update")
55     @ApiOperation("修改")
56     public ResponseData update(@RequestBody ${entity}Param param) {
57         ${lowerEntityService}.update(param);
58         return ResponseData.success();
59     }
60
61     /**
62      * 删除
63      *
64      * @author ${author}
65      * @Date ${date}
66      */
67     @PostResource(name = "删除", path = "/delete")
68     @ApiOperation("删除")
69     public ResponseData delete(@RequestBody ${entity}Param param) {
70         ${lowerEntityService}.delete(param);
71         return ResponseData.success();
72     }
73
74     /**
75      * 查询单条详情
76      *
77      * @author ${author}
78      * @Date ${date}
79      */
80     @PostResource(name = "查询详情", path = "/queryDetail")
81     @ApiOperation(value = "查询详情", response = ${entity}Result.class)
82     public ResponseData queryDetail(@RequestBody ${entity}Param param) {
83         ${entity}Result result = ${lowerEntityService}.findBySpec(param);
84         return ResponseData.success(result);
85     }
86
87     /**
88      * 查询列表
89      *
90      * @author ${author}
91      * @Date ${date}
92      */
93     @PostResource(name = "查询列表", path = "/queryList")
94     @ApiOperation(value = "查询列表", response = ${entity}Result.class)
95     public ResponseData queryList(@RequestBody ${entity}Param param) {
96         List<${entity}Result> listBySpec = ${lowerEntityService}.findListBySpec(param);
97         return ResponseData.success(listBySpec);
98     }
99
100     /**
101      * 分页查询列表
102      *
103      * @author ${author}
104      * @Date ${date}
105      */
106     @PostResource(name = "分页查询列表", path = "/queryListPage")
107     @ApiOperation(value = "分页查询列表", response = ${entity}Result.class)
108     public ResponseData queryListPage(@RequestBody ${entity}Param param) {
109         PageResult<${entity}Result> pageBySpec = ${lowerEntityService}.findPageBySpec(param);
110         return ResponseData.success(pageBySpec);
111     }
112
113 }