feat: add club map
This commit is contained in:
@@ -10,6 +10,7 @@ import fr.titionfire.ffsaf.data.repository.CombRepository;
|
||||
import fr.titionfire.ffsaf.net2.ServerCustom;
|
||||
import fr.titionfire.ffsaf.net2.data.SimpleClubModel;
|
||||
import fr.titionfire.ffsaf.net2.request.SReqClub;
|
||||
import fr.titionfire.ffsaf.rest.data.ClubMapData;
|
||||
import fr.titionfire.ffsaf.rest.data.DeskMember;
|
||||
import fr.titionfire.ffsaf.rest.data.RenewAffData;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleClubList;
|
||||
@@ -25,6 +26,7 @@ import io.quarkus.hibernate.reactive.panache.common.WithSession;
|
||||
import io.quarkus.panache.common.Page;
|
||||
import io.quarkus.panache.common.Sort;
|
||||
import io.quarkus.vertx.VertxContextSupport;
|
||||
import io.smallrye.mutiny.Multi;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import io.smallrye.mutiny.unchecked.Unchecked;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
@@ -121,7 +123,8 @@ public class ClubService {
|
||||
}
|
||||
|
||||
public Uni<ClubModel> getOfUser(SecurityCtx securityCtx) {
|
||||
return combRepository.find("userId = ?1", securityCtx.getSubject()).firstResult().invoke(Unchecked.consumer(m -> {
|
||||
return combRepository.find("userId = ?1", securityCtx.getSubject()).firstResult()
|
||||
.invoke(Unchecked.consumer(m -> {
|
||||
if (m == null || m.getClub() == null)
|
||||
throw new DNotFoundException("Club non trouvé");
|
||||
}))
|
||||
@@ -143,7 +146,8 @@ public class ClubService {
|
||||
TypeReference<HashMap<Contact, String>> typeRef = new TypeReference<>() {
|
||||
};
|
||||
|
||||
return combRepository.find("userId = ?1", securityCtx.getSubject()).firstResult().invoke(Unchecked.consumer(m -> {
|
||||
return combRepository.find("userId = ?1", securityCtx.getSubject()).firstResult()
|
||||
.invoke(Unchecked.consumer(m -> {
|
||||
if (m == null || m.getClub() == null)
|
||||
throw new DNotFoundException("Club non trouvé");
|
||||
if (!securityCtx.isInClubGroup(m.getClub().getId()))
|
||||
@@ -279,4 +283,31 @@ public class ClubService {
|
||||
.toList()))
|
||||
.map(o -> data);
|
||||
}
|
||||
|
||||
public Uni<List<ClubMapData>> getMapData() {
|
||||
return repository.list("international", false).toMulti().flatMap(list -> Multi.createFrom().iterable(list))
|
||||
.call(clubModel -> Mutiny.fetch(clubModel.getContact()))
|
||||
.map(clubModel -> {
|
||||
ClubMapData data = new ClubMapData();
|
||||
|
||||
data.setName(clubModel.getName());
|
||||
data.setUuid(clubModel.getClubId());
|
||||
if (clubModel.getTraining_location() != null) {
|
||||
try {
|
||||
MAPPER.readTree(clubModel.getTraining_location()).forEach(l -> {
|
||||
ClubMapData.Location loc = new ClubMapData.Location();
|
||||
loc.setLat(l.get("lat").asDouble());
|
||||
loc.setLng(l.get("lng").asDouble());
|
||||
loc.setAddr(l.get("text").asText());
|
||||
data.training_location.add(loc);
|
||||
});
|
||||
} catch (JsonProcessingException ignored) {
|
||||
}
|
||||
}
|
||||
data.setTraining_day_time(clubModel.getTraining_day_time());
|
||||
data.setContact(clubModel.getContact());
|
||||
|
||||
return data;
|
||||
}).collect().asList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user