started changes required by review
This commit is contained in:
parent
27332ff809
commit
a82677b3bb
@ -15,10 +15,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@Table(name = "site",
|
||||
uniqueConstraints = { @UniqueConstraint(columnNames = "name") })
|
||||
public class Site {
|
||||
@ -43,12 +45,4 @@ public class Site {
|
||||
this.address = address;
|
||||
this.jiInSite = new ArrayList<Ji>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Site{id=" + id + ", name='" + name + "', description='" +
|
||||
description + "', address='" + address + "'}";
|
||||
}
|
||||
|
||||
// public Site() {}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package fr.la_banquise.backend.rest;
|
||||
import fr.la_banquise.backend.rest.response.DashboardResponse;
|
||||
import fr.la_banquise.backend.services.InstanceService;
|
||||
import fr.la_banquise.backend.services.SujetService;
|
||||
import io.quarkus.security.Authenticated;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
@ -22,13 +23,14 @@ public class Endpoints {
|
||||
@Inject SujetService sujetService;
|
||||
|
||||
@GET
|
||||
@Authenticated
|
||||
@Path("dashboard")
|
||||
public Response getDashboard() {
|
||||
String username = identity.getPrincipal().getName();
|
||||
DashboardResponse dashboard = new DashboardResponse();
|
||||
dashboard.tps =
|
||||
sujetService.getAllSujetsRespo(identity.getPrincipal().getName());
|
||||
//dashboard.instances = instanceService.getAllInstances(username);
|
||||
// dashboard.instances = instanceService.getAllInstances(username);
|
||||
return Response.ok(dashboard).build();
|
||||
}
|
||||
}
|
||||
|
@ -41,13 +41,11 @@ public class JiResource {
|
||||
@Path("/create")
|
||||
@RolesAllowed("ROOT")
|
||||
public Response createJi(@QueryParam("name") String name,
|
||||
@QueryParam("desc") String desc, // TODO : change
|
||||
// desc to date
|
||||
@QueryParam("address") String address,
|
||||
@QueryParam("date") String date,
|
||||
@QueryParam("respo") String respo,
|
||||
@QueryParam("site") String name_site) {
|
||||
try {
|
||||
Ji jsp = jiService.createJi(name, desc, address, name_site);
|
||||
Ji jsp = jiService.createJi(name, date, respo, name_site);
|
||||
return Response.ok(Map.of("created", jsp)).build();
|
||||
} catch (Exception e) {
|
||||
return Response.status(500)
|
||||
@ -72,7 +70,7 @@ public class JiResource {
|
||||
|
||||
@DELETE
|
||||
@Path("/del")
|
||||
@RolesAllowed("root")
|
||||
@RolesAllowed("ROOT")
|
||||
@APIResponses({
|
||||
@APIResponse(responseCode = "200", description = "Successfully deleted")
|
||||
, @APIResponse(responseCode = "500",
|
||||
@ -90,48 +88,4 @@ public class JiResource {
|
||||
.build();
|
||||
}
|
||||
}
|
||||
/*
|
||||
@GET
|
||||
@Path("/all")
|
||||
public Response listContainers() {
|
||||
try {
|
||||
String id = dockerService.listAllContainers();
|
||||
return Response.ok(id).build();
|
||||
} catch (Exception e) {
|
||||
return Response.status(500).entity(Map.of("error",
|
||||
e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/start")
|
||||
public Response start(@QueryParam("id") String id) {
|
||||
try {
|
||||
dockerService.start(id);
|
||||
return Response.ok(Map.of("containerId", id, "status",
|
||||
"Running")).build(); } catch (Exception e) { return
|
||||
Response.status(500).entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/stop")
|
||||
public Response stop(@QueryParam("id") String id) {
|
||||
try {
|
||||
dockerService.stop(id);
|
||||
return Response.ok(Map.of("containerId", id, "status",
|
||||
"removed")).build(); } catch (Exception e) { return
|
||||
Response.status(500).entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
@DELETE
|
||||
@Path("/remove")
|
||||
public Response remove(@QueryParam("id") String id) {
|
||||
try {
|
||||
dockerService.remove(id);
|
||||
return Response.ok(Map.of("containerId", id, "status",
|
||||
"removed")).build(); } catch (Exception e) { return
|
||||
Response.status(500).entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import java.util.Map;
|
||||
/**
|
||||
* TpEndpoints
|
||||
*/
|
||||
@Path("/api/subject")
|
||||
@Path("/api/subjects")
|
||||
public class SujetEndpoints {
|
||||
|
||||
@Inject SecurityIdentity identity;
|
||||
@ -52,10 +52,10 @@ public class SujetEndpoints {
|
||||
@Path("/respo")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@RolesAllowed("ROOT")
|
||||
public Response addRespoSujet(@QueryParam("name_sujet") String name_sujet,
|
||||
@QueryParam("name_user") String name_user) {
|
||||
public Response addRespoSujet(@QueryParam("nameSujet") String nameSujet,
|
||||
@QueryParam("nameUser") String nameUser) {
|
||||
try {
|
||||
if (sujetService.addRespo(name_sujet, name_user)) {
|
||||
if (sujetService.addRespo(nameSujet, nameUser)) {
|
||||
return Response.ok("Respo added sucessfully.").build();
|
||||
}
|
||||
return Response.status(404)
|
||||
@ -71,11 +71,11 @@ public class SujetEndpoints {
|
||||
@DELETE
|
||||
@Path("/respo")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@RolesAllowed("root")
|
||||
public Response rmRespoSujet(@QueryParam("name_sujet") String name_sujet,
|
||||
@QueryParam("name_user") String name_user) {
|
||||
@RolesAllowed("ROOT")
|
||||
public Response rmRespoSujet(@QueryParam("nameSujet") String nameSujet,
|
||||
@QueryParam("nameUser") String nameUser) {
|
||||
try {
|
||||
if (sujetService.rmRespo(name_sujet, name_user)) {
|
||||
if (sujetService.rmRespo(nameSujet, nameUser)) {
|
||||
return Response.ok("Respo removed sucessfully.").build();
|
||||
}
|
||||
return Response.status(404)
|
||||
|
@ -68,9 +68,9 @@ public class SujetService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean addRespo(String name_sujet, String name_user) {
|
||||
User user = userRepository.find("name", name_user).firstResult();
|
||||
Sujet sujet = sujetRepository.find("name", name_sujet).firstResult();
|
||||
public boolean addRespo(String nameSujet, String nameUser) {
|
||||
User user = userRepository.find("name", nameUser).firstResult();
|
||||
Sujet sujet = sujetRepository.find("name", nameSujet).firstResult();
|
||||
if (!sujet.respos.contains(user)) {
|
||||
sujet.respos.add(user);
|
||||
return true;
|
||||
@ -79,9 +79,9 @@ public class SujetService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean rmRespo(String name_sujet, String name_user) {
|
||||
User user = userRepository.find("name", name_user).firstResult();
|
||||
Sujet sujet = sujetRepository.find("name", name_sujet).firstResult();
|
||||
public boolean rmRespo(String nameSujet, String nameUser) {
|
||||
User user = userRepository.find("name", nameUser).firstResult();
|
||||
Sujet sujet = sujetRepository.find("name", nameSujet).firstResult();
|
||||
if (sujet.respos.contains(user)) {
|
||||
sujet.respos.remove(user);
|
||||
return true;
|
||||
|
@ -45,7 +45,7 @@ public class UserService {
|
||||
userRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Transactional // wtf ? this is get user no ?
|
||||
@Transactional // wtf ? this is get user no ? EDIT : this is x)
|
||||
public User updateUser(Long id) {
|
||||
User user = userRepository.findById(id);
|
||||
return user;
|
||||
|
Loading…
x
Reference in New Issue
Block a user