feat: club
This commit is contained in:
@@ -308,7 +308,13 @@ public class AffiliationService {
|
||||
}
|
||||
}))
|
||||
.chain(club ->
|
||||
Panache.withTransaction(() -> repository.persist(new AffiliationModel(null, club, saison))))
|
||||
Panache.withTransaction(() -> repository.persist(new AffiliationModel(null, club, saison))
|
||||
.chain(c -> (club.getNo_affiliation() != null) ? Uni.createFrom().item(c) :
|
||||
sequenceRepository.getNextValueInTransaction(SequenceType.Affiliation)
|
||||
.invoke(club::setNo_affiliation)
|
||||
.chain(() -> clubRepository.persist(club))
|
||||
.map(o -> c)
|
||||
)))
|
||||
.map(SimpleAffiliation::fromModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,13 +122,15 @@ public class ClubService {
|
||||
|
||||
m.setName(input.getName());
|
||||
m.setCountry(input.getCountry());
|
||||
m.setInternational(input.isInternational());
|
||||
|
||||
if (!input.isInternational()) {
|
||||
m.setTraining_location(input.getTraining_location());
|
||||
m.setTraining_day_time(input.getTraining_day_time());
|
||||
m.setContact_intern(input.getContact_intern());
|
||||
m.setRNA(input.getRna());
|
||||
m.setSIRET(input.getSiret());
|
||||
if (input.getSiret() != null && !input.getSiret().isBlank())
|
||||
m.setSIRET(Long.parseLong(input.getSiret()));
|
||||
m.setAddress(input.getAddress());
|
||||
|
||||
try {
|
||||
@@ -145,7 +147,37 @@ public class ClubService {
|
||||
}
|
||||
|
||||
public Uni<Long> add(FullClubForm input) {
|
||||
return Uni.createFrom().nullItem();
|
||||
TypeReference<HashMap<Contact, String>> typeRef = new TypeReference<>() {
|
||||
};
|
||||
|
||||
return Uni.createFrom().nullItem()
|
||||
.chain(() -> {
|
||||
ClubModel clubModel = new ClubModel();
|
||||
|
||||
clubModel.setName(input.getName());
|
||||
clubModel.setCountry(input.getCountry());
|
||||
clubModel.setInternational(input.isInternational());
|
||||
clubModel.setNo_affiliation(null);
|
||||
if (!input.isInternational()) {
|
||||
clubModel.setTraining_location(input.getTraining_location());
|
||||
clubModel.setTraining_day_time(input.getTraining_day_time());
|
||||
clubModel.setContact_intern(input.getContact_intern());
|
||||
clubModel.setRNA(input.getRna());
|
||||
if (input.getSiret() != null && !input.getSiret().isBlank())
|
||||
clubModel.setSIRET(Long.parseLong(input.getSiret()));
|
||||
clubModel.setAddress(input.getAddress());
|
||||
|
||||
try {
|
||||
clubModel.setContact(MAPPER.readValue(input.getContact(), typeRef));
|
||||
} catch (JsonProcessingException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return Panache.withTransaction(() -> repository.persist(clubModel));
|
||||
})
|
||||
.call(clubModel -> keycloakService.getGroupFromClub(clubModel)) // create group in keycloak
|
||||
.invoke(clubModel -> SReqClub.sendAddIfNeed(serverCustom.clients, SimpleClubModel.fromModel(clubModel)))
|
||||
.map(ClubModel::getId);
|
||||
}
|
||||
|
||||
public Uni<?> delete(long id) {
|
||||
@@ -155,8 +187,10 @@ public class ClubService {
|
||||
combModel.setClub(null);
|
||||
combModel.setRole(RoleAsso.MEMBRE);
|
||||
}).toList())
|
||||
.call(list -> Uni.join().all(list.stream().filter(m -> m.getUserId() != null)
|
||||
.map(m -> keycloakService.clearUser(m.getUserId())).toList()).andCollectFailures())
|
||||
.call(list -> (list.isEmpty()) ? Uni.createFrom().voidItem() :
|
||||
Uni.join().all(list.stream().filter(m -> m.getUserId() != null)
|
||||
.map(m -> keycloakService.clearUser(m.getUserId())).toList())
|
||||
.andCollectFailures())
|
||||
.chain(list -> Panache.withTransaction(() -> combRepository.persist(list)))
|
||||
.map(o -> club)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user