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;
import com.RESTAPI.RESTAPI.Entities.Compte;
import com.RESTAPI.RESTAPI.Entities.User;
import com.RESTAPI.RESTAPI.Repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -16,7 +17,7 @@ public class UserController {
@PutMapping(path="/")
public @ResponseBody
User addNewUser (@RequestBody String name, String ) {
User addNewUser (@ModelAttribute User user, @ModelAttribute Compte compte) {
userRepository.save(user);
return user;
}
......
......@@ -10,7 +10,6 @@ public class Avis {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
private String choix;
private String commentaire;
......
......@@ -5,6 +5,8 @@ import lombok.Getter;
import lombok.Setter;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
......@@ -14,6 +16,8 @@ import java.util.Date;
@Builder
public class Compte {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
private String email;
private String mdp;
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;
import javax.persistence.*;
import java.time.LocalDateTime;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
@Entity
public class Sujet {
......@@ -9,7 +12,6 @@ public class Sujet {
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
private String nom;
private LocalDateTime dateFinPhase;
@ManyToOne
private StatusSujet status;
private Date dateFinPhase;
private String 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