You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.9 KiB
54 lines
1.9 KiB
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(@RequestBody ${modelNameUpperCamel} ${modelNameLowerCamel}) {
|
|
${modelNameLowerCamel}Service.save(${modelNameLowerCamel});
|
|
return ResultGenerator.genSuccessResult();
|
|
}
|
|
|
|
@DeleteMapping("/{id}")
|
|
public Result delete(@PathVariable Integer id) {
|
|
${modelNameLowerCamel}Service.deleteById(id);
|
|
return ResultGenerator.genSuccessResult();
|
|
}
|
|
|
|
@PutMapping
|
|
public Result update(@RequestBody ${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(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
|
|
PageHelper.startPage(page, size);
|
|
List<${modelNameUpperCamel}> list = ${modelNameLowerCamel}Service.findAll();
|
|
PageInfo pageInfo = new PageInfo(list);
|
|
return ResultGenerator.genSuccessResult(pageInfo);
|
|
}
|
|
}
|
|
|