Commit 7d099076 authored by Alexandre Ducarne's avatar Alexandre Ducarne

Load objects from bdd

parent 50bc8832
package com.RESTAPI.RESTAPI.Controllers;
import com.RESTAPI.RESTAPI.Repositories.SujetRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping(path="/sujet")
public class SujetController {
@Autowired
private SujetRepository sujetRepository;
// @PutMapping(path = "/")
// public @ResponseBody
// Sujet createSujet(@RequestBody Sujet id) {
//// return compteRepository.findById(id).get();
// }
}
\ No newline at end of file
package com.RESTAPI.RESTAPI.Controllers; package com.RESTAPI.RESTAPI.Controllers;
import com.RESTAPI.RESTAPI.Entities.Compte;
import com.RESTAPI.RESTAPI.Entities.User; import com.RESTAPI.RESTAPI.Entities.User;
import com.RESTAPI.RESTAPI.Repositories.UserRepository; import com.RESTAPI.RESTAPI.Repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -16,7 +17,7 @@ public class UserController { ...@@ -16,7 +17,7 @@ public class UserController {
@PutMapping(path="/") @PutMapping(path="/")
public @ResponseBody public @ResponseBody
User addNewUser (@RequestBody String name, String ) { User addNewUser (@ModelAttribute User user, @ModelAttribute Compte compte) {
userRepository.save(user); userRepository.save(user);
return user; return user;
} }
......
...@@ -10,7 +10,6 @@ public class Avis { ...@@ -10,7 +10,6 @@ public class Avis {
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id; private Integer id;
private String choix; private String choix;
private String commentaire; private String commentaire;
......
...@@ -5,6 +5,8 @@ import lombok.Getter; ...@@ -5,6 +5,8 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import java.util.Date; import java.util.Date;
...@@ -14,6 +16,8 @@ import java.util.Date; ...@@ -14,6 +16,8 @@ import java.util.Date;
@Builder @Builder
public class Compte { public class Compte {
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
private String email; private String email;
private String mdp; private String mdp;
private Boolean status; private Boolean status;
......
package com.RESTAPI.RESTAPI.Entities;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "status_sujets")
public class StatusSujet {
@Id
private String status;
}
package com.RESTAPI.RESTAPI.Entities; package com.RESTAPI.RESTAPI.Entities;
import javax.persistence.*; import javax.persistence.Entity;
import java.time.LocalDateTime; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
@Entity @Entity
public class Sujet { public class Sujet {
...@@ -9,7 +12,6 @@ public class Sujet { ...@@ -9,7 +12,6 @@ public class Sujet {
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id; private Integer id;
private String nom; private String nom;
private LocalDateTime dateFinPhase; private Date dateFinPhase;
@ManyToOne private String status;
private StatusSujet status;
} }
package com.RESTAPI.RESTAPI.Repositories;
import com.RESTAPI.RESTAPI.Entities.Compte;
import org.springframework.data.repository.CrudRepository;
public interface SujetRepository extends CrudRepository<Compte, Integer> {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment