SpringBootCodeGenerator
SpringBootCodeGenerator copied to clipboard
Can you support RESTful contoller?
sure . may i know which controller model did you use .
hi Geroge , would you please provide the RESTFul templates so that i can migrate it to 3.0 version
Here is a sample code:
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
@RestController
@RequestMapping("/foos")
@RequiredArgsConstructor
public class FooController {
private final IFooService service;
@PostMapping
public Foo create(@RequestBody @Valid Foo resource) {
return service.create(resource);
}
@GetMapping
public PageResponse<Foo> search(Foo param, PageParam pageParam) {
return service.search(param,pageParam);
}
@PutMapping(value = "/{id}")
public Foo update(@PathVariable( "id" ) Long id, @RequestBody @Valid Foo resource) {
service.update(resource);
}
@DeleteMapping(value = "/{id}")
public void delete(@PathVariable("id") Long id) {
service.deleteById(id);
}
}
public class PageParam{
private Integer pageNum;
private Integer pageSize;
//getter/setter...
}
public class PageResponse<T>{
private int total;
private List<T> list;
//getter/setter...
}