wip: affiliation
This commit is contained in:
@@ -45,6 +45,8 @@ public class ClubModel {
|
||||
|
||||
String contact_intern;
|
||||
|
||||
String address;
|
||||
|
||||
String RNA;
|
||||
|
||||
Long SIRET;
|
||||
|
||||
@@ -53,6 +53,6 @@ public class MembreModel {
|
||||
|
||||
String url_photo;
|
||||
|
||||
@OneToMany(mappedBy = "membre", fetch = FetchType.LAZY)
|
||||
@OneToMany(mappedBy = "membre", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
List<LicenceModel> licences;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package fr.titionfire.ffsaf.data.model;
|
||||
|
||||
import fr.titionfire.ffsaf.utils.SequenceType;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@RegisterForReflection
|
||||
|
||||
@Entity
|
||||
@Table(name = "sequence")
|
||||
public class SequenceModel {
|
||||
@Id
|
||||
SequenceType type;
|
||||
|
||||
long value;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package fr.titionfire.ffsaf.data.repository;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.SequenceModel;
|
||||
import fr.titionfire.ffsaf.utils.SequenceType;
|
||||
import io.quarkus.hibernate.reactive.panache.PanacheRepositoryBase;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
public class SequenceRepository implements PanacheRepositoryBase<SequenceModel, SequenceType> {
|
||||
|
||||
public Uni<Long> getNextValueInTransaction(SequenceType type) {
|
||||
return this.findById(type).onItem().ifNull()
|
||||
.switchTo(() -> this.persist(new SequenceModel(type, 1L)))
|
||||
.chain(v -> {
|
||||
v.setValue(v.getValue() + 1);
|
||||
return this.persistAndFlush(v);
|
||||
})
|
||||
.map(SequenceModel::getValue);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user