test controller
This commit is contained in:
@@ -3,9 +3,8 @@ package hackathon.FrisbYEE.jpa.metier;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,11 +1,51 @@
|
||||
package hackathon.FrisbYEE.jpa.web;
|
||||
|
||||
|
||||
import hackathon.FrisbYEE.jpa.metier.Activite;
|
||||
import hackathon.FrisbYEE.jpa.service.ActiviteDAO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/activite")
|
||||
|
||||
public class ActiviteController {
|
||||
@Autowired
|
||||
private ActiviteDAO activiteDAO;
|
||||
|
||||
/*
|
||||
POST /activite/create
|
||||
DELETE /activite/delete/{id}
|
||||
|
||||
*/
|
||||
|
||||
@PostMapping("/create")
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('Coach')")
|
||||
public String create(@PathVariable("id") int id) {
|
||||
String activiteID = "";
|
||||
String activiteNom = "";
|
||||
try {
|
||||
Activite activite = new Activite();
|
||||
|
||||
} catch (Exception ex) {
|
||||
return ex.toString();
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('Coach')")
|
||||
public String delete(@PathVariable("id") int id) {
|
||||
try {
|
||||
Activite activite = activiteDAO.findById(id).get();
|
||||
activiteDAO.delete(activite);
|
||||
} catch (Exception ex) {
|
||||
return ex.toString();
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user