Loading src/main/java/com/example/demo/HelpProposition.java 0 → 100644 +81 −0 Original line number Diff line number Diff line package com.example.demo; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.Table; import com.example.demo.Mentor; import org.springframework.format.annotation.DateTimeFormat; @Entity @Table(name = "helpproposition") public class HelpProposition { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column private Integer id; @Column private String matiere; @Column @DateTimeFormat(pattern = "yyyy-MM-dd") private Date date; @Column private String comment; @ManyToOne private Mentor mentor; public HelpProposition() { } public Integer getId() { return id; } public String getMatiere() { return matiere; } public Date getDate() { return date; } public String getComment() { return comment; } public Mentor getMentor(){ return mentor; } public void setId(Integer id) { this.id = id; } public void setMatiere(String matiere) { this.matiere = matiere; } public void setDate(Date date) { this.date = date; } public void setComment(String comment) { this.comment = comment; } public void setMentor(Mentor mentor) { this.mentor = mentor; } } src/main/java/com/example/demo/HelpPropositionController.java 0 → 100644 +41 −0 Original line number Diff line number Diff line package com.example.demo; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; import com.example.demo.HelpPropositionRepository; @Controller public class HelpPropositionController { @Autowired HelpPropositionRepository helpPropositionRepository; @GetMapping("/allHelpProposition") public String getAll(Map<String, Object> model) { model.put("helpPropositions", helpPropositionRepository.findAll()); return "allHelpProposition"; } @GetMapping("/formHelpProposition") public String helpPropositionForm(Model model) { model.addAttribute("helpProposition", new HelpProposition()); return "formHelpProposition"; } @PostMapping("/insertHelpProposition") public String insertHelpProposition(@ModelAttribute HelpProposition helpProposition, Model model) { //TODO : recup le mentor loggé Mentor mentor= new Mentor(); mentor.setId(1); helpProposition.setMentor(mentor); helpPropositionRepository.save(helpProposition); return "formHelpProposition"; } } src/main/java/com/example/demo/HelpPropositionRepository.java 0 → 100644 +7 −0 Original line number Diff line number Diff line package com.example.demo; import org.springframework.data.jpa.repository.JpaRepository; import com.example.demo.HelpProposition; public interface HelpPropositionRepository extends JpaRepository <HelpProposition, Long> { } src/main/resources/templates/allHelpProposition.html 0 → 100644 +30 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="ISO-8859-1"> <title>All Help Request</title> </head> <body> <h1>All Help Request</h1> <table class="table"> <thead> <tr> <th scope="col">Id</th> <th scope="col">Matiere</th> <th scope="col">Date</th> <th scope="col">Comment</th> <th scope="col">Poulain</th> </tr> </thead> <tbody> <tr th:each="help: ${helpPropositions}"> <td th:text="${help.id}" /> <td th:text="${help.matiere}" /> <td th:text="${#dates.format(help.date, 'dd-MM-yyyy')}"/> <td th:text="${help.comment}" /> <td th:text="${help.mentor.id}" /> </tr> </tbody> </table> </body> </html> src/main/resources/templates/formHelpProposition.html 0 → 100644 +17 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="ISO-8859-1"> <title>Form HelpProposition</title> </head> <body> <h1>Form HelpProposition</h1> <form action="#" th:action="@{/insertHelpProposition}" th:object="${helpProposition}" method="post"> <p>HelpRequest matiere: <input type="text" th:field="*{matiere}" /></p> <p>HelpRequest date: <input type="date" th:field="*{{date}}" /></p> <p>HelpRequest comment: <input type="text" th:field="*{comment}" /></p> <p>HelpRequest Poulain : TODO recup id Mentor</p> <p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p> </form> </body> </html> Loading
src/main/java/com/example/demo/HelpProposition.java 0 → 100644 +81 −0 Original line number Diff line number Diff line package com.example.demo; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.Table; import com.example.demo.Mentor; import org.springframework.format.annotation.DateTimeFormat; @Entity @Table(name = "helpproposition") public class HelpProposition { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column private Integer id; @Column private String matiere; @Column @DateTimeFormat(pattern = "yyyy-MM-dd") private Date date; @Column private String comment; @ManyToOne private Mentor mentor; public HelpProposition() { } public Integer getId() { return id; } public String getMatiere() { return matiere; } public Date getDate() { return date; } public String getComment() { return comment; } public Mentor getMentor(){ return mentor; } public void setId(Integer id) { this.id = id; } public void setMatiere(String matiere) { this.matiere = matiere; } public void setDate(Date date) { this.date = date; } public void setComment(String comment) { this.comment = comment; } public void setMentor(Mentor mentor) { this.mentor = mentor; } }
src/main/java/com/example/demo/HelpPropositionController.java 0 → 100644 +41 −0 Original line number Diff line number Diff line package com.example.demo; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; import com.example.demo.HelpPropositionRepository; @Controller public class HelpPropositionController { @Autowired HelpPropositionRepository helpPropositionRepository; @GetMapping("/allHelpProposition") public String getAll(Map<String, Object> model) { model.put("helpPropositions", helpPropositionRepository.findAll()); return "allHelpProposition"; } @GetMapping("/formHelpProposition") public String helpPropositionForm(Model model) { model.addAttribute("helpProposition", new HelpProposition()); return "formHelpProposition"; } @PostMapping("/insertHelpProposition") public String insertHelpProposition(@ModelAttribute HelpProposition helpProposition, Model model) { //TODO : recup le mentor loggé Mentor mentor= new Mentor(); mentor.setId(1); helpProposition.setMentor(mentor); helpPropositionRepository.save(helpProposition); return "formHelpProposition"; } }
src/main/java/com/example/demo/HelpPropositionRepository.java 0 → 100644 +7 −0 Original line number Diff line number Diff line package com.example.demo; import org.springframework.data.jpa.repository.JpaRepository; import com.example.demo.HelpProposition; public interface HelpPropositionRepository extends JpaRepository <HelpProposition, Long> { }
src/main/resources/templates/allHelpProposition.html 0 → 100644 +30 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="ISO-8859-1"> <title>All Help Request</title> </head> <body> <h1>All Help Request</h1> <table class="table"> <thead> <tr> <th scope="col">Id</th> <th scope="col">Matiere</th> <th scope="col">Date</th> <th scope="col">Comment</th> <th scope="col">Poulain</th> </tr> </thead> <tbody> <tr th:each="help: ${helpPropositions}"> <td th:text="${help.id}" /> <td th:text="${help.matiere}" /> <td th:text="${#dates.format(help.date, 'dd-MM-yyyy')}"/> <td th:text="${help.comment}" /> <td th:text="${help.mentor.id}" /> </tr> </tbody> </table> </body> </html>
src/main/resources/templates/formHelpProposition.html 0 → 100644 +17 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="ISO-8859-1"> <title>Form HelpProposition</title> </head> <body> <h1>Form HelpProposition</h1> <form action="#" th:action="@{/insertHelpProposition}" th:object="${helpProposition}" method="post"> <p>HelpRequest matiere: <input type="text" th:field="*{matiere}" /></p> <p>HelpRequest date: <input type="date" th:field="*{{date}}" /></p> <p>HelpRequest comment: <input type="text" th:field="*{comment}" /></p> <p>HelpRequest Poulain : TODO recup id Mentor</p> <p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p> </form> </body> </html>