|
|
@@ -1,14 +1,20 @@ |
|
|
|
package ${package}.${moduleName}.controller; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
package ${package}import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.xkcoding.common.R; |
|
|
|
import com.xkcoding.scaffold.log.annotations.ApiLog; |
|
|
|
import ${package}.${moduleName}.entity.${className}; |
|
|
|
import ${package}.${moduleName}.service.${className}Service; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
.${moduleName}.controller; |
|
|
|
${package} |
|
|
|
.${moduleName}.entity.${className}; |
|
|
|
${package} |
|
|
|
.${moduleName}.service.${className}Service; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* ${comments} |
|
|
@@ -25,6 +31,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
@RestController |
|
|
|
@AllArgsConstructor |
|
|
|
@RequestMapping("/${pathName}") |
|
|
|
@Api(description = "${className}Controller", tags = {"${comments}"}) |
|
|
|
public class ${className}Controller { |
|
|
|
|
|
|
|
private final ${className}Service ${classname}Service; |
|
|
@@ -36,6 +43,8 @@ public class ${className}Controller { |
|
|
|
* @return R |
|
|
|
*/ |
|
|
|
@GetMapping("") |
|
|
|
@ApiOperation(value = "分页查询${comments}", notes = "分页查询${comments}") |
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页参数", required = true), @ApiImplicitParam(name = "${classname}", value = "查询条件", required = true)}) |
|
|
|
public R list${className}(Page page, ${className} ${classname}) { |
|
|
|
return new R<>(${classname}Service.page(page,Wrappers.query(${classname}))); |
|
|
|
} |
|
|
@@ -47,6 +56,8 @@ public class ${className}Controller { |
|
|
|
* @return R |
|
|
|
*/ |
|
|
|
@GetMapping("/{${pk.lowerAttrName}}") |
|
|
|
@ApiOperation(value = "通过id查询${comments}", notes = "通过id查询${comments}") |
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "${pk.lowerAttrName}", value = "主键id", required = true)}) |
|
|
|
public R get${className}(@PathVariable("${pk.lowerAttrName}") ${pk.attrType} ${pk.lowerAttrName}){ |
|
|
|
return new R<>(${classname}Service.getById(${pk.lowerAttrName})); |
|
|
|
} |
|
|
@@ -58,6 +69,7 @@ public class ${className}Controller { |
|
|
|
*/ |
|
|
|
@ApiLog("新增${comments}") |
|
|
|
@PostMapping |
|
|
|
@ApiOperation(value = "新增${comments}", notes = "新增${comments}") |
|
|
|
public R save${className}(@RequestBody ${className} ${classname}){ |
|
|
|
return new R<>(${classname}Service.save(${classname})); |
|
|
|
} |
|
|
@@ -70,6 +82,8 @@ public class ${className}Controller { |
|
|
|
*/ |
|
|
|
@ApiLog("修改${comments}") |
|
|
|
@PutMapping("/{${pk.lowerAttrName}}") |
|
|
|
@ApiOperation(value = "修改${comments}", notes = "修改${comments}") |
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "${pk.lowerAttrName}", value = "主键id", required = true)}) |
|
|
|
public R update${className}(@PathVariable ${pk.attrType} ${pk.lowerAttrName}, @RequestBody ${className} ${classname}){ |
|
|
|
return new R<>(${classname}Service.updateById(${classname})); |
|
|
|
} |
|
|
@@ -81,6 +95,8 @@ public class ${className}Controller { |
|
|
|
*/ |
|
|
|
@ApiLog("删除${comments}") |
|
|
|
@DeleteMapping("/{${pk.lowerAttrName}}") |
|
|
|
@ApiOperation(value = "删除${comments}", notes = "删除${comments}") |
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "${pk.lowerAttrName}", value = "主键id", required = true)}) |
|
|
|
public R delete${className}(@PathVariable ${pk.attrType} ${pk.lowerAttrName}){ |
|
|
|
return new R<>(${classname}Service.removeById(${pk.lowerAttrName})); |
|
|
|
} |
|
|
|