package ${basePackage}.${table.moduleName}.controller.${table.businessName}; import org.springframework.web.bind.annotation.*; 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 ${PageResultClassName}; import ${CommonResultClassName}; import static ${CommonResultClassName}.success; 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; import ${basePackage}.${table.moduleName}.service.${table.businessName}.${table.className}Service; @Api(tags = "${table.classComment}") @RestController ##二级的 businessName 暂时不算在 HTTP 路径上,可以根据需要写 @RequestMapping("/${table.moduleName}/${simpleClassName_strikeCase}") @Validated public class ${table.className}Controller { @Resource private ${table.className}Service ${classNameVar}Service; @ApiOperation("创建${table.classComment}") @PostMapping("/create") public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO) { return success(${classNameVar}Service.create${simpleClassName}(createReqVO)); } @ApiOperation("更新${table.classComment}") @PutMapping("/update") public CommonResult update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO) { ${classNameVar}Service.update${simpleClassName}(updateReqVO); return success(true); } @ApiOperation("删除${table.classComment}") @DeleteMapping("/delete") @ApiImplicitParam(name = "id", value = "编号", required = true) public CommonResult delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { ${classNameVar}Service.delete${simpleClassName}(id); return success(true); } @GetMapping("/get") @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("获得${table.classComment}列表") @ApiImplicitParam(name = "ids", value = "编号列表", required = true) public CommonResult> 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") public CommonResult> 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)); } }