inleft
2022-02-09 9bcb19959eeb9da9bde2561e7278f6d0a55eb151
commit | author | age
9bcb19 1 /*
I 2 Copyright [2020] [https://www.xiaonuo.vip]
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
17
18 1.请不要删除和修改根目录下的LICENSE文件。
19 2.请不要删除和修改Snowy源码头部的版权声明。
20 3.请保留源码和相关描述文件的项目出处,作者声明等。
21 4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy
22 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy
23 6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
24  */
25 package vip.xiaonuo.generate.modular.controller;
26
27 import org.springframework.validation.annotation.Validated;
28 import org.springframework.web.bind.annotation.GetMapping;
29 import org.springframework.web.bind.annotation.PostMapping;
30 import org.springframework.web.bind.annotation.RequestBody;
31 import org.springframework.web.bind.annotation.RestController;
32 import vip.xiaonuo.core.annotion.BusinessLog;
33 import vip.xiaonuo.core.annotion.Permission;
34 import vip.xiaonuo.core.context.constant.ConstantContextHolder;
35 import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
36 import vip.xiaonuo.core.exception.DemoException;
37 import vip.xiaonuo.core.pojo.response.ResponseData;
38 import vip.xiaonuo.core.pojo.response.SuccessResponseData;
39 import vip.xiaonuo.generate.modular.param.CodeGenerateParam;
40 import vip.xiaonuo.generate.modular.service.CodeGenerateService;
41
42 import javax.annotation.Resource;
43 import javax.servlet.http.HttpServletResponse;
44 import java.util.List;
45
46 /**
47  * 代码生成器
48  *
49  * @auther yubaoshan
50  * @date 12/15/20 11:20 PM
51  */
52 @RestController
53 public class CodeGenerateController {
54
55     @Resource
56     private CodeGenerateService codeGenerateService;
57
58     /**
59      * 代码生成基础数据
60      *
61      * @author yubaoshan89
62      * @date 2020年12月16日20:58:48
63      */
64     @Permission
65     @GetMapping("/codeGenerate/page")
66     @BusinessLog(title = "代码生成配置_查询", opType = LogAnnotionOpTypeEnum.QUERY)
67     public ResponseData page(CodeGenerateParam codeGenerateParam) {
68         return new SuccessResponseData(codeGenerateService.page(codeGenerateParam));
69     }
70
71     /**
72      * 代码生成基础配置保存
73      *
74      * @auther yubaoshan
75      * @date 12/15/20 11:20 PM
76      */
77     @Permission
78     @PostMapping("/codeGenerate/add")
79     @BusinessLog(title = "代码生成配置_增加", opType = LogAnnotionOpTypeEnum.ADD)
80     public ResponseData add(@RequestBody @Validated(CodeGenerateParam.add.class) CodeGenerateParam codeGenerateParam) {
81         this.codeGenerateService.add(codeGenerateParam);
82         return new SuccessResponseData();
83     }
84
85     /**
86      * 代码生成基础配置编辑
87      *
88      * @auther yubaoshan
89      * @date 2020年12月16日20:56:19
90      */
91     @Permission
92     @PostMapping("/codeGenerate/edit")
93     @BusinessLog(title = "代码生成配置_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
94     public ResponseData edit(@RequestBody @Validated(CodeGenerateParam.add.class) CodeGenerateParam codeGenerateParam) {
95         codeGenerateService.edit(codeGenerateParam);
96         return new SuccessResponseData();
97     }
98
99     /**
100      * 删除代码生成基础配置
101      *
102      * @author yubaoshan
103      * @date 2020年12月16日22:13:32
104      */
105     @Permission
106     @PostMapping("/codeGenerate/delete")
107     @BusinessLog(title = "代码生成配置_删除", opType = LogAnnotionOpTypeEnum.DELETE)
108     public ResponseData delete(@RequestBody @Validated(CodeGenerateParam.delete.class) List<CodeGenerateParam> codeGenerateParamList) {
109         codeGenerateService.delete(codeGenerateParamList);
110         return new SuccessResponseData();
111     }
112
113     /**
114      * 查询当前数据库用户下的所有表
115      *
116      * @author yubaoshan
117      * @date 2020-12-16 01:55:48
118      */
119     @Permission
120     @GetMapping("/codeGenerate/InformationList")
121     @BusinessLog(title = "数据库表列表_查询", opType = LogAnnotionOpTypeEnum.QUERY)
122     public ResponseData InformationList() {
123         return ResponseData.success(codeGenerateService.InformationTableList());
124     }
125
126     /**
127      * 代码生成基础配置生成
128      *
129      * @auther yubaoshan
130      * @date 12/15/20 11:20 PM
131      */
132     @Permission
133     @PostMapping("/codeGenerate/runLocal")
134     @BusinessLog(title = "代码生成_本地项目", opType = LogAnnotionOpTypeEnum.OTHER)
135     public ResponseData runLocal(@RequestBody @Validated(CodeGenerateParam.detail.class) CodeGenerateParam codeGenerateParam) {
136         // 演示环境开启,则不允许操作
137         if (ConstantContextHolder.getDemoEnvFlag()) {
138             throw new DemoException();
139         }
140         this.codeGenerateService.runLocal(codeGenerateParam);
141         return new SuccessResponseData();
142     }
143
144     /**
145      * 代码生成基础配置生成
146      *
147      * @auther yubaoshan
148      * @date 12/15/20 11:20 PM
149      */
150     @Permission
151     @GetMapping("/codeGenerate/runDown")
152     @BusinessLog(title = "代码生成_下载方式", opType = LogAnnotionOpTypeEnum.OTHER)
153     public void runDown(@Validated(CodeGenerateParam.detail.class) CodeGenerateParam codeGenerateParam, HttpServletResponse response) {
154         // 演示环境开启,则不允许操作
155         if (ConstantContextHolder.getDemoEnvFlag()) {
156             throw new DemoException();
157         }
158         this.codeGenerateService.runDown(codeGenerateParam, response);
159     }
160 }