parent
cbd918c288
commit
188b20ee84
@ -0,0 +1,53 @@ |
||||
package ${basePackage}.web; |
||||
|
||||
import ${basePackage}.core.Result; |
||||
import ${basePackage}.core.ResultGenerator; |
||||
import ${basePackage}.model.${modelNameUpperCamel}; |
||||
import ${basePackage}.service.${modelNameUpperCamel}Service; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by ${author} on ${date}. |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("${baseRequestMapping}") |
||||
public class ${modelNameUpperCamel}Controller { |
||||
@Resource |
||||
private ${modelNameUpperCamel}Service ${modelNameLowerCamel}Service; |
||||
|
||||
@PostMapping |
||||
public Result add(${modelNameUpperCamel} ${modelNameLowerCamel}) { |
||||
${modelNameLowerCamel}Service.save(${modelNameLowerCamel}); |
||||
return ResultGenerator.genSuccessResult(); |
||||
} |
||||
|
||||
@DeleteMapping("/{id}") |
||||
public Result delete(@PathVariable Integer id) { |
||||
userService.deleteById(id); |
||||
return ResultGenerator.genSuccessResult(); |
||||
} |
||||
|
||||
@PutMapping |
||||
public Result update(${modelNameUpperCamel} ${modelNameLowerCamel}) { |
||||
${modelNameLowerCamel}Service.update(${modelNameLowerCamel}); |
||||
return ResultGenerator.genSuccessResult(); |
||||
} |
||||
@GetMapping("/{id}") |
||||
public Result detail(@PathVariable Integer id) { |
||||
${modelNameUpperCamel} ${modelNameLowerCamel} = ${modelNameLowerCamel}Service.findById(id); |
||||
return ResultGenerator.genSuccessResult(${modelNameLowerCamel}); |
||||
} |
||||
|
||||
@GetMapping |
||||
public Result list(Integer page, Integer size) { |
||||
PageHelper.startPage(page, size); |
||||
List<${modelNameUpperCamel}> list = ${modelNameLowerCamel}Service.findAll(); |
||||
PageInfo pageInfo = new PageInfo(list); |
||||
return ResultGenerator.genSuccessResult(pageInfo); |
||||
} |
||||
} |
Loading…
Reference in new issue