Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you support RESTful contoller? #103

Open
GerogeLeon opened this issue Jan 6, 2021 · 3 comments
Open

Can you support RESTful contoller? #103

GerogeLeon opened this issue Jan 6, 2021 · 3 comments

Comments

@GerogeLeon
Copy link

No description provided.

@moshowgame
Copy link
Owner

sure . may i know which controller model did you use .

@moshowgame
Copy link
Owner

hi Geroge , would you please provide the RESTFul templates so that i can migrate it to 3.0 version

@GerogeLeon
Copy link
Author

GerogeLeon commented Jan 14, 2021

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...
  }
  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants