From a6c5984b2347a368e4e9ea7dbfdb95d199d6d4f4 Mon Sep 17 00:00:00 2001
From: luoyb <412940104@qq.com>
Date: 星期二, 02 二月 2021 22:10:14 +0800
Subject: [PATCH] feat(系统和人力微服务): 数据字典和缓存
---
febs-server/febs-server-generator/src/main/resources/generator/templates/controller.ftl | 116 +++++++++++++++++++++++++++++++++-------------------------
1 files changed, 66 insertions(+), 50 deletions(-)
diff --git a/febs-server/febs-server-generator/src/main/resources/generator/templates/controller.ftl b/febs-server/febs-server-generator/src/main/resources/generator/templates/controller.ftl
index d9245c2..9273b1f 100644
--- a/febs-server/febs-server-generator/src/main/resources/generator/templates/controller.ftl
+++ b/febs-server/febs-server-generator/src/main/resources/generator/templates/controller.ftl
@@ -16,11 +16,15 @@
import java.util.Map;
/**
- * ${tableComment} Controller
- *
- * @author ${author}
- * @date ${date}
- */
+*
+* name:${className}
+* package:${basePackage}.${controllerPackage}
+* description:${tableComment}控制器
+*
+* @author ${author}
+* @date ${date}
+* @since JDK1.8
+*/
@Slf4j
@Validated
@RestController
@@ -28,54 +32,66 @@
@RequiredArgsConstructor
public class ${className}Controller {
- private final I${className}Service ${className?uncap_first}Service;
+private final I${className}Service ${className?uncap_first}Service;
- @GetMapping
- @PreAuthorize("hasAuthority('${className?uncap_first}:list')")
- public FebsResponse getAll${className}s(${className} ${className?uncap_first}) {
- return new FebsResponse().data(${className?uncap_first}Service.find${className}s(${className?uncap_first}));
- }
+@GetMapping
+@PreAuthorize("hasAuthority('${className?uncap_first}:list')")
+public FebsResponse getAll${className}s(${className} ${className?uncap_first}) {
+return new FebsResponse().data(${className?uncap_first}Service.find${className}s(${className?uncap_first}));
+}
- @GetMapping("list")
- @PreAuthorize("hasAuthority('${className?uncap_first}:list')")
- public FebsResponse ${className?uncap_first}List(QueryRequest request, ${className} ${className?uncap_first}) {
- Map<String, Object> dataTable = FebsUtil.getDataTable(this.${className?uncap_first}Service.find${className}s(request, ${className?uncap_first}));
- return new FebsResponse().data(dataTable);
- }
+@GetMapping("list")
+@PreAuthorize("hasAuthority('${className?uncap_first}:list')")
+public FebsResponse ${className?uncap_first}List(QueryRequest request, ${className} ${className?uncap_first}) {
+Map<String, Object> dataTable = FebsUtil.getDataTable(this.${className?uncap_first}Service.find${className}s(request, ${className?uncap_first}));
+return new FebsResponse().data(dataTable);
+}
- @PostMapping
- @PreAuthorize("hasAuthority('${className?uncap_first}:add')")
- public void add${className}(@Valid ${className} ${className?uncap_first}) throws FebsException {
- try {
- this.${className?uncap_first}Service.create${className}(${className?uncap_first});
- } catch (Exception e) {
- String message = "新增${className}失败";
- log.error(message, e);
- throw new FebsException(message);
- }
- }
+@PostMapping
+@PreAuthorize("hasAuthority('${className?uncap_first}:add')")
+public void add${className}(@Valid ${className} ${className?uncap_first}) throws FebsException {
+try {
+this.${className?uncap_first}Service.create${className}(${className?uncap_first});
+} catch (Exception e) {
+String message = "新增${tableComment}失败";
+log.error(message, e);
+throw new FebsException(message);
+}
+}
- @DeleteMapping
- @PreAuthorize("hasAuthority('${className?uncap_first}:delete')")
- public void delete${className}(${className} ${className?uncap_first}) throws FebsException {
- try {
- this.${className?uncap_first}Service.delete${className}(${className?uncap_first});
- } catch (Exception e) {
- String message = "删除${className}失败";
- log.error(message, e);
- throw new FebsException(message);
- }
- }
+@DeleteMapping
+@PreAuthorize("hasAuthority('${className?uncap_first}:delete')")
+public void delete${className}(${className} ${className?uncap_first}) throws FebsException {
+try {
+this.${className?uncap_first}Service.delete${className}(${className?uncap_first});
+} catch (Exception e) {
+String message = "删除${tableComment}失败";
+log.error(message, e);
+throw new FebsException(message);
+}
+}
- @PutMapping
- @PreAuthorize("hasAuthority('${className?uncap_first}:update')")
- public void update${className}(${className} ${className?uncap_first}) throws FebsException {
- try {
- this.${className?uncap_first}Service.update${className}(${className?uncap_first});
- } catch (Exception e) {
- String message = "修改${className}失败";
- log.error(message, e);
- throw new FebsException(message);
- }
- }
+@DeleteMapping("{ids}")
+@PreAuthorize("hasAuthority('${className?uncap_first}:delete')")
+public void logicDelete${className}(@PathVariable("ids") String ids) throws FebsException {
+try {
+this.${className?uncap_first}Service.logicDel${className}(ids);
+} catch (Exception e) {
+String message = "逻辑删除${tableComment}失败";
+log.error(message, e);
+throw new FebsException(message);
+}
+}
+
+@PutMapping
+@PreAuthorize("hasAuthority('${className?uncap_first}:update')")
+public void update${className}(${className} ${className?uncap_first}) throws FebsException {
+try {
+this.${className?uncap_first}Service.update${className}(${className?uncap_first});
+} catch (Exception e) {
+String message = "修改${tableComment}失败";
+log.error(message, e);
+throw new FebsException(message);
+}
+}
}
--
Gitblit v1.8.0