LeoMoulin/Backend/Leo #55

Merged
tonitch merged 11 commits from LeoMoulin/Backend/Leo into master 2024-03-05 23:42:00 +01:00
4 changed files with 101 additions and 2 deletions
Showing only changes of commit 3956037ab5 - Show all commits

View File

@ -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);
}
}

View File

@ -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();**/
}

View File

@ -14,7 +14,6 @@ public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int RegNo;
private String LastName;
private String FirstName;
private String Email;
@ -32,4 +31,60 @@ public class 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;
}
}

View File

@ -1 +1,2 @@
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect