懒羊羊
2023-11-25 9bd5461a1387becd4da03158061a1ed17ddf6a6c
提交 | 用户 | 时间
71e81e 1 package ${controllerPackage};
2
3 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
4 import ${package.Entity}.${entity};
5 import ${package.EntitySpecParams}.${entity}Param;
6 import ${package.Service}.${table.serviceName};
7 import cn.stylefeng.roses.core.base.controller.BaseController;
8 import cn.stylefeng.roses.kernel.model.response.ResponseData;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Controller;
11 import org.springframework.web.bind.annotation.RequestMapping;
12 import org.springframework.web.bind.annotation.ResponseBody;
13
14 <% var lowerEntityService = lowerEntity + 'Service'; %>
15
16 /**
17  * ${tool.cleanWhite(table.comment)}控制器
18  *
19  * @author ${author}
20  * @Date ${tool.currentTime()}
21  */
22 @Controller
23 @RequestMapping("/${lowerEntity}")
24 public class ${entity}Controller extends BaseController {
25
26     private String PREFIX = "${context.modularName}/${lowerEntity}";
27
28     @Autowired
29     private ${entity}Service ${lowerEntityService};
30
31     /**
32      * 跳转到主页面
33      *
34      * @author ${author}
35      * @Date ${date}
36      */
37     @RequestMapping("")
38     public String index() {
39         return PREFIX + "/${lowerEntity}.html";
40     }
41
42     /**
43      * 新增页面
44      *
45      * @author ${author}
46      * @Date ${date}
47      */
48     @RequestMapping("/add")
49     public String add() {
50         return PREFIX + "/${lowerEntity}_add.html";
51     }
52
53     /**
54      * 编辑页面
55      *
56      * @author ${author}
57      * @Date ${date}
58      */
59     @RequestMapping("/edit")
60     public String edit() {
61         return PREFIX + "/${lowerEntity}_edit.html";
62     }
63
64     /**
65      * 新增接口
66      *
67      * @author ${author}
68      * @Date ${date}
69      */
70     @RequestMapping("/addItem")
71     @ResponseBody
72     public ResponseData addItem(${entity}Param ${lowerEntity}Param) {
73         this.${lowerEntity}Service.add(${lowerEntity}Param);
74         return ResponseData.success();
75     }
76
77     /**
78      * 编辑接口
79      *
80      * @author ${author}
81      * @Date ${date}
82      */
83     @RequestMapping("/editItem")
84     @ResponseBody
85     public ResponseData editItem(${entity}Param ${lowerEntity}Param) {
86         this.${lowerEntity}Service.update(${lowerEntity}Param);
87         return ResponseData.success();
88     }
89
90     /**
91      * 删除接口
92      *
93      * @author ${author}
94      * @Date ${date}
95      */
96     @RequestMapping("/delete")
97     @ResponseBody
98     public ResponseData delete(${entity}Param ${lowerEntity}Param) {
99         this.${lowerEntity}Service.delete(${lowerEntity}Param);
100         return ResponseData.success();
101     }
102
103     /**
104      * 查看详情接口
105      *
106      * @author ${author}
107      * @Date ${date}
108      */
109     @RequestMapping("/detail")
110     @ResponseBody
111     public ResponseData detail(${entity}Param ${lowerEntity}Param) {
112         ${entity} detail = this.${lowerEntity}Service.getById(${lowerEntity}Param.get${bigKeyPropertyName}());
113         return ResponseData.success(detail);
114     }
115
116     /**
117      * 查询列表
118      *
119      * @author ${author}
120      * @Date ${date}
121      */
122     @ResponseBody
123     @RequestMapping("/list")
124     public LayuiPageInfo list(${entity}Param ${lowerEntity}Param) {
125         return this.${lowerEntity}Service.findPageBySpec(${lowerEntity}Param);
126     }
127
128 }
129
130