Guest User

Untitled

a guest
Jun 9th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package com.example;
  2.  
  3. import org.springframework.boot.SpringApplication;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5. import org.springframework.web.bind.annotation.PostMapping;
  6. import org.springframework.web.bind.annotation.PathVariable;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import org.springframework.http.ResponseEntity;
  9.  
  10. @SpringBootApplication
  11. @RestController
  12. public class App {
  13.     public static class MyEntity {
  14.         private long id;
  15.         private String value;
  16.         public MyEntity() { }
  17.         public MyEntity(long id, String value) { this.id = id; this.value = value; }
  18.         public long getId() { return id; }
  19.         public String getValue() { return value; }
  20.     }
  21.  
  22.     @PostMapping("/api/myentity/{id}/clone")
  23.     public ResponseEntity<MyEntity> cloneMyEntity(@PathVariable("id") long id) {
  24.         return ResponseEntity.ok(new MyEntity(id + 1, "my entity"));
  25.     }
  26.  
  27.     public static void main(String[] args) {
  28.         SpringApplication.run(App.class, args);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment