feat: add get private socket endpoint
This commit is contained in:
parent
be69093c1d
commit
21cb673d33
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
@ -35,7 +35,6 @@ jobs:
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script: |
|
||||
cd ${{ secrets.TARGET_DIR }}/ffsaf
|
||||
cp ../vite.env src/main/webapp/.env
|
||||
chmod 740 mvnw
|
||||
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 ./mvnw package -Pnative -DskipTests
|
||||
|
||||
@ -76,6 +75,7 @@ jobs:
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script: |
|
||||
cd ${{ secrets.TARGET_DIR }}/ffsaf/src/main/webapp
|
||||
cp ${{ secrets.TARGET_DIR }}/vite.env .env
|
||||
npm run build
|
||||
rm -rf ${{ secrets.TARGET_DIR }}/ffsaf-site
|
||||
mv dist ${{ secrets.TARGET_DIR }}/ffsaf-site
|
||||
@ -0,0 +1,9 @@
|
||||
package fr.titionfire.ffsaf.data.repository;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.ClubModel;
|
||||
import io.quarkus.hibernate.reactive.panache.PanacheRepositoryBase;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
public class ClubRepository implements PanacheRepositoryBase<ClubModel, Long> {
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package fr.titionfire.ffsaf.data.repository;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.CombModel;
|
||||
import io.quarkus.hibernate.reactive.panache.PanacheRepositoryBase;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
public class CombRepository implements PanacheRepositoryBase<CombModel, Long> {
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package fr.titionfire.ffsaf.domain.service;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.ClubModel;
|
||||
import fr.titionfire.ffsaf.data.repository.ClubRepository;
|
||||
import io.quarkus.hibernate.reactive.panache.Panache;
|
||||
import io.quarkus.hibernate.reactive.panache.common.WithSession;
|
||||
import io.quarkus.vertx.VertxContextSupport;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@WithSession
|
||||
@ApplicationScoped
|
||||
public class ClubService {
|
||||
|
||||
@Inject
|
||||
ClubRepository repository;
|
||||
|
||||
public ClubModel findByIdOptionalClub (long id) throws Throwable {
|
||||
return VertxContextSupport.subscribeAndAwait(() -> Panache.withTransaction(() -> repository.findById(id)));
|
||||
}
|
||||
|
||||
public Collection<ClubModel> findAllClub () throws Throwable {
|
||||
return VertxContextSupport.subscribeAndAwait(() -> Panache.withTransaction(() -> repository.findAll().list()));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package fr.titionfire.ffsaf.domain.service;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.CombModel;
|
||||
import fr.titionfire.ffsaf.data.repository.CombRepository;
|
||||
import io.quarkus.hibernate.reactive.panache.Panache;
|
||||
import io.quarkus.hibernate.reactive.panache.common.WithSession;
|
||||
import io.quarkus.vertx.VertxContextSupport;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
|
||||
@WithSession
|
||||
@ApplicationScoped
|
||||
public class CombService {
|
||||
|
||||
@Inject
|
||||
CombRepository repository;
|
||||
|
||||
public CombModel find(int licence, String np) throws Throwable {
|
||||
return VertxContextSupport.subscribeAndAwait(() -> Panache.withTransaction(() ->
|
||||
repository.find("licence = ?1 AND (lname = ?2 OR fname = ?2)", licence, np).firstResult()));
|
||||
}
|
||||
|
||||
public CombModel findByIdOptionalComb (long id) throws Throwable {
|
||||
return VertxContextSupport.subscribeAndAwait(() -> Panache.withTransaction(() -> repository.findById(id)));
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,15 @@
|
||||
package fr.titionfire.ffsaf.net2;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import fr.titionfire.ffsaf.domain.service.ClubService;
|
||||
import fr.titionfire.ffsaf.domain.service.CombService;
|
||||
import fr.titionfire.ffsaf.net2.packet.IAction;
|
||||
import fr.titionfire.ffsaf.net2.packet.RegisterAction;
|
||||
import fr.titionfire.ffsaf.utils.Pair;
|
||||
import io.quarkus.runtime.ShutdownEvent;
|
||||
import io.quarkus.runtime.StartupEvent;
|
||||
import jakarta.enterprise.event.Observes;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
import org.jboss.logging.Logger;
|
||||
@ -25,8 +28,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
@Singleton
|
||||
public class ServerCustom extends Thread {
|
||||
private static final Logger LOGGER = Logger.getLogger("SocketServer");
|
||||
@ -38,6 +39,8 @@ public class ServerCustom extends Thread {
|
||||
private SSLServerSocket server;
|
||||
private boolean run;
|
||||
|
||||
private static ServerCustom serverCustom;
|
||||
|
||||
@ConfigProperty(name = "internal-port")
|
||||
int port;
|
||||
|
||||
@ -50,6 +53,12 @@ public class ServerCustom extends Thread {
|
||||
@Inject
|
||||
protected Scheduler quartz;
|
||||
|
||||
@Inject
|
||||
public CombService combService;
|
||||
|
||||
@Inject
|
||||
public ClubService clubService;
|
||||
|
||||
private PublicKey publicKey;
|
||||
|
||||
private X509TrustManager tm(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
|
||||
@ -134,6 +143,7 @@ public class ServerCustom extends Thread {
|
||||
|
||||
void onStart(@Observes StartupEvent ev) {
|
||||
LOGGER.info("The server is starting...");
|
||||
serverCustom = this;
|
||||
this.start();
|
||||
}
|
||||
|
||||
@ -142,6 +152,10 @@ public class ServerCustom extends Thread {
|
||||
this.stop2();
|
||||
}
|
||||
|
||||
public static ServerCustom getInstance(){
|
||||
return serverCustom;
|
||||
}
|
||||
|
||||
public Stream<Client_Thread> get_clients() {
|
||||
return clients.stream();
|
||||
}
|
||||
|
||||
@ -4,6 +4,9 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import fr.titionfire.ffsaf.net2.Client_Thread;
|
||||
import fr.titionfire.ffsaf.net2.Message;
|
||||
import io.quarkus.hibernate.reactive.panache.common.WithSession;
|
||||
import io.quarkus.vertx.SafeVertxContext;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import fr.titionfire.ffsaf.net2.Client_Thread;
|
||||
import fr.titionfire.ffsaf.net2.Message;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
public interface IAction {
|
||||
void dataIn(Client_Thread client_Thread, Message<JsonNode> message) throws JsonProcessingException;
|
||||
|
||||
39
src/main/java/fr/titionfire/ffsaf/net2/packet/RClub.java
Normal file
39
src/main/java/fr/titionfire/ffsaf/net2/packet/RClub.java
Normal file
@ -0,0 +1,39 @@
|
||||
package fr.titionfire.ffsaf.net2.packet;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.ClubModel;
|
||||
import fr.titionfire.ffsaf.net2.ServerCustom;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RClub {
|
||||
private static final Logger LOGGER = Logger.getLogger(RClub.class);
|
||||
|
||||
final CIA<Long> findByIdOptionalClub = new CIA<>(Long.class, (client_Thread, message) -> {
|
||||
try {
|
||||
ClubModel clubModel = ServerCustom.getInstance().clubService.findByIdOptionalClub(message.data());
|
||||
client_Thread.sendRepTo(clubModel, message);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
client_Thread.sendErrTo(e.getMessage(), message);
|
||||
}
|
||||
});
|
||||
|
||||
final IAction findAllClub = (client_Thread, message) -> {
|
||||
try {
|
||||
Collection<ClubModel> clubModels = ServerCustom.getInstance().clubService.findAllClub();
|
||||
client_Thread.sendRepTo(clubModels, message);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
client_Thread.sendErrTo(e.getMessage(), message);
|
||||
}
|
||||
};
|
||||
|
||||
public static void register(HashMap<String, IAction> iMap) {
|
||||
RClub rClub = new RClub();
|
||||
|
||||
iMap.put("findByIdOptionalClub", rClub.findByIdOptionalClub);
|
||||
iMap.put("findAllClub", rClub.findAllClub);
|
||||
}
|
||||
}
|
||||
40
src/main/java/fr/titionfire/ffsaf/net2/packet/RComb.java
Normal file
40
src/main/java/fr/titionfire/ffsaf/net2/packet/RComb.java
Normal file
@ -0,0 +1,40 @@
|
||||
package fr.titionfire.ffsaf.net2.packet;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.CombModel;
|
||||
import fr.titionfire.ffsaf.net2.ServerCustom;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ApplicationScoped
|
||||
public class RComb {
|
||||
private static final Logger LOGGER = Logger.getLogger(RComb.class);
|
||||
|
||||
final IAction findComb = (client_Thread, message) -> {
|
||||
try {
|
||||
CombModel combModel = ServerCustom.getInstance().combService.find(message.data().get("licence").asInt(), message.data().get("np").asText());
|
||||
client_Thread.sendRepTo(combModel, message);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
client_Thread.sendErrTo(e.getMessage(), message);
|
||||
}
|
||||
};
|
||||
|
||||
final CIA<Long> findByIdOptionalComb = new CIA<>(Long.class, (client_Thread, message) -> {
|
||||
try {
|
||||
CombModel combModel = ServerCustom.getInstance().combService.findByIdOptionalComb(message.data());
|
||||
client_Thread.sendRepTo(combModel, message);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
client_Thread.sendErrTo(e.getMessage(), message);
|
||||
}
|
||||
});
|
||||
|
||||
public static void register(HashMap<String, IAction> iMap) {
|
||||
RComb rComb = new RComb();
|
||||
|
||||
iMap.put("findComb", rComb.findComb);
|
||||
iMap.put("findByIdOptionalComb", rComb.findByIdOptionalComb);
|
||||
}
|
||||
}
|
||||
@ -7,5 +7,7 @@ public class RegisterAction {
|
||||
public static void register(HashMap<String, IAction> iMap) {
|
||||
iMap.clear();
|
||||
|
||||
RComb.register(iMap);
|
||||
RClub.register(iMap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,9 @@ quarkus.hibernate-orm.physical-naming-strategy=fr.titionfire.ffsaf.data.SafcaNam
|
||||
quarkus.http.cors=true
|
||||
quarkus.quartz.start-mode=forced
|
||||
|
||||
%dev.quarkus.log.min-level=ALL
|
||||
%dev.quarkus.log.category."fr.titionfire.ffsaf".level=ALL
|
||||
|
||||
database.prefix = test2_
|
||||
database.database=ffsaf
|
||||
database.hostname=localhost
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user