From 8deb76b7205f398c539a1eacfcffd43febba8aad Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Sat, 3 Aug 2024 21:58:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A8=A1=E6=9D=BF=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/generator/controller.java.vm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/generator/controller.java.vm b/src/main/resources/templates/generator/controller.java.vm index 983bd6d3..fd3b999e 100644 --- a/src/main/resources/templates/generator/controller.java.vm +++ b/src/main/resources/templates/generator/controller.java.vm @@ -12,6 +12,7 @@ import com.youlai.common.result.Result; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import jakarta.validation.Valid; @@ -32,6 +33,7 @@ public class ${entityName}Controller { @Operation(summary = "$!{businessName}分页列表") @GetMapping("/page") + @PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:query')") public PageResult<${entityName}PageVO> get${entityName}Page(${entityName}PageQuery queryParams ) { IPage<${entityName}PageVO> result = ${lowerFirstEntityName}Service.get${entityName}Page(queryParams); return PageResult.success(result); @@ -39,6 +41,7 @@ public class ${entityName}Controller { @Operation(summary = "新增${businessName}") @PostMapping + @PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:add')") public Result save${entityName}(@RequestBody @Valid ${entityName}Form formData ) { boolean result = ${lowerFirstEntityName}Service.save${entityName}(formData); return Result.judge(result); @@ -46,6 +49,7 @@ public class ${entityName}Controller { @Operation(summary = "获取${businessName}表单数据") @GetMapping("/{id}/form") + @PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:edit')") public Result<${entityName}Form> get${entityName}Form( @Parameter(description = "$!{businessName}ID") @PathVariable Long id ) { @@ -55,14 +59,18 @@ public class ${entityName}Controller { @Operation(summary = "修改${businessName}") @PutMapping(value = "/{id}") - public Result update${entityName}(@Parameter(description = "$!{businessName}ID") @PathVariable Long id, - @RequestBody @Validated ${entityName}Form formData) { + @PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:edit')") + public Result update${entityName}( + @Parameter(description = "$!{businessName}ID") @PathVariable Long id, + @RequestBody @Validated ${entityName}Form formData + ) { boolean result = ${lowerFirstEntityName}Service.update${entityName}(id, formData); return Result.judge(result); } @Operation(summary = "删除${businessName}") @DeleteMapping("/{ids}") + @PreAuthorize("@ss.hasPerm('${moduleName}:${lowerFirstEntityName}:delete')") public Result delete${entityName}s( @Parameter(description = "$!{businessName}ID,多个以英文逗号(,)分割") @PathVariable String ids ) {