wip: Logger
This commit is contained in:
parent
54e72cc705
commit
97ca8766af
@ -18,7 +18,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "club")
|
@Table(name = "club")
|
||||||
public class ClubModel {
|
public class ClubModel implements LoggableModel {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Schema(description = "Identifiant du club", example = "1")
|
@Schema(description = "Identifiant du club", example = "1")
|
||||||
@ -70,4 +70,14 @@ public class ClubModel {
|
|||||||
@OneToMany(mappedBy = "club", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "club", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||||
@Schema(description = "Liste des affiliations du club (optionnel)")
|
@Schema(description = "Liste des affiliations du club (optionnel)")
|
||||||
List<AffiliationModel> affiliations;
|
List<AffiliationModel> affiliations;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getObjectName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LogModel.ObjectType getObjectType() {
|
||||||
|
return LogModel.ObjectType.Club;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,10 +34,7 @@ import jakarta.inject.Inject;
|
|||||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||||
import org.hibernate.reactive.mutiny.Mutiny;
|
import org.hibernate.reactive.mutiny.Mutiny;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static fr.titionfire.ffsaf.net2.Client_Thread.MAPPER;
|
import static fr.titionfire.ffsaf.net2.Client_Thread.MAPPER;
|
||||||
@ -61,6 +58,9 @@ public class ClubService {
|
|||||||
@ConfigProperty(name = "upload_dir")
|
@ConfigProperty(name = "upload_dir")
|
||||||
String media;
|
String media;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LoggerService ls;
|
||||||
|
|
||||||
public SimpleClubModel findByIdOptionalClub(long id) throws Throwable {
|
public SimpleClubModel findByIdOptionalClub(long id) throws Throwable {
|
||||||
return VertxContextSupport.subscribeAndAwait(
|
return VertxContextSupport.subscribeAndAwait(
|
||||||
() -> Panache.withTransaction(() -> repository.findById(id).map(SimpleClubModel::fromModel)));
|
() -> Panache.withTransaction(() -> repository.findById(id).map(SimpleClubModel::fromModel)));
|
||||||
@ -78,8 +78,10 @@ public class ClubService {
|
|||||||
|
|
||||||
public Uni<?> setClubId(Long id, String id1) {
|
public Uni<?> setClubId(Long id, String id1) {
|
||||||
return repository.findById(id).chain(clubModel -> {
|
return repository.findById(id).chain(clubModel -> {
|
||||||
|
ls.logChange("KC UUID", clubModel.getClubId(), id1, clubModel);
|
||||||
clubModel.setClubId(id1);
|
clubModel.setClubId(id1);
|
||||||
return Panache.withTransaction(() -> repository.persist(clubModel));
|
return Panache.withTransaction(() -> repository.persist(clubModel))
|
||||||
|
.call(() -> ls.append());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,18 +158,26 @@ public class ClubService {
|
|||||||
.map(MembreModel::getClub)
|
.map(MembreModel::getClub)
|
||||||
.call(club -> Mutiny.fetch(club.getContact()))
|
.call(club -> Mutiny.fetch(club.getContact()))
|
||||||
.chain(Unchecked.function(club -> {
|
.chain(Unchecked.function(club -> {
|
||||||
|
ls.logChange("Contact interne", club.getContact_intern(), form.getContact_intern(), club);
|
||||||
club.setContact_intern(form.getContact_intern());
|
club.setContact_intern(form.getContact_intern());
|
||||||
|
ls.logChange("Adresse administrative", club.getAddress(), form.getAddress(), club);
|
||||||
club.setAddress(form.getAddress());
|
club.setAddress(form.getAddress());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!Objects.equals(club.getContact(), MAPPER.readValue(form.getContact(), typeRef)))
|
||||||
|
ls.logUpdate("Contact(s)...", club);
|
||||||
club.setContact(MAPPER.readValue(form.getContact(), typeRef));
|
club.setContact(MAPPER.readValue(form.getContact(), typeRef));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new DBadRequestException("Erreur de format des contacts");
|
throw new DBadRequestException("Erreur de format des contacts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ls.logChange("Lieux d'entrainements", club.getTraining_location(), form.getTraining_location(),
|
||||||
|
club);
|
||||||
club.setTraining_location(form.getTraining_location());
|
club.setTraining_location(form.getTraining_location());
|
||||||
|
ls.logChange("Horaires d'entrainements", club.getTraining_day_time(), form.getTraining_day_time(),
|
||||||
|
club);
|
||||||
club.setTraining_day_time(form.getTraining_day_time());
|
club.setTraining_day_time(form.getTraining_day_time());
|
||||||
return Panache.withTransaction(() -> repository.persist(club));
|
return Panache.withTransaction(() -> repository.persist(club)).call(() -> ls.append());
|
||||||
}))
|
}))
|
||||||
.map(__ -> "OK");
|
.map(__ -> "OK");
|
||||||
}
|
}
|
||||||
@ -183,21 +193,32 @@ public class ClubService {
|
|||||||
m.setInternational(input.isInternational());
|
m.setInternational(input.isInternational());
|
||||||
|
|
||||||
if (!input.isInternational()) {
|
if (!input.isInternational()) {
|
||||||
|
ls.logChange("Lieux d'entrainements", m.getTraining_location(), input.getTraining_location(),
|
||||||
|
m);
|
||||||
m.setTraining_location(input.getTraining_location());
|
m.setTraining_location(input.getTraining_location());
|
||||||
|
ls.logChange("Horaires d'entrainements", m.getTraining_day_time(), input.getTraining_day_time(),
|
||||||
|
m);
|
||||||
m.setTraining_day_time(input.getTraining_day_time());
|
m.setTraining_day_time(input.getTraining_day_time());
|
||||||
|
ls.logChange("Contact interne", m.getContact_intern(), input.getContact_intern(), m);
|
||||||
m.setContact_intern(input.getContact_intern());
|
m.setContact_intern(input.getContact_intern());
|
||||||
|
ls.logChange("N° RNA", m.getRNA(), input.getRna(), m);
|
||||||
m.setRNA(input.getRna());
|
m.setRNA(input.getRna());
|
||||||
if (input.getSiret() != null && !input.getSiret().isBlank())
|
if (input.getSiret() != null && !input.getSiret().isBlank()) {
|
||||||
|
ls.logChange("N° SIRET", m.getSIRET(), input.getSiret(), m);
|
||||||
m.setSIRET(Long.parseLong(input.getSiret()));
|
m.setSIRET(Long.parseLong(input.getSiret()));
|
||||||
|
}
|
||||||
|
ls.logChange("Adresse administrative", m.getAddress(), input.getAddress(), m);
|
||||||
m.setAddress(input.getAddress());
|
m.setAddress(input.getAddress());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!Objects.equals(m.getContact(), MAPPER.readValue(input.getContact(), typeRef)))
|
||||||
|
ls.logUpdate("Contact(s)...", m);
|
||||||
m.setContact(MAPPER.readValue(input.getContact(), typeRef));
|
m.setContact(MAPPER.readValue(input.getContact(), typeRef));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new DBadRequestException("Erreur de format des contacts");
|
throw new DBadRequestException("Erreur de format des contacts");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Panache.withTransaction(() -> repository.persist(m));
|
return Panache.withTransaction(() -> repository.persist(m)).call(() -> ls.append());
|
||||||
}))
|
}))
|
||||||
.invoke(membreModel -> SReqClub.sendIfNeed(serverCustom.clients,
|
.invoke(membreModel -> SReqClub.sendIfNeed(serverCustom.clients,
|
||||||
SimpleClubModel.fromModel(membreModel)))
|
SimpleClubModel.fromModel(membreModel)))
|
||||||
@ -233,6 +254,7 @@ public class ClubService {
|
|||||||
|
|
||||||
return Panache.withTransaction(() -> repository.persist(clubModel));
|
return Panache.withTransaction(() -> repository.persist(clubModel));
|
||||||
})
|
})
|
||||||
|
.call(clubModel -> ls.logAAdd(clubModel))
|
||||||
.call(clubModel -> keycloakService.getGroupFromClub(clubModel)) // create group in keycloak
|
.call(clubModel -> keycloakService.getGroupFromClub(clubModel)) // create group in keycloak
|
||||||
.invoke(clubModel -> SReqClub.sendAddIfNeed(serverCustom.clients, SimpleClubModel.fromModel(clubModel)))
|
.invoke(clubModel -> SReqClub.sendAddIfNeed(serverCustom.clients, SimpleClubModel.fromModel(clubModel)))
|
||||||
.map(ClubModel::getId);
|
.map(ClubModel::getId);
|
||||||
@ -255,6 +277,7 @@ public class ClubService {
|
|||||||
.call(clubModel -> (clubModel.getClubId() == null) ? Uni.createFrom()
|
.call(clubModel -> (clubModel.getClubId() == null) ? Uni.createFrom()
|
||||||
.voidItem() : keycloakService.removeClubGroup(clubModel.getClubId()))
|
.voidItem() : keycloakService.removeClubGroup(clubModel.getClubId()))
|
||||||
.invoke(membreModel -> SReqClub.sendRmIfNeed(serverCustom.clients, id))
|
.invoke(membreModel -> SReqClub.sendRmIfNeed(serverCustom.clients, id))
|
||||||
|
.call(clubModel -> ls.logADelete(clubModel))
|
||||||
.chain(clubModel -> Panache.withTransaction(() -> repository.delete(clubModel)))
|
.chain(clubModel -> Panache.withTransaction(() -> repository.delete(clubModel)))
|
||||||
.call(__ -> Utils.deleteMedia(id, media, "ppClub"))
|
.call(__ -> Utils.deleteMedia(id, media, "ppClub"))
|
||||||
.call(__ -> Utils.deleteMedia(id, media, "clubStatus"));
|
.call(__ -> Utils.deleteMedia(id, media, "clubStatus"));
|
||||||
|
|||||||
@ -145,7 +145,7 @@ public class ClubEndpoints {
|
|||||||
)).invoke(Unchecked.consumer(out -> {
|
)).invoke(Unchecked.consumer(out -> {
|
||||||
if (!out.equals("OK"))
|
if (!out.equals("OK"))
|
||||||
throw new DInternalError("Impossible de reconnaitre le fichier: " + out);
|
throw new DInternalError("Impossible de reconnaitre le fichier: " + out);
|
||||||
}));
|
})); // TODO log
|
||||||
else
|
else
|
||||||
return Uni.createFrom().nullItem();
|
return Uni.createFrom().nullItem();
|
||||||
}).chain(() -> {
|
}).chain(() -> {
|
||||||
@ -154,7 +154,7 @@ public class ClubEndpoints {
|
|||||||
)).invoke(Unchecked.consumer(out -> {
|
)).invoke(Unchecked.consumer(out -> {
|
||||||
if (!out.equals("OK"))
|
if (!out.equals("OK"))
|
||||||
throw new DInternalError("Impossible de reconnaitre le fichier: " + out);
|
throw new DInternalError("Impossible de reconnaitre le fichier: " + out);
|
||||||
}));
|
})); // TODO log
|
||||||
else
|
else
|
||||||
return Uni.createFrom().nullItem();
|
return Uni.createFrom().nullItem();
|
||||||
});
|
});
|
||||||
@ -178,13 +178,13 @@ public class ClubEndpoints {
|
|||||||
})).call(id -> {
|
})).call(id -> {
|
||||||
if (input.getLogo().length > 0)
|
if (input.getLogo().length > 0)
|
||||||
return Uni.createFrom().future(Utils.replacePhoto(id, input.getLogo(), media, "ppClub"
|
return Uni.createFrom().future(Utils.replacePhoto(id, input.getLogo(), media, "ppClub"
|
||||||
));
|
)); // TODO log
|
||||||
else
|
else
|
||||||
return Uni.createFrom().nullItem();
|
return Uni.createFrom().nullItem();
|
||||||
}).call(id -> {
|
}).call(id -> {
|
||||||
if (input.getStatus().length > 0)
|
if (input.getStatus().length > 0)
|
||||||
return Uni.createFrom().future(Utils.replacePhoto(id, input.getStatus(), media, "clubStatus"
|
return Uni.createFrom().future(Utils.replacePhoto(id, input.getStatus(), media, "clubStatus"
|
||||||
));
|
)); // TODO log
|
||||||
else
|
else
|
||||||
return Uni.createFrom().nullItem();
|
return Uni.createFrom().nullItem();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user