完成代码生成器的 sql 生成

This commit is contained in:
YunaiV
2021-02-12 12:58:41 +08:00
parent b8351f50f2
commit 937c51f4ec
14 changed files with 421 additions and 520 deletions

View File

@@ -3,6 +3,7 @@ package ${basePackage}.${table.moduleName}.controller.${table.businessName};
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*;
@@ -18,6 +19,9 @@ import static ${CommonResultClassName}.success;
import ${ExcelUtilsClassName};
import ${OperateLogClassName};
import static ${OperateTypeEnumClassName}.*;
import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*;
import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
@@ -33,22 +37,25 @@ public class ${table.className}Controller {
@Resource
private ${table.className}Service ${classNameVar}Service;
@ApiOperation("创建${table.classComment}")
@PostMapping("/create")
@ApiOperation("创建${table.classComment}")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:create')")
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO) {
return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
}
@ApiOperation("更新${table.classComment}")
@PutMapping("/update")
@ApiOperation("更新${table.classComment}")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:update')")
public CommonResult<Boolean> update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO) {
${classNameVar}Service.update${simpleClassName}(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除${table.classComment}")
@DeleteMapping("/delete")
@ApiImplicitParam(name = "id", value = "编号", required = true)
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:delete')")
public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
${classNameVar}Service.delete${simpleClassName}(id);
return success(true);
@@ -57,6 +64,7 @@ public class ${table.className}Controller {
@GetMapping("/get")
@ApiOperation("获得${table.classComment}")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class)
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
public CommonResult<${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
return success(${table.className}Convert.INSTANCE.convert(${classNameVar}));
@@ -65,13 +73,15 @@ public class ${table.className}Controller {
@GetMapping("/list")
@ApiOperation("获得${table.classComment}列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
public CommonResult<List<${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) {
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids);
return success(${table.className}Convert.INSTANCE.convertList(list));
}
@ApiOperation("获得${table.classComment}分页")
@GetMapping("/page")
@ApiOperation("获得${table.classComment}分页")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
public CommonResult<PageResult<${table.className}RespVO>> get${simpleClassName}Page(@Valid ${table.className}PageReqVO pageVO) {
PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO);
return success(${table.className}Convert.INSTANCE.convertPage(pageResult));
@@ -79,6 +89,8 @@ public class ${table.className}Controller {
@GetMapping("/export-excel")
@ApiOperation("导出${table.classComment} Excel")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
@OperateLog(type = EXPORT)
public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO);