Merge remote-tracking branch 'origin/LeoMoulin/Backend/Leo' into LeoMoulin/Backend/Leo
This commit is contained in:
		| @ -0,0 +1,27 @@ | |||||||
|  | package ovh.herisson.Clyde.EndPoints; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | import org.springframework.web.bind.annotation.*; | ||||||
|  | import ovh.herisson.Clyde.Repositories.UserRepository; | ||||||
|  | import ovh.herisson.Clyde.Tables.User; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @RestController | ||||||
|  | @CrossOrigin(origins = "http://localhost:5173") | ||||||
|  | public class UserController { | ||||||
|  |  | ||||||
|  |     private final UserRepository userRepo; | ||||||
|  |  | ||||||
|  |     public UserController(UserRepository userRepo){ | ||||||
|  |         this.userRepo = userRepo; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("/users") | ||||||
|  |     public Iterable<User> getUsers(){ | ||||||
|  |         return userRepo.findAll(); | ||||||
|  |     } | ||||||
|  |     @PostMapping("/users") | ||||||
|  |     public void postUser(@RequestBody User user ){ | ||||||
|  |         userRepo.save(user); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,16 @@ | |||||||
|  | package ovh.herisson.Clyde.Repositories; | ||||||
|  |  | ||||||
|  | import org.springframework.data.jpa.repository.Query; | ||||||
|  | import org.springframework.data.repository.CrudRepository; | ||||||
|  | import ovh.herisson.Clyde.Tables.User; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | public interface UserRepository extends CrudRepository<User, Long> { | ||||||
|  |  | ||||||
|  |     User findById(long id); | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |     @Query(value = "select a.* from Users a ",nativeQuery = true) | ||||||
|  |     Iterable<User> findAllUsers();**/ | ||||||
|  | } | ||||||
| @ -14,7 +14,6 @@ public class User { | |||||||
|     @Id |     @Id | ||||||
|     @GeneratedValue(strategy = GenerationType.AUTO) |     @GeneratedValue(strategy = GenerationType.AUTO) | ||||||
|     private int RegNo; |     private int RegNo; | ||||||
|  |  | ||||||
|     private String LastName; |     private String LastName; | ||||||
|     private String FirstName; |     private String FirstName; | ||||||
|     private String Email; |     private String Email; | ||||||
| @ -32,4 +31,60 @@ public class User { | |||||||
|     public User() { |     public User() { | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public String getLastName() { | ||||||
|  |         return LastName; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setLastName(String LastName) { | ||||||
|  |         this.LastName = LastName; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public String getFirstName() { | ||||||
|  |         return FirstName; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setFirstName(String firstName) { | ||||||
|  |         FirstName = firstName; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public String getEmail() { | ||||||
|  |         return Email; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setEmail(String email) { | ||||||
|  |         Email = email; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public String getAdress() { | ||||||
|  |         return Adress; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setAdress(String adress) { | ||||||
|  |         Adress = adress; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public String getCountry() { | ||||||
|  |         return Country; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setCountry(String country) { | ||||||
|  |         Country = country; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public Date getBirthDate() { | ||||||
|  |         return BirthDate; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setBirthDate(Date birthDate) { | ||||||
|  |         BirthDate = birthDate; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public ovh.herisson.Clyde.Tables.Role getRole() { | ||||||
|  |         return Role; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setRole(ovh.herisson.Clyde.Tables.Role role) { | ||||||
|  |         Role = role; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1 +1,2 @@ | |||||||
|  | spring.jpa.hibernate.ddl-auto=create-drop | ||||||
|  | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user