|
@@ -1,63 +1,76 @@
|
|
|
+package ${basePackage}.${table.moduleName}.controller.${table.businessName};
|
|
|
+
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+
|
|
|
import io.swagger.annotations.*;
|
|
|
+
|
|
|
import javax.validation.constraints.*;
|
|
|
import javax.validation.*;
|
|
|
import java.util.*;
|
|
|
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
+import ${PageResultClassName};
|
|
|
+import ${CommonResultClassName};
|
|
|
+import static ${CommonResultClassName}.success;
|
|
|
+
|
|
|
+import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*;
|
|
|
+import ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.businessName}.${table.className}DO;
|
|
|
+import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
|
|
+import ${basePackage}.${table.moduleName}.service.${table.businessName}.${table.className}Service;
|
|
|
|
|
|
-/**
|
|
|
- * ${class.description} Controller
|
|
|
- */
|
|
|
+@Api(tags = "${table.classComment}")
|
|
|
@RestController
|
|
|
-@RequestMapping("/${class.classNameLowerUnderscore}")
|
|
|
-@Api(tags = "${class.description}")
|
|
|
+##二级的 businessName 暂时不算在 HTTP 路径上,可以根据需要写
|
|
|
+@RequestMapping("/${table.moduleName}/${simpleClassName_strikeCase}")
|
|
|
@Validated
|
|
|
-public class ${class.className}Controller {
|
|
|
+public class ${table.className}Controller {
|
|
|
|
|
|
- @Autowired
|
|
|
- private ${class.className}Service ${class.classNameVar}Service;
|
|
|
+ @Resource
|
|
|
+ private ${table.className}Service ${classNameVar}Service;
|
|
|
|
|
|
+ @ApiOperation("创建${table.classComment}")
|
|
|
@PostMapping("/create")
|
|
|
- @ApiOperation("创建${class.description}")
|
|
|
- public CommonResult<Integer> create${class.className}(@Valid ${class.className}CreateReqVO createVO) {
|
|
|
- return success(${class.classNameVar}Service.create${class.className}(createVO));
|
|
|
+ public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO) {
|
|
|
+ return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/update")
|
|
|
- @ApiOperation("更新${class.description}")
|
|
|
- public CommonResult<Boolean> update${class.className}(@Valid ${class.className}UpdateReqVO updateVO) {
|
|
|
- ${class.classNameVar}Service.update${class.className}(updateVO);
|
|
|
+ @ApiOperation("更新${table.classComment}")
|
|
|
+ @PutMapping("/update")
|
|
|
+ public CommonResult<Boolean> update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO) {
|
|
|
+ ${classNameVar}Service.update${simpleClassName}(updateReqVO);
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/delete")
|
|
|
- @ApiOperation("删除${class.description}")
|
|
|
- @ApiImplicitParam(name = "${class.classNameVar}Id", value = "${class.description}编号", required = true)
|
|
|
- public CommonResult<Boolean> delete${class.className}(@RequestParam("${class.classNameVar}Id") Integer ${class.classNameVar}Id) {
|
|
|
- ${class.classNameVar}Service.delete${class.className}(${class.classNameVar}Id);
|
|
|
+ @ApiOperation("删除${table.classComment}")
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @ApiImplicitParam(name = "id", value = "编号", required = true)
|
|
|
+ public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
|
|
+ ${classNameVar}Service.delete${simpleClassName}(id);
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get")
|
|
|
- @ApiOperation("获得${class.description}")
|
|
|
- @ApiImplicitParam(name = "${class.classNameVar}Id", value = "${class.description}编号", required = true)
|
|
|
- public CommonResult<${class.className}RespVO> get${class.className}(@RequestParam("${class.classNameVar}Id") Integer ${class.classNameVar}Id) {
|
|
|
- return success(${class.classNameVar}Service.get${class.className}(${class.classNameVar}Id));
|
|
|
+ @ApiOperation("获得${table.classComment}")
|
|
|
+ @ApiImplicitParam(name = "id", value = "编号", required = true)
|
|
|
+ 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}));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
- @ApiOperation("获得${class.description}列表")
|
|
|
- @ApiImplicitParam(name = "${class.classNameVar}Ids", value = "${class.description}编号列表", required = true)
|
|
|
- public CommonResult<List<${class.className}RespVO>> list${class.className}s(@RequestParam("${class.classNameVar}Ids") List<Integer> ${class.classNameVar}Ids) {
|
|
|
- return success(${class.classNameVar}Service.list${class.className}s(${class.classNameVar}Ids));
|
|
|
+ @ApiOperation("获得${table.classComment}列表")
|
|
|
+ @ApiImplicitParam(name = "ids", value = "编号列表", required = true)
|
|
|
+ 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("获得${class.description}分页")
|
|
|
- public CommonResult<PageResult<${class.className}RespVO>> page${class.className}(${class.className}PageReqVO pageVO) {
|
|
|
- return success(${class.classNameVar}Service.page${class.className}(pageVO));
|
|
|
+ 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));
|
|
|
}
|
|
|
|
|
|
}
|