Commit 25259540 authored by ourfbht's avatar ourfbht
Browse files

refactored all files (in folders, indent, ...)

parent aed6a607
Loading
Loading
Loading
Loading
+0 −105
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.model.User;

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'T'HH:mm")
	private Date dateBegin;

	@Column
	@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm")
	private Date dateEnd;
	
	@Column
	private String comment;
	
	@ManyToOne
	private User mentor;

	@ManyToOne
	private User poulain;

	public HelpProposition() {

	}

	public Integer getId() {
		return id;
	}

	public String getMatiere() {
		return matiere;
	}

	public Date getDateBegin() {
		return dateBegin;
	}
	
	public Date getDateEnd() {
		return dateEnd;
	}
	
	public String getComment() {
		return comment;
	}

	public User getMentor(){
		return mentor;
	}

	public User getPoulain(){
		return poulain;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}

	public void setMatiere(String matiere) {
		this.matiere = matiere;
	}

	public void setDateBegin(Date date) {
		this.dateBegin = date;
	}

	public void setDateEnd(Date date) {
		this.dateEnd = date;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public void setMentor(User mentor) {
		this.mentor = mentor;
	}
	
	public void setPoulain(User poulain) {
		this.poulain = poulain;
	}
}
+0 −76
Original line number Diff line number Diff line
package com.example.demo;

import java.security.Principal;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
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.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import com.example.demo.HelpPropositionRepository;
import com.example.demo.model.User;
import com.example.demo.service.UserServiceInterface;


@Controller
public class HelpPropositionController {
	@Autowired 
	HelpPropositionRepository helpPropositionRepository;
	@Autowired 
	private UserServiceInterface userService;
	
    @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, HttpSession session, Principal principal) {

		String email = SecurityContextHolder.getContext().getAuthentication().getName();
		User user = userService.findByEmail(email);


		helpProposition.setMentor(user);

		helpPropositionRepository.save(helpProposition);
		return "formHelpProposition";
	}

	@GetMapping("/allPropositionByMentor")
	public String getallPropositionByMentor(Map<String, Object> model, HttpSession session, Principal principal) {

		String email = SecurityContextHolder.getContext().getAuthentication().getName();
		User user = userService.findByEmail(email);
		
		model.put("helpPropositions", helpPropositionRepository.findByMentor(user));
		return "ProfileHelpProposition";
	}

	@GetMapping("/editProposition/{id}")
	public String editProposition(@PathVariable("id") Integer helpId, Model model, HttpSession session, Principal principal) {
		HelpProposition helpProposition = helpPropositionRepository.findById(helpId);
		
	   	String email = SecurityContextHolder.getContext().getAuthentication().getName();
	  	User user = userService.findByEmail(email);
	   
		helpProposition.setPoulain(user);

		helpPropositionRepository.save(helpProposition);
		return "allHelpProposition";
	}
}
+0 −104
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.model.User;

import org.springframework.format.annotation.DateTimeFormat;


@Entity
@Table(name = "helprequest")
public class HelpRequest {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column
	private Integer id;

	@Column
	private String matiere;
	
	@Column
	@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm")
	private Date dateBegin;

	@Column
	@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm")
	private Date dateEnd;
	
	@Column
	private String comment;
	
	@ManyToOne
	private User poulain;

	@ManyToOne
	private User mentor;


	public HelpRequest() {

	}

	public Integer getId() {
		return id;
	}

	public String getMatiere() {
		return matiere;
	}

	public Date getDateBegin() {
		return dateBegin;
	}
	public Date getDateEnd() {
		return dateEnd;
	}
	
	public String getComment() {
		return comment;
	}

	public User getPoulain(){
		return poulain;
	}

	public User getMentor(){
		return mentor;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}

	public void setMatiere(String matiere) {
		this.matiere = matiere;
	}

	public void setDateBegin(Date date) {
		this.dateBegin = date;
	}
	
	public void setDateEnd(Date date) {
		this.dateEnd = date;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public void setPoulain(User poulain) {
		this.poulain = poulain;
	}

	public void setMentor(User mentor) {
		this.mentor = mentor;
	}
}
+75 −0
Original line number Diff line number Diff line
package com.example.demo.controller;

import java.security.Principal;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
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.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import com.example.demo.model.HelpProposition;
import com.example.demo.model.User;
import com.example.demo.repository.HelpPropositionRepository;
import com.example.demo.service.IUserService;

@Controller
public class HelpPropositionController {

    @Autowired 
    HelpPropositionRepository helpPropositionRepository;

    @Autowired 
    private IUserService userService;
    
    @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, HttpSession session, Principal principal) {

        String email = SecurityContextHolder.getContext().getAuthentication().getName();
        User user = userService.findByEmail(email);

        helpProposition.setMentor(user);

        helpPropositionRepository.save(helpProposition);
        return "formHelpProposition";
    }

    @GetMapping("/allPropositionByMentor")
    public String getallPropositionByMentor(Map<String, Object> model, HttpSession session, Principal principal) {

        String email = SecurityContextHolder.getContext().getAuthentication().getName();
        User user = userService.findByEmail(email);
        
        model.put("helpPropositions", helpPropositionRepository.findByMentor(user));
        return "ProfileHelpProposition";
    }

    @GetMapping("/editProposition/{id}")
    public String editProposition(@PathVariable("id") Integer helpId, Model model, HttpSession session, Principal principal) {
        HelpProposition helpProposition = helpPropositionRepository.findById(helpId);
        
        String email = SecurityContextHolder.getContext().getAuthentication().getName();
        User user = userService.findByEmail(email);
    
        helpProposition.setPoulain(user);

        helpPropositionRepository.save(helpProposition);
        return "allHelpProposition";
    }
}
+83 −0
Original line number Diff line number Diff line
package com.example.demo;
package com.example.demo.controller;

import java.security.Principal;
import java.util.Map;
@@ -13,10 +13,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.HelpRequestRepository;
import com.example.demo.model.User;

import com.example.demo.service.UserServiceInterface;
import com.example.demo.model.HelpRequest;
import com.example.demo.model.User;
import com.example.demo.repository.HelpRequestRepository;
import com.example.demo.service.IUserService;



@@ -26,7 +27,7 @@ public class HelpRequestController {
    HelpRequestRepository helpRequestRepository;
    
    @Autowired 
	private UserServiceInterface userService;
    private IUserService userService;

    
    @GetMapping("/allHelpRequest")
Loading