cleaning
This commit is contained in:
parent
20568ed0b2
commit
0c222fffc5
@ -57,18 +57,18 @@ public class User {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Dans l'ordre d'affichage dans le dashboard :
|
||||
@ManyToMany(mappedBy = "respos", cascade = CascadeType.ALL)
|
||||
public List<Ji> jiRespo;
|
||||
public List<Ji> jiRespo; // JI dont user est respo
|
||||
|
||||
@ManyToMany(mappedBy = "participants", cascade = CascadeType.ALL)
|
||||
public List<Ji> jiParticipant;
|
||||
|
||||
@OneToMany(mappedBy = "owner", cascade = CascadeType.ALL)
|
||||
public List<Instance> instances;
|
||||
public List<Ji> jiParticipant; // JI ou user est participant
|
||||
|
||||
@ManyToMany(mappedBy = "respos", cascade = CascadeType.ALL)
|
||||
public List<Sujet> sujetRespo;
|
||||
public List<Sujet> sujetRespo; // Sujet ou user est respo
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@OneToMany(mappedBy = "owner", cascade = CascadeType.ALL)
|
||||
public List<Instance> instances; // mouai, pas a afficher
|
||||
|
||||
// Méthode pour Quarkus Security - conversion simple
|
||||
@RolesValue
|
||||
@Roles
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package fr.la_banquise.backend.rest;
|
||||
|
||||
import fr.la_banquise.backend.data.model.User;
|
||||
import fr.la_banquise.backend.rest.response.DashboardResponse;
|
||||
import fr.la_banquise.backend.services.InstanceService;
|
||||
import fr.la_banquise.backend.services.SujetService;
|
||||
import fr.la_banquise.backend.services.UserService;
|
||||
import io.quarkus.security.Authenticated;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import jakarta.inject.Inject;
|
||||
@ -21,16 +23,21 @@ public class Endpoints {
|
||||
@Inject InstanceService instanceService;
|
||||
|
||||
@Inject SujetService sujetService;
|
||||
@Inject UserService userService;
|
||||
|
||||
|
||||
@GET
|
||||
@Authenticated
|
||||
@Path("dashboard")
|
||||
public Response getDashboard() {
|
||||
String username = identity.getPrincipal().getName();
|
||||
User user = userService.getUser(identity.getPrincipal().getName());
|
||||
DashboardResponse dashboard = new DashboardResponse();
|
||||
dashboard.tps =
|
||||
sujetService.getAllSujetsRespo(identity.getPrincipal().getName());
|
||||
// dashboard.instances = instanceService.getAllInstances(username);
|
||||
dashboard.roles = user.getRoles();
|
||||
|
||||
dashboard.jiRespo = user.jiRespo;
|
||||
dashboard.jiParticipant = user.jiParticipant;
|
||||
dashboard.sujetRespo = user.sujetRespo;
|
||||
|
||||
return Response.ok(dashboard).build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,30 @@
|
||||
package fr.la_banquise.backend.rest.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import fr.la_banquise.backend.data.model.Instance;
|
||||
import fr.la_banquise.backend.data.model.Ji;
|
||||
import fr.la_banquise.backend.data.model.Sujet;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.AllArgsConstructor;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* DashboardResponse
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class DashboardResponse {
|
||||
public List<Sujet> tps;
|
||||
public List<Instance> instances;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
////// Dans l'ordre d'affichage dans le dashboard :
|
||||
// Profil
|
||||
public String name;
|
||||
public Set<String> roles;
|
||||
|
||||
// A afficher dans des blocs differents
|
||||
public List<Ji> jiRespo;
|
||||
|
||||
public List<Ji> jiParticipant;
|
||||
|
||||
public List<Sujet> sujetRespo;
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
package fr.la_banquise.backend.services;
|
||||
|
||||
import com.github.dockerjava.api.DockerClient;
|
||||
import com.github.dockerjava.api.command.CreateContainerResponse;
|
||||
import com.github.dockerjava.api.command.InspectContainerResponse;
|
||||
import com.github.dockerjava.api.model.ExposedPort;
|
||||
import com.github.dockerjava.api.model.HostConfig;
|
||||
import com.github.dockerjava.api.model.Ports;
|
||||
|
||||
import fr.la_banquise.backend.data.model.Instance;
|
||||
import fr.la_banquise.backend.data.model.Ji;
|
||||
import fr.la_banquise.backend.data.model.User;
|
||||
@ -16,11 +10,8 @@ import fr.la_banquise.backend.data.repository.UserRepository;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -111,5 +102,4 @@ public class InstanceService {
|
||||
|
||||
return retour;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@ import io.quarkus.elytron.security.common.BcryptUtil;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -30,6 +29,7 @@ public class UserService {
|
||||
public List<User> getAllUsers() { return userRepository.listAll(); }
|
||||
|
||||
public User getUser(Long id) { return userRepository.findById(id); }
|
||||
public User getUser(String name) { return userRepository.findByName(name); }
|
||||
|
||||
@Transactional
|
||||
public User createUser(UserRequest request) {
|
||||
@ -96,7 +96,6 @@ public class UserService {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public RolesAsso fromString(String role_str) {
|
||||
return switch (role_str) {
|
||||
case "ROOT" -> RolesAsso.ROOT;
|
||||
@ -118,5 +117,4 @@ public class UserService {
|
||||
User user = userRepository.findById(userId);
|
||||
user.role.remove(fromString(role));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
-- Ce fichier est exécuté automatiquement en mode dev
|
||||
INSERT INTO penguin (name, password) VALUES ('root', '$2a$10$lzKAv4aj6s0jtneg0Ikx/eEBb6p.6N6yo7ZF.myqYxEA9MWbMwvNu');
|
||||
INSERT INTO penguin (name, password) VALUES ('root', '$2a$12$o8FSg6JaPwW4h9OnEDT0VOOlf2K/mVg.rhPyRbQzgKybqb9obYyGS');
|
||||
INSERT INTO user_roles (User_id, role) VALUES (1, 'ROOT');
|
||||
INSERT INTO site (name, description, address) VALUES ('test', 'test', 'test');
|
||||
INSERT INTO ji (name, description, date, site_id) VALUES ('ji', 'test', 'date', 1);
|
||||
INSERT INTO ji_respos (ji_id, User_id) VALUES (1, 1);
|
||||
-- INSERT INTO site (name, description, address) VALUES ('test', 'test', 'test');
|
||||
-- INSERT INTO ji (name, description, date, site_id) VALUES ('ji', 'test', 'date', 1);
|
||||
-- INSERT INTO ji_respos (ji_id, User_id) VALUES (1, 1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user