fix: 自动代码生成模板纠正和定义全局参数

This commit is contained in:
haoxr
2024-04-12 23:21:55 +08:00
parent d610731853
commit d18df15795
4 changed files with 41 additions and 29 deletions

View File

@@ -6,20 +6,16 @@ import org.springframework.web.bind.annotation.RestController;
import ${package.Parent}.model.form.${entity}Form;
import ${package.Parent}.model.query.${entity}PageQuery;
import ${package.Parent}.model.vo.${entity}PageVO;
import ${package.Parent}.service.${entity}Service;
import ${package.Parent}.service.${table.serviceName};
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.youlai.system.common.result.PageResult;
import com.youlai.system.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 lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.List;
#if(${superControllerClassPackage})
import ${superControllerClassPackage};
@@ -28,10 +24,12 @@ import ${superControllerClassPackage};
/**
* $!{table.comment} 前端控制器
*
* @author${author}
* @since${date}
* @author ${author}
* @since ${date}
*/
@Tag(name = "${table.comment}接口")
@RestController
@RequestMapping("/api/v1/${firstCharLowerCaseEntity}s")
@RequiredArgsConstructor
#if(${superControllerClass})
public class ${table.controllerName} extends ${superControllerClass} {
@@ -39,21 +37,19 @@ public class ${table.controllerName} extends ${superControllerClass} {
public class ${table.controllerName} {
#end
#set($entityLower = $string.toLowerCase($entity))
private final ${table.serviceName} $entityLowerService;
private final ${table.serviceName} ${firstCharLowerCaseEntity}Service;
@Operation(summary = "$!{table.comment}分页列表")
@GetMapping("/page")
public PageResult<${entity}PageVO> listPaged${entity}s(${entity}PageQuery queryParams ) {
IPage<${entity}PageVO> result = ${entityLower}Service.listPaged${entity}s(queryParams);
IPage<${entity}PageVO> result = ${firstCharLowerCaseEntity}Service.listPaged${entity}s(queryParams);
return PageResult.success(result);
}
@Operation(summary = "新增$!{table.comment}")
@PostMapping
@PreventDuplicateSubmit
public Result save${entity}(@RequestBody @Valid ${entity}Form formData ) {
boolean result = ${entityLower}Service.save${entity}(userForm);
boolean result = ${firstCharLowerCaseEntity}Service.save${entity}(formData);
return Result.judge(result);
}
@@ -62,7 +58,7 @@ public class ${table.controllerName} {
public Result<${entity}Form> get${entity}Form(
@Parameter(description = "$!{table.comment}ID") @PathVariable Long id
) {
${entity}Form formData = ${entityLower}Service.get${entity}FormData(id);
${entity}Form formData = ${firstCharLowerCaseEntity}Service.get${entity}FormData(id);
return Result.success(formData);
}
@@ -70,7 +66,7 @@ public class ${table.controllerName} {
@PutMapping(value = "/{id}")
public Result update${entity}(@Parameter(description = "$!{table.comment}ID") @PathVariable Long id,
@RequestBody @Validated ${entity}Form formData) {
boolean result = ${entityLower}Service.update${entity}(userId, formData);
boolean result = ${firstCharLowerCaseEntity}Service.update${entity}(id, formData);
return Result.judge(result);
}
@@ -79,7 +75,7 @@ public class ${table.controllerName} {
public Result delete${entity}s(
@Parameter(description = "$!{table.comment}ID多个以英文逗号(,)分割") @PathVariable String ids
) {
boolean result = ${entityLower}Service.delete${entity}s(ids);
boolean result = ${firstCharLowerCaseEntity}Service.delete${entity}s(ids);
return Result.judge(result);
}
}