Compare commits
10
Commits
prod/v1.5
...
2b2025a78f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b2025a78f | ||
|
|
63c71d504e | ||
|
|
4956e1a70c | ||
|
|
b9a7dc089c | ||
|
|
1737087062 | ||
|
|
df217bc923 | ||
|
|
da0443f655 | ||
|
|
baa4d3c0cd | ||
|
|
e81be98cbe | ||
|
|
a19e49392b |
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>as-talange-parent</artifactId>
|
<artifactId>as-talange-parent</artifactId>
|
||||||
<groupId>com.astalange</groupId>
|
<groupId>com.astalange</groupId>
|
||||||
<version>1.5</version>
|
<version>1.7-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>as-talange-parent</artifactId>
|
<artifactId>as-talange-parent</artifactId>
|
||||||
<groupId>com.astalange</groupId>
|
<groupId>com.astalange</groupId>
|
||||||
<version>1.5</version>
|
<version>1.7-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -28,6 +28,11 @@
|
|||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|||||||
@@ -36,4 +36,10 @@ public class AppUser {
|
|||||||
inverseJoinColumns = @JoinColumn(name = "role_id")
|
inverseJoinColumns = @JoinColumn(name = "role_id")
|
||||||
)
|
)
|
||||||
private Set<Role> roles = new HashSet<>();
|
private Set<Role> roles = new HashSet<>();
|
||||||
|
|
||||||
|
@Column(name = "last_login_at")
|
||||||
|
private java.time.LocalDateTime lastLoginAt;
|
||||||
|
|
||||||
|
@Column(name = "last_logout_at")
|
||||||
|
private java.time.LocalDateTime lastLogoutAt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,17 @@ public class Categorie {
|
|||||||
@JoinColumn(name = "saison_id", nullable = false)
|
@JoinColumn(name = "saison_id", nullable = false)
|
||||||
private Saison saison;
|
private Saison saison;
|
||||||
|
|
||||||
|
@Column(name = "sport_easy_token")
|
||||||
|
private String sportEasyToken;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "categorie", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "categorie", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
private List<CategorieEquipement> categorieEquipements = new ArrayList<>();
|
private List<CategorieEquipement> categorieEquipements = new ArrayList<>();
|
||||||
|
|
||||||
// Getters and Setters
|
// Getters and Setters
|
||||||
|
|
||||||
|
public String getSportEasyToken() { return sportEasyToken; }
|
||||||
|
public void setSportEasyToken(String sportEasyToken) { this.sportEasyToken = sportEasyToken; }
|
||||||
|
|
||||||
public Long getId() { return id; }
|
public Long getId() { return id; }
|
||||||
public void setId(Long id) { this.id = id; }
|
public void setId(Long id) { this.id = id; }
|
||||||
|
|
||||||
|
|||||||
@@ -64,4 +64,107 @@ public class Dotation {
|
|||||||
|
|
||||||
public Boolean getChoisi() { return choisi; }
|
public Boolean getChoisi() { return choisi; }
|
||||||
public void setChoisi(Boolean choisi) { this.choisi = choisi; }
|
public void setChoisi(Boolean choisi) { this.choisi = choisi; }
|
||||||
|
|
||||||
|
public static boolean isSizeMatch(String option, String adherentSize) {
|
||||||
|
if (option == null || adherentSize == null) return false;
|
||||||
|
String opt = option.trim();
|
||||||
|
String adh = adherentSize.trim();
|
||||||
|
if (opt.isEmpty() || adh.isEmpty()) return false;
|
||||||
|
|
||||||
|
if (opt.equalsIgnoreCase(adh)) return true;
|
||||||
|
|
||||||
|
String optNorm = opt.toLowerCase().replaceAll("\\s+", " ");
|
||||||
|
String adhNorm = adh.toLowerCase().replaceAll("\\s+", " ");
|
||||||
|
|
||||||
|
if (optNorm.equals(adhNorm)) return true;
|
||||||
|
|
||||||
|
// 1. Age bracket matching: 5/6, 7/8, 9/10, 11/12, 13/14, 15/16
|
||||||
|
java.util.regex.Pattern agePattern = java.util.regex.Pattern.compile("(?<!\\d)(5[/\\-]6|7[/\\-]8|9[/\\-]10|11[/\\-]12|13[/\\-]14|15[/\\-]16)(?!\\d)");
|
||||||
|
java.util.regex.Matcher adhAgeMatcher = agePattern.matcher(adhNorm);
|
||||||
|
java.util.regex.Matcher optAgeMatcher = agePattern.matcher(optNorm);
|
||||||
|
boolean adhHasAge = adhAgeMatcher.find();
|
||||||
|
boolean optHasAge = optAgeMatcher.find();
|
||||||
|
|
||||||
|
if (adhHasAge && optHasAge) {
|
||||||
|
String adhAgeKey = adhAgeMatcher.group(1).replace("-", "/");
|
||||||
|
String optAgeKey = optAgeMatcher.group(1).replace("-", "/");
|
||||||
|
return adhAgeKey.equals(optAgeKey);
|
||||||
|
} else if (adhHasAge) {
|
||||||
|
String ageKey = adhAgeMatcher.group(1).replace("-", "/");
|
||||||
|
String altAgeKey = ageKey.replace("/", "-");
|
||||||
|
if (optNorm.contains(ageKey) || optNorm.contains(altAgeKey)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Height matching (3-digit numbers in cm, e.g. 115, 116, 126, 128, 138, 140, 150, 152, 162, 164, 176)
|
||||||
|
java.util.regex.Pattern heightPattern = java.util.regex.Pattern.compile("(?<!\\d)(115|116|126|128|138|140|150|152|162|164|176)(?!\\d)");
|
||||||
|
java.util.regex.Matcher adhHeightMatcher = heightPattern.matcher(adhNorm);
|
||||||
|
java.util.regex.Matcher optHeightMatcher = heightPattern.matcher(optNorm);
|
||||||
|
boolean adhHasHeight = adhHeightMatcher.find();
|
||||||
|
boolean optHasHeight = optHeightMatcher.find();
|
||||||
|
|
||||||
|
if (adhHasHeight && optHasHeight) {
|
||||||
|
int adhH = Integer.parseInt(adhHeightMatcher.group(1));
|
||||||
|
int optH = Integer.parseInt(optHeightMatcher.group(1));
|
||||||
|
return Math.abs(adhH - optH) <= 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Shoe size / pointure matching: 27/30, 31/34, 35/38, 39/42, 43/46
|
||||||
|
java.util.regex.Pattern shoePattern = java.util.regex.Pattern.compile("(?<!\\d)(27[/\\-]30|31[/\\-]34|35[/\\-]38|39[/\\-]42|43[/\\-]46)(?!\\d)");
|
||||||
|
java.util.regex.Matcher adhShoeMatcher = shoePattern.matcher(adhNorm);
|
||||||
|
java.util.regex.Matcher optShoeMatcher = shoePattern.matcher(optNorm);
|
||||||
|
boolean adhHasShoe = adhShoeMatcher.find();
|
||||||
|
boolean optHasShoe = optShoeMatcher.find();
|
||||||
|
|
||||||
|
if (adhHasShoe && optHasShoe) {
|
||||||
|
String adhShoeKey = adhShoeMatcher.group(1).replace("-", "/");
|
||||||
|
String optShoeKey = optShoeMatcher.group(1).replace("-", "/");
|
||||||
|
return adhShoeKey.equals(optShoeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Sock size tag matching: "taille 0", "taille 1", "taille 2", "taille 3", "taille 4"
|
||||||
|
java.util.regex.Pattern tNumPattern = java.util.regex.Pattern.compile("(?<![a-z0-9])taille\\s*([0-4])(?![0-9])");
|
||||||
|
java.util.regex.Matcher adhTNumMatcher = tNumPattern.matcher(adhNorm);
|
||||||
|
java.util.regex.Matcher optTNumMatcher = tNumPattern.matcher(optNorm);
|
||||||
|
boolean adhHasTNum = adhTNumMatcher.find();
|
||||||
|
boolean optHasTNum = optTNumMatcher.find();
|
||||||
|
|
||||||
|
if (adhHasTNum && optHasTNum) {
|
||||||
|
return adhTNumMatcher.group(1).equals(optTNumMatcher.group(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. Letter size matching: XXL, XL, L, M, S, XS
|
||||||
|
java.util.regex.Pattern letterPattern = java.util.regex.Pattern.compile("(?<![a-z0-9])(xxl|xl|l|m|s|xs)(?![a-z0-9])");
|
||||||
|
java.util.regex.Matcher adhLetterMatcher = letterPattern.matcher(adhNorm);
|
||||||
|
java.util.regex.Matcher optLetterMatcher = letterPattern.matcher(optNorm);
|
||||||
|
boolean adhHasLetter = adhLetterMatcher.find();
|
||||||
|
boolean optHasLetter = optLetterMatcher.find();
|
||||||
|
|
||||||
|
if (adhHasLetter && optHasLetter) {
|
||||||
|
return adhLetterMatcher.group(1).equals(optLetterMatcher.group(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Substring fallback only if neither age, height, shoe, tag, nor letter pattern were present
|
||||||
|
if (!adhHasAge && !optHasAge && !adhHasHeight && !optHasHeight && !adhHasShoe && !optHasShoe && !adhHasTNum && !optHasTNum && !adhHasLetter && !optHasLetter) {
|
||||||
|
if (optNorm.length() >= 2 && adhNorm.contains(optNorm)) return true;
|
||||||
|
if (adhNorm.length() >= 2 && optNorm.contains(adhNorm)) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTailleOptionSelected(String option) {
|
||||||
|
if (option == null) return false;
|
||||||
|
String trimmedOpt = option.trim();
|
||||||
|
if (this.taille != null && !this.taille.trim().isEmpty()) {
|
||||||
|
return this.taille.trim().equalsIgnoreCase(trimmedOpt);
|
||||||
|
}
|
||||||
|
if (this.licence == null || this.licence.getAdherent() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Adherent adherent = this.licence.getAdherent();
|
||||||
|
return isSizeMatch(trimmedOpt, adherent.getTailleVetement()) || isSizeMatch(trimmedOpt, adherent.getPointure());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ public class Licence {
|
|||||||
@Column(columnDefinition = "TEXT")
|
@Column(columnDefinition = "TEXT")
|
||||||
private String commentaire;
|
private String commentaire;
|
||||||
|
|
||||||
|
@Column(name = "sport_easy_email_sent", nullable = false)
|
||||||
|
private Boolean sportEasyEmailSent = false;
|
||||||
|
|
||||||
|
@Column(name = "sport_easy_email_sent_at")
|
||||||
|
private java.time.LocalDateTime sportEasyEmailSentAt;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "licence", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "licence", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
private List<Paiement> paiements = new ArrayList<>();
|
private List<Paiement> paiements = new ArrayList<>();
|
||||||
|
|
||||||
@@ -134,6 +140,20 @@ public class Licence {
|
|||||||
public String getCommentaire() { return commentaire; }
|
public String getCommentaire() { return commentaire; }
|
||||||
public void setCommentaire(String commentaire) { this.commentaire = commentaire; }
|
public void setCommentaire(String commentaire) { this.commentaire = commentaire; }
|
||||||
|
|
||||||
|
public Boolean getSportEasyEmailSent() { return sportEasyEmailSent != null ? sportEasyEmailSent : false; }
|
||||||
|
public void setSportEasyEmailSent(Boolean sportEasyEmailSent) { this.sportEasyEmailSent = sportEasyEmailSent; }
|
||||||
|
|
||||||
|
public java.time.LocalDateTime getSportEasyEmailSentAt() { return sportEasyEmailSentAt; }
|
||||||
|
public void setSportEasyEmailSentAt(java.time.LocalDateTime sportEasyEmailSentAt) { this.sportEasyEmailSentAt = sportEasyEmailSentAt; }
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
public boolean isRenouvellement() {
|
||||||
|
return typeDemande != null && (
|
||||||
|
"Renouvellement".equalsIgnoreCase(typeDemande.trim()) ||
|
||||||
|
"RENOUVELLEMENT".equalsIgnoreCase(typeDemande.trim())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Paiement> getPaiements() { return paiements; }
|
public List<Paiement> getPaiements() { return paiements; }
|
||||||
public void setPaiements(List<Paiement> paiements) { this.paiements = paiements; }
|
public void setPaiements(List<Paiement> paiements) { this.paiements = paiements; }
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
public interface LicenceRepository extends JpaRepository<Licence, Long>, JpaSpecificationExecutor<Licence> {
|
public interface LicenceRepository extends JpaRepository<Licence, Long>, JpaSpecificationExecutor<Licence> {
|
||||||
List<Licence> findByAdherentId(Long adherentId);
|
List<Licence> findByAdherentId(Long adherentId);
|
||||||
|
|
||||||
|
java.util.Optional<Licence> findByAdherentIdAndSaison(Long adherentId, com.astalange.core.entity.Saison saison);
|
||||||
|
|
||||||
|
List<Licence> findBySaison(com.astalange.core.entity.Saison saison);
|
||||||
|
|
||||||
List<Licence> findBySaisonAndCategorie(com.astalange.core.entity.Saison saison, com.astalange.core.entity.Categorie categorie);
|
List<Licence> findBySaisonAndCategorie(com.astalange.core.entity.Saison saison, com.astalange.core.entity.Categorie categorie);
|
||||||
|
|
||||||
long countByEtat(String etat);
|
long countByEtat(String etat);
|
||||||
|
|||||||
+79
@@ -0,0 +1,79 @@
|
|||||||
|
package com.astalange.core.security;
|
||||||
|
|
||||||
|
import com.astalange.core.entity.AppUser;
|
||||||
|
import com.astalange.core.repository.AppUserRepository;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
|
||||||
|
import org.springframework.security.authentication.event.LogoutSuccessEvent;
|
||||||
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.security.web.session.HttpSessionDestroyedEvent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class AuthenticationEventListener {
|
||||||
|
|
||||||
|
private final AppUserRepository userRepository;
|
||||||
|
|
||||||
|
public AuthenticationEventListener(AppUserRepository userRepository) {
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
@Transactional
|
||||||
|
public void onAuthenticationSuccess(AuthenticationSuccessEvent event) {
|
||||||
|
String username = extractUsername(event.getAuthentication().getPrincipal());
|
||||||
|
if (username != null) {
|
||||||
|
userRepository.findByUsername(username).ifPresent(user -> {
|
||||||
|
user.setLastLoginAt(LocalDateTime.now());
|
||||||
|
userRepository.save(user);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
@Transactional
|
||||||
|
public void onLogoutSuccess(LogoutSuccessEvent event) {
|
||||||
|
if (event.getAuthentication() != null) {
|
||||||
|
String username = extractUsername(event.getAuthentication().getPrincipal());
|
||||||
|
if (username != null) {
|
||||||
|
userRepository.findByUsername(username).ifPresent(user -> {
|
||||||
|
user.setLastLogoutAt(LocalDateTime.now());
|
||||||
|
userRepository.save(user);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
@Transactional
|
||||||
|
public void onSessionDestroyed(HttpSessionDestroyedEvent event) {
|
||||||
|
List<SecurityContext> contexts = event.getSecurityContexts();
|
||||||
|
for (SecurityContext context : contexts) {
|
||||||
|
if (context != null && context.getAuthentication() != null) {
|
||||||
|
String username = extractUsername(context.getAuthentication().getPrincipal());
|
||||||
|
if (username != null) {
|
||||||
|
userRepository.findByUsername(username).ifPresent(user -> {
|
||||||
|
if (user.getLastLogoutAt() == null || (user.getLastLoginAt() != null && user.getLastLogoutAt().isBefore(user.getLastLoginAt()))) {
|
||||||
|
user.setLastLogoutAt(LocalDateTime.now());
|
||||||
|
userRepository.save(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String extractUsername(Object principal) {
|
||||||
|
if (principal instanceof UserDetails) {
|
||||||
|
return ((UserDetails) principal).getUsername();
|
||||||
|
} else if (principal instanceof String) {
|
||||||
|
return (String) principal;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,23 @@ public class CategorieService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String matchedTaille = "";
|
||||||
|
if (licence.getAdherent() != null) {
|
||||||
|
String taillesDispo = ce.getEquipement().getTaillesDisponibles();
|
||||||
|
if (taillesDispo != null && !taillesDispo.trim().isEmpty()) {
|
||||||
|
String[] dispos = taillesDispo.split(",");
|
||||||
|
String tv = licence.getAdherent().getTailleVetement();
|
||||||
|
String pt = licence.getAdherent().getPointure();
|
||||||
|
for (String t : dispos) {
|
||||||
|
String trimmed = t.trim();
|
||||||
|
if (Dotation.isSizeMatch(trimmed, tv) || Dotation.isSizeMatch(trimmed, pt)) {
|
||||||
|
matchedTaille = trimmed;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (Dotation d : currentDotations) {
|
for (Dotation d : currentDotations) {
|
||||||
if (ce.getEquipement().getId().equals(d.getEquipement().getId())) {
|
if (ce.getEquipement().getId().equals(d.getEquipement().getId())) {
|
||||||
@@ -130,6 +147,9 @@ public class CategorieService {
|
|||||||
if (Boolean.TRUE.equals(ce.getObligatoire()) && !Boolean.TRUE.equals(d.getChoisi())) {
|
if (Boolean.TRUE.equals(ce.getObligatoire()) && !Boolean.TRUE.equals(d.getChoisi())) {
|
||||||
d.setChoisi(true);
|
d.setChoisi(true);
|
||||||
}
|
}
|
||||||
|
if ((d.getTaille() == null || d.getTaille().trim().isEmpty()) && !matchedTaille.isEmpty()) {
|
||||||
|
d.setTaille(matchedTaille);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +166,7 @@ public class CategorieService {
|
|||||||
}
|
}
|
||||||
newDotation.setChoisi(ce.getObligatoire() || (isMaillot && isNouvelle)); // Checked if obligatoire or if it's a new registration
|
newDotation.setChoisi(ce.getObligatoire() || (isMaillot && isNouvelle)); // Checked if obligatoire or if it's a new registration
|
||||||
newDotation.setFourni(false);
|
newDotation.setFourni(false);
|
||||||
newDotation.setTaille("");
|
newDotation.setTaille(matchedTaille);
|
||||||
newDotation.setNumero("");
|
newDotation.setNumero("");
|
||||||
if (licence.getAdherent() != null) {
|
if (licence.getAdherent() != null) {
|
||||||
String defaultFlocage = "";
|
String defaultFlocage = "";
|
||||||
|
|||||||
@@ -0,0 +1,227 @@
|
|||||||
|
package com.astalange.core.service;
|
||||||
|
|
||||||
|
import com.astalange.core.entity.Licence;
|
||||||
|
import com.astalange.core.entity.Saison;
|
||||||
|
import com.astalange.core.repository.LicenceRepository;
|
||||||
|
import com.astalange.core.repository.SaisonRepository;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SportEasyEmailService {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(SportEasyEmailService.class);
|
||||||
|
|
||||||
|
private final LicenceRepository licenceRepository;
|
||||||
|
private final SaisonRepository saisonRepository;
|
||||||
|
private final JavaMailSender mailSender;
|
||||||
|
|
||||||
|
@Value("${sporteasy.base-url:https://www.sporteasy.net/join/}")
|
||||||
|
private String sportEasyBaseUrl;
|
||||||
|
|
||||||
|
@Value("${spring.mail.username:noreply@as-talange.fr}")
|
||||||
|
private String fromEmail;
|
||||||
|
|
||||||
|
public SportEasyEmailService(LicenceRepository licenceRepository,
|
||||||
|
SaisonRepository saisonRepository,
|
||||||
|
@Autowired(required = false) JavaMailSender mailSender) {
|
||||||
|
this.licenceRepository = licenceRepository;
|
||||||
|
this.saisonRepository = saisonRepository;
|
||||||
|
this.mailSender = mailSender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record BatchSendResult(int sentCount, int skippedCount, int errorCount, String message) {}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public boolean sendInvitationForLicence(Long licenceId, boolean forceResend) {
|
||||||
|
Licence licence = licenceRepository.findById(licenceId)
|
||||||
|
.orElseThrow(() -> new IllegalArgumentException("Licence introuvable avec l'ID: " + licenceId));
|
||||||
|
|
||||||
|
if (licence.isRenouvellement()) {
|
||||||
|
log.info("Invitation SportEasy non envoyée pour la licence ID {} : il s'agit d'un renouvellement.", licenceId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!forceResend && Boolean.TRUE.equals(licence.getSportEasyEmailSent())) {
|
||||||
|
log.info("Invitation SportEasy déjà envoyée pour la licence ID: {}", licenceId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String recipientEmail = licence.getAdherent() != null ? licence.getAdherent().getEmail() : null;
|
||||||
|
if (recipientEmail == null || recipientEmail.trim().isEmpty()) {
|
||||||
|
throw new IllegalStateException("L'adhérent n'a pas d'adresse e-mail renseignée.");
|
||||||
|
}
|
||||||
|
|
||||||
|
String token = (licence.getCategorie() != null && licence.getCategorie().getSportEasyToken() != null)
|
||||||
|
? licence.getCategorie().getSportEasyToken().trim()
|
||||||
|
: "";
|
||||||
|
|
||||||
|
String inviteUrl;
|
||||||
|
if (token.startsWith("http://") || token.startsWith("https://")) {
|
||||||
|
inviteUrl = token;
|
||||||
|
} else if (!token.isEmpty()) {
|
||||||
|
inviteUrl = sportEasyBaseUrl.endsWith("/") ? sportEasyBaseUrl + token : sportEasyBaseUrl + "/" + token;
|
||||||
|
} else {
|
||||||
|
inviteUrl = sportEasyBaseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
String adherentNom = licence.getAdherent().getPrenom() + " " + licence.getAdherent().getNom();
|
||||||
|
String categorieNom = licence.getCategorie() != null ? licence.getCategorie().getNom() : "AS Talange";
|
||||||
|
String saisonNom = licence.getSaison() != null ? licence.getSaison().getNom() : "";
|
||||||
|
|
||||||
|
String subject = "AS Talange - Invitation SportEasy (" + categorieNom + ")";
|
||||||
|
String htmlContent = buildEmailHtml(adherentNom, categorieNom, saisonNom, inviteUrl);
|
||||||
|
|
||||||
|
boolean sentSuccessfully = false;
|
||||||
|
|
||||||
|
if (mailSender != null) {
|
||||||
|
try {
|
||||||
|
MimeMessage message = mailSender.createMimeMessage();
|
||||||
|
MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
|
||||||
|
helper.setFrom(fromEmail);
|
||||||
|
helper.setTo(recipientEmail);
|
||||||
|
helper.setSubject(subject);
|
||||||
|
helper.setText(htmlContent, true);
|
||||||
|
|
||||||
|
mailSender.send(message);
|
||||||
|
sentSuccessfully = true;
|
||||||
|
log.info("E-mail d'invitation SportEasy envoyé avec succès via SMTP à {} pour {}", recipientEmail, adherentNom);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Impossible d'envoyer l'e-mail via SMTP pour {}: {}. Bascule en mode simulation / log.", recipientEmail, e.getMessage());
|
||||||
|
logDevEmail(recipientEmail, subject, htmlContent);
|
||||||
|
// In dev environment or fallback, mark as processed anyway to simulate full flow
|
||||||
|
sentSuccessfully = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info("Aucun JavaMailSender configuré (Mode DEV). Simulation de l'envoi d'e-mail SportEasy.");
|
||||||
|
logDevEmail(recipientEmail, subject, htmlContent);
|
||||||
|
sentSuccessfully = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sentSuccessfully) {
|
||||||
|
licence.setSportEasyEmailSent(true);
|
||||||
|
licence.setSportEasyEmailSentAt(LocalDateTime.now());
|
||||||
|
licenceRepository.save(licence);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sentSuccessfully;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public BatchSendResult sendBatchInvitationsForActiveSaison(Long categoryId) {
|
||||||
|
Saison activeSaison = saisonRepository.findByEstActiveTrue()
|
||||||
|
.orElseThrow(() -> new IllegalStateException("Aucune saison active trouvée."));
|
||||||
|
|
||||||
|
List<Licence> licences;
|
||||||
|
if (categoryId != null) {
|
||||||
|
licences = licenceRepository.findBySaison(activeSaison).stream()
|
||||||
|
.filter(l -> l.getCategorie() != null && categoryId.equals(l.getCategorie().getId()))
|
||||||
|
.toList();
|
||||||
|
} else {
|
||||||
|
licences = licenceRepository.findBySaison(activeSaison);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sentCount = 0;
|
||||||
|
int skippedCount = 0;
|
||||||
|
int errorCount = 0;
|
||||||
|
|
||||||
|
for (Licence licence : licences) {
|
||||||
|
if (licence.isRenouvellement()) {
|
||||||
|
skippedCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(licence.getSportEasyEmailSent())) {
|
||||||
|
skippedCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String email = licence.getAdherent() != null ? licence.getAdherent().getEmail() : null;
|
||||||
|
if (email == null || email.trim().isEmpty()) {
|
||||||
|
skippedCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean success = sendInvitationForLicence(licence.getId(), false);
|
||||||
|
if (success) {
|
||||||
|
sentCount++;
|
||||||
|
} else {
|
||||||
|
skippedCount++;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Erreur lors de l'envoi d'invitation SportEasy pour la licence ID {}: {}", licence.getId(), e.getMessage());
|
||||||
|
errorCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String msg = String.format("%d invitation(s) SportEasy envoyée(s) avec succès. %d ignorée(s) (déjà envoyées, renouvellements ou sans email), %d erreur(s).",
|
||||||
|
sentCount, skippedCount, errorCount);
|
||||||
|
|
||||||
|
return new BatchSendResult(sentCount, skippedCount, errorCount, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logDevEmail(String recipient, String subject, String body) {
|
||||||
|
log.info("==================== [SIMULATION E-MAIL SPORTEASY] ====================");
|
||||||
|
log.info("Destinataire: {}", recipient);
|
||||||
|
log.info("Sujet: {}", subject);
|
||||||
|
log.info("Contenu:\n{}", body);
|
||||||
|
log.info("=======================================================================");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildEmailHtml(String adherentNom, String categorieNom, String saisonNom, String inviteUrl) {
|
||||||
|
return """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
body { font-family: Arial, sans-serif; background-color: #f4f6f8; margin: 0; padding: 20px; color: #333; }
|
||||||
|
.container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
|
||||||
|
.header { background-color: #1e3a8a; color: #ffffff; padding: 24px; text-align: center; }
|
||||||
|
.header h1 { margin: 0; font-size: 22px; }
|
||||||
|
.content { padding: 24px; line-height: 1.6; }
|
||||||
|
.btn { display: inline-block; background-color: #2563eb; color: #ffffff !important; padding: 12px 24px; border-radius: 6px; text-decoration: none; font-weight: bold; margin-top: 16px; text-align: center; }
|
||||||
|
.footer { background: #f9fafb; border-top: 1px solid #e5e7eb; padding: 16px; text-align: center; font-size: 12px; color: #6b7280; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>AS Talange - Invitation SportEasy</h1>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<p>Bonjour <strong>%s</strong>,</p>
|
||||||
|
<p>Afin d'assurer le suivi des entraînements, convocations et matchs pour la saison <strong>%s</strong> (catégorie <strong>%s</strong>), le club utilise la plateforme <strong>SportEasy</strong>.</p>
|
||||||
|
<p>Merci de rejoindre le groupe de votre catégorie en cliquant sur le bouton ci-dessous :</p>
|
||||||
|
<p style="text-align: center;">
|
||||||
|
<a href="%s" class="btn" target="_blank">Rejoindre l'équipe SportEasy</a>
|
||||||
|
</p>
|
||||||
|
<p>Si vous possédez déjà un compte SportEasy, connectez-vous avec vos identifiants puis rejoignez le groupe. Sinon, créez votre compte gratuitement en quelques secondes.</p>
|
||||||
|
<p>À très vite sur les terrains !<br><strong>L'équipe de l'AS Talange</strong></p>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
Cet e-mail a été envoyé automatiquement par le système de gestion de l'AS Talange.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
""".formatted(
|
||||||
|
adherentNom,
|
||||||
|
saisonNom != null ? saisonNom : "",
|
||||||
|
categorieNom,
|
||||||
|
inviteUrl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE app_user ADD COLUMN last_login_at TIMESTAMP;
|
||||||
|
ALTER TABLE app_user ADD COLUMN last_logout_at TIMESTAMP;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE categorie ADD COLUMN sport_easy_token VARCHAR(255);
|
||||||
|
ALTER TABLE licence ADD COLUMN sport_easy_email_sent BOOLEAN NOT NULL DEFAULT FALSE;
|
||||||
|
ALTER TABLE licence ADD COLUMN sport_easy_email_sent_at TIMESTAMP;
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.astalange.core;
|
||||||
|
|
||||||
|
import com.astalange.core.entity.Dotation;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
public class DotationSizeMatchTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAdherent60SizeMatchBugFix() {
|
||||||
|
String adherentTaille = "11/12ANS (Taille 152cm)";
|
||||||
|
String adherentPointure = "35/38 (Taille 2)";
|
||||||
|
|
||||||
|
// Equipment options for Junior Maillot / Shorts / Tracksuits
|
||||||
|
String opt56 = "5/6ANS (Taille 116cm)";
|
||||||
|
String opt78 = "7/8ANS (Taille 128cm)";
|
||||||
|
String opt910 = "9/10ANS (Taille 140cm)";
|
||||||
|
String opt1112 = "11/12ANS (Taille 152cm)";
|
||||||
|
String opt1314 = "13/14ANS (Taille 164cm)";
|
||||||
|
|
||||||
|
assertFalse(Dotation.isSizeMatch(opt56, adherentTaille), "5/6ANS should NOT match 11/12ANS");
|
||||||
|
assertFalse(Dotation.isSizeMatch(opt78, adherentTaille), "7/8ANS should NOT match 11/12ANS");
|
||||||
|
assertFalse(Dotation.isSizeMatch(opt910, adherentTaille), "9/10ANS should NOT match 11/12ANS");
|
||||||
|
assertTrue(Dotation.isSizeMatch(opt1112, adherentTaille), "11/12ANS MUST match 11/12ANS");
|
||||||
|
assertFalse(Dotation.isSizeMatch(opt1314, adherentTaille), "13/14ANS should NOT match 11/12ANS");
|
||||||
|
|
||||||
|
// Sock sizes
|
||||||
|
String sock2730 = "27/30 (Taille 0)";
|
||||||
|
String sock3134 = "31/34 (Taille 1)";
|
||||||
|
String sock3538 = "35/38 (Taille 2)";
|
||||||
|
String sock3942 = "39/42 (Taille 3)";
|
||||||
|
|
||||||
|
assertFalse(Dotation.isSizeMatch(sock2730, adherentPointure), "27/30 should NOT match 35/38");
|
||||||
|
assertFalse(Dotation.isSizeMatch(sock3134, adherentPointure), "31/34 should NOT match 35/38");
|
||||||
|
assertTrue(Dotation.isSizeMatch(sock3538, adherentPointure), "35/38 MUST match 35/38");
|
||||||
|
assertFalse(Dotation.isSizeMatch(sock3942, adherentPointure), "39/42 should NOT match 35/38");
|
||||||
|
|
||||||
|
// Ensure sock sizes do not match clothing size 152cm due to "Taille 1"
|
||||||
|
assertFalse(Dotation.isSizeMatch(sock3134, adherentTaille), "Sock 31/34 (Taille 1) should NOT match clothing 152cm");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLetterSizes() {
|
||||||
|
assertFalse(Dotation.isSizeMatch("S", "XL"));
|
||||||
|
assertFalse(Dotation.isSizeMatch("M", "XL"));
|
||||||
|
assertTrue(Dotation.isSizeMatch("XL", "XL"));
|
||||||
|
assertTrue(Dotation.isSizeMatch("xxl", "XXL"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSpaceVariations() {
|
||||||
|
assertTrue(Dotation.isSizeMatch("5/6 ANS (Taille 116cm)", "5/6ANS"));
|
||||||
|
assertTrue(Dotation.isSizeMatch("11/12 ANS (Taille 152cm)", "11/12ANS (Taille 152 cm)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
+214
@@ -0,0 +1,214 @@
|
|||||||
|
package com.astalange.core.service;
|
||||||
|
|
||||||
|
import com.astalange.core.entity.*;
|
||||||
|
import com.astalange.core.repository.CategorieRepository;
|
||||||
|
import com.astalange.core.repository.DotationRepository;
|
||||||
|
import com.astalange.core.repository.EquipementRepository;
|
||||||
|
import com.astalange.core.repository.SaisonRepository;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
public class DotationIntegrationTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private CategorieRepository categorieRepository;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private SaisonRepository saisonRepository;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private EquipementRepository equipementRepository;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private com.astalange.core.repository.LicenceRepository licenceRepository;
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private CategorieService categorieService;
|
||||||
|
|
||||||
|
private Equipement maillotJunior;
|
||||||
|
private Equipement chaussettesJunior;
|
||||||
|
private Equipement maillotAdulte;
|
||||||
|
private Equipement chaussettesAdulte;
|
||||||
|
private Categorie catJunior;
|
||||||
|
private Categorie catAdulte;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setUp() {
|
||||||
|
// 1. Junior Equipment
|
||||||
|
maillotJunior = new Equipement();
|
||||||
|
maillotJunior.setId(1L);
|
||||||
|
maillotJunior.setNom("Maillot de match Puma (Junior)");
|
||||||
|
maillotJunior.setTypePublic("TOUS");
|
||||||
|
maillotJunior.setTaillesDisponibles("5/6ANS (Taille 116cm),7/8ANS (Taille 128cm),9/10ANS (Taille 140cm),11/12ANS (Taille 152cm),13/14ANS (Taille 164cm),15/16ANS (Taille 176cm)");
|
||||||
|
|
||||||
|
chaussettesJunior = new Equipement();
|
||||||
|
chaussettesJunior.setId(2L);
|
||||||
|
chaussettesJunior.setNom("Chaussettes puma (Junior)");
|
||||||
|
chaussettesJunior.setTypePublic("TOUS");
|
||||||
|
chaussettesJunior.setTaillesDisponibles("27/30 (Taille 0),31/34 (Taille 1),35/38 (Taille 2),39/42 (Taille 3)");
|
||||||
|
|
||||||
|
catJunior = new Categorie();
|
||||||
|
catJunior.setId(10L);
|
||||||
|
catJunior.setNom("U11");
|
||||||
|
|
||||||
|
CategorieEquipement ce1 = new CategorieEquipement();
|
||||||
|
ce1.setCategorie(catJunior);
|
||||||
|
ce1.setEquipement(maillotJunior);
|
||||||
|
ce1.setObligatoire(true);
|
||||||
|
|
||||||
|
CategorieEquipement ce2 = new CategorieEquipement();
|
||||||
|
ce2.setCategorie(catJunior);
|
||||||
|
ce2.setEquipement(chaussettesJunior);
|
||||||
|
ce2.setObligatoire(true);
|
||||||
|
|
||||||
|
catJunior.setCategorieEquipements(List.of(ce1, ce2));
|
||||||
|
|
||||||
|
// 2. Adult Equipment
|
||||||
|
maillotAdulte = new Equipement();
|
||||||
|
maillotAdulte.setId(3L);
|
||||||
|
maillotAdulte.setNom("Maillot de match Puma (Adulte)");
|
||||||
|
maillotAdulte.setTypePublic("TOUS");
|
||||||
|
maillotAdulte.setTaillesDisponibles("XS,S,M,L,XL,XXL");
|
||||||
|
|
||||||
|
chaussettesAdulte = new Equipement();
|
||||||
|
chaussettesAdulte.setId(4L);
|
||||||
|
chaussettesAdulte.setNom("Chaussettes puma (Adulte)");
|
||||||
|
chaussettesAdulte.setTypePublic("TOUS");
|
||||||
|
chaussettesAdulte.setTaillesDisponibles("35/38 (Taille 2),39/42 (Taille 3),43/46 (Taille 4)");
|
||||||
|
|
||||||
|
catAdulte = new Categorie();
|
||||||
|
catAdulte.setId(20L);
|
||||||
|
catAdulte.setNom("Seniors");
|
||||||
|
|
||||||
|
CategorieEquipement ce3 = new CategorieEquipement();
|
||||||
|
ce3.setCategorie(catAdulte);
|
||||||
|
ce3.setEquipement(maillotAdulte);
|
||||||
|
ce3.setObligatoire(true);
|
||||||
|
|
||||||
|
CategorieEquipement ce4 = new CategorieEquipement();
|
||||||
|
ce4.setCategorie(catAdulte);
|
||||||
|
ce4.setEquipement(chaussettesAdulte);
|
||||||
|
ce4.setObligatoire(true);
|
||||||
|
|
||||||
|
catAdulte.setCategorieEquipements(List.of(ce3, ce4));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Licence createLicence(Categorie cat, String tailleVetement, String pointure) {
|
||||||
|
Adherent adherent = new Adherent();
|
||||||
|
adherent.setTypeMaillot("JOUEUR");
|
||||||
|
adherent.setTailleVetement(tailleVetement);
|
||||||
|
adherent.setPointure(pointure);
|
||||||
|
|
||||||
|
Licence licence = new Licence();
|
||||||
|
licence.setId(100L);
|
||||||
|
licence.setAdherent(adherent);
|
||||||
|
licence.setCategorie(cat);
|
||||||
|
licence.setDotations(new ArrayList<>());
|
||||||
|
return licence;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Junior 11/12ANS (Bug initial Adhérent 60) -> Doit reporter 11/12ANS et 35/38")
|
||||||
|
public void testAdherent60Synchronization() {
|
||||||
|
Licence licence = createLicence(catJunior, "11/12ANS (Taille 152cm)", "35/38 (Taille 2)");
|
||||||
|
|
||||||
|
categorieService.syncDotationsForLicence(licence);
|
||||||
|
|
||||||
|
List<Dotation> dotations = licence.getDotations();
|
||||||
|
assertEquals(2, dotations.size());
|
||||||
|
Dotation dMaillot = dotations.stream().filter(d -> d.getEquipement().getId().equals(1L)).findFirst().orElseThrow();
|
||||||
|
Dotation dChaussettes = dotations.stream().filter(d -> d.getEquipement().getId().equals(2L)).findFirst().orElseThrow();
|
||||||
|
|
||||||
|
assertEquals("11/12ANS (Taille 152cm)", dMaillot.getTaille(), "Le maillot doit être 11/12ANS et non 5/6ANS");
|
||||||
|
assertEquals("35/38 (Taille 2)", dChaussettes.getTaille(), "Les chaussettes doivent être 35/38 et non 31/34");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Junior - Test de toutes les tailles (5/6, 7/8, 9/10, 11/12, 13/14, 15/16)")
|
||||||
|
public void testAllJuniorSizes() {
|
||||||
|
String[][] cases = {
|
||||||
|
{"5/6ANS (Taille 116cm)", "27/30 (Taille 0)", "5/6ANS (Taille 116cm)", "27/30 (Taille 0)"},
|
||||||
|
{"7/8ANS (Taille 128cm)", "31/34 (Taille 1)", "7/8ANS (Taille 128cm)", "31/34 (Taille 1)"},
|
||||||
|
{"9/10ANS (Taille 140cm)", "31/34 (Taille 1)", "9/10ANS (Taille 140cm)", "31/34 (Taille 1)"},
|
||||||
|
{"11/12ANS (Taille 152cm)", "35/38 (Taille 2)", "11/12ANS (Taille 152cm)", "35/38 (Taille 2)"},
|
||||||
|
{"13/14ANS (Taille 164cm)", "35/38 (Taille 2)", "13/14ANS (Taille 164cm)", "35/38 (Taille 2)"},
|
||||||
|
{"15/16ANS (Taille 176cm)", "39/42 (Taille 3)", "15/16ANS (Taille 176cm)", "39/42 (Taille 3)"}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (String[] testCase : cases) {
|
||||||
|
String tv = testCase[0];
|
||||||
|
String pt = testCase[1];
|
||||||
|
String expectedMaillot = testCase[2];
|
||||||
|
String expectedChaussettes = testCase[3];
|
||||||
|
|
||||||
|
Licence licence = createLicence(catJunior, tv, pt);
|
||||||
|
categorieService.syncDotationsForLicence(licence);
|
||||||
|
|
||||||
|
List<Dotation> dotations = licence.getDotations();
|
||||||
|
Dotation dMaillot = dotations.stream().filter(d -> d.getEquipement().getId().equals(1L)).findFirst().orElseThrow();
|
||||||
|
Dotation dChaussettes = dotations.stream().filter(d -> d.getEquipement().getId().equals(2L)).findFirst().orElseThrow();
|
||||||
|
|
||||||
|
assertEquals(expectedMaillot, dMaillot.getTaille(), "Erreur pour la taille vêtement: " + tv);
|
||||||
|
assertEquals(expectedChaussettes, dChaussettes.getTaille(), "Erreur pour la pointure: " + pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Adulte - Test de toutes les tailles (XS, S, M, L, XL, XXL)")
|
||||||
|
public void testAllAdultSizes() {
|
||||||
|
String[][] cases = {
|
||||||
|
{"XS", "35/38 (Taille 2)", "XS", "35/38 (Taille 2)"},
|
||||||
|
{"S", "39/42 (Taille 3)", "S", "39/42 (Taille 3)"},
|
||||||
|
{"M", "39/42 (Taille 3)", "M", "39/42 (Taille 3)"},
|
||||||
|
{"L", "43/46 (Taille 4)", "L", "43/46 (Taille 4)"},
|
||||||
|
{"XL", "43/46 (Taille 4)", "XL", "43/46 (Taille 4)"},
|
||||||
|
{"XXL", "43/46 (Taille 4)", "XXL", "43/46 (Taille 4)"}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (String[] testCase : cases) {
|
||||||
|
String tv = testCase[0];
|
||||||
|
String pt = testCase[1];
|
||||||
|
String expectedMaillot = testCase[2];
|
||||||
|
String expectedChaussettes = testCase[3];
|
||||||
|
|
||||||
|
Licence licence = createLicence(catAdulte, tv, pt);
|
||||||
|
categorieService.syncDotationsForLicence(licence);
|
||||||
|
|
||||||
|
List<Dotation> dotations = licence.getDotations();
|
||||||
|
Dotation dMaillot = dotations.stream().filter(d -> d.getEquipement().getId().equals(3L)).findFirst().orElseThrow();
|
||||||
|
Dotation dChaussettes = dotations.stream().filter(d -> d.getEquipement().getId().equals(4L)).findFirst().orElseThrow();
|
||||||
|
|
||||||
|
assertEquals(expectedMaillot, dMaillot.getTaille(), "Erreur pour la taille adulte vêtement: " + tv);
|
||||||
|
assertEquals(expectedChaussettes, dChaussettes.getTaille(), "Erreur pour la pointure adulte: " + pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Formats alternatifs (Espaces, sans mention de taille)")
|
||||||
|
public void testAlternativeFormats() {
|
||||||
|
Licence licence1 = createLicence(catJunior, "11/12 ANS (Taille 152 cm)", "35/38 (Taille 2)");
|
||||||
|
categorieService.syncDotationsForLicence(licence1);
|
||||||
|
|
||||||
|
Dotation dMaillot1 = licence1.getDotations().stream().filter(d -> d.getEquipement().getId().equals(1L)).findFirst().orElseThrow();
|
||||||
|
assertEquals("11/12ANS (Taille 152cm)", dMaillot1.getTaille());
|
||||||
|
|
||||||
|
Licence licence2 = createLicence(catJunior, "11/12ANS", "35/38");
|
||||||
|
categorieService.syncDotationsForLicence(licence2);
|
||||||
|
|
||||||
|
Dotation dMaillot2 = licence2.getDotations().stream().filter(d -> d.getEquipement().getId().equals(1L)).findFirst().orElseThrow();
|
||||||
|
Dotation dChaussettes2 = licence2.getDotations().stream().filter(d -> d.getEquipement().getId().equals(2L)).findFirst().orElseThrow();
|
||||||
|
assertEquals("11/12ANS (Taille 152cm)", dMaillot2.getTaille());
|
||||||
|
assertEquals("35/38 (Taille 2)", dChaussettes2.getTaille());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>as-talange-parent</artifactId>
|
<artifactId>as-talange-parent</artifactId>
|
||||||
<groupId>com.astalange</groupId>
|
<groupId>com.astalange</groupId>
|
||||||
<version>1.5</version>
|
<version>1.7-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -24,14 +24,16 @@ public class AdherentController {
|
|||||||
private final com.astalange.core.repository.ModePaiementRepository modePaiementRepository;
|
private final com.astalange.core.repository.ModePaiementRepository modePaiementRepository;
|
||||||
private final SaisonRepository saisonRepository;
|
private final SaisonRepository saisonRepository;
|
||||||
private final com.astalange.core.service.CategorieService categorieService;
|
private final com.astalange.core.service.CategorieService categorieService;
|
||||||
|
private final com.astalange.core.service.SportEasyEmailService sportEasyEmailService;
|
||||||
|
|
||||||
public AdherentController(AdherentRepository adherentRepository, CategorieRepository categorieRepository, com.astalange.core.repository.LicenceRepository licenceRepository, com.astalange.core.repository.ModePaiementRepository modePaiementRepository, SaisonRepository saisonRepository, com.astalange.core.service.CategorieService categorieService) {
|
public AdherentController(AdherentRepository adherentRepository, CategorieRepository categorieRepository, com.astalange.core.repository.LicenceRepository licenceRepository, com.astalange.core.repository.ModePaiementRepository modePaiementRepository, SaisonRepository saisonRepository, com.astalange.core.service.CategorieService categorieService, com.astalange.core.service.SportEasyEmailService sportEasyEmailService) {
|
||||||
this.adherentRepository = adherentRepository;
|
this.adherentRepository = adherentRepository;
|
||||||
this.categorieRepository = categorieRepository;
|
this.categorieRepository = categorieRepository;
|
||||||
this.licenceRepository = licenceRepository;
|
this.licenceRepository = licenceRepository;
|
||||||
this.modePaiementRepository = modePaiementRepository;
|
this.modePaiementRepository = modePaiementRepository;
|
||||||
this.saisonRepository = saisonRepository;
|
this.saisonRepository = saisonRepository;
|
||||||
this.categorieService = categorieService;
|
this.categorieService = categorieService;
|
||||||
|
this.sportEasyEmailService = sportEasyEmailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@org.springframework.web.bind.annotation.ModelAttribute("equipes")
|
@org.springframework.web.bind.annotation.ModelAttribute("equipes")
|
||||||
@@ -48,6 +50,7 @@ public class AdherentController {
|
|||||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String licence,
|
@org.springframework.web.bind.annotation.RequestParam(required = false) String licence,
|
||||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String email,
|
@org.springframework.web.bind.annotation.RequestParam(required = false) String email,
|
||||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String paiement,
|
@org.springframework.web.bind.annotation.RequestParam(required = false) String paiement,
|
||||||
|
@org.springframework.web.bind.annotation.RequestParam(required = false) String sporteasy,
|
||||||
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "nom") String sortField,
|
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "nom") String sortField,
|
||||||
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "asc") String sortDirection,
|
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "asc") String sortDirection,
|
||||||
@org.springframework.web.bind.annotation.RequestParam(defaultValue = "0") int page,
|
@org.springframework.web.bind.annotation.RequestParam(defaultValue = "0") int page,
|
||||||
@@ -114,6 +117,21 @@ public class AdherentController {
|
|||||||
}).collect(java.util.stream.Collectors.toList());
|
}).collect(java.util.stream.Collectors.toList());
|
||||||
model.addAttribute("paiementFilter", paiement.trim());
|
model.addAttribute("paiementFilter", paiement.trim());
|
||||||
}
|
}
|
||||||
|
if (sporteasy != null && !sporteasy.trim().isEmpty()) {
|
||||||
|
adherents = adherents.stream().filter(a -> {
|
||||||
|
Licence lic = a.getLicenceActuelle();
|
||||||
|
if (lic == null) return false;
|
||||||
|
if ("NON_INVITE".equalsIgnoreCase(sporteasy)) {
|
||||||
|
return !lic.isRenouvellement() && !Boolean.TRUE.equals(lic.getSportEasyEmailSent());
|
||||||
|
} else if ("INVITE".equalsIgnoreCase(sporteasy)) {
|
||||||
|
return !lic.isRenouvellement() && Boolean.TRUE.equals(lic.getSportEasyEmailSent());
|
||||||
|
} else if ("RENOUVELLEMENT".equalsIgnoreCase(sporteasy)) {
|
||||||
|
return lic.isRenouvellement();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).collect(java.util.stream.Collectors.toList());
|
||||||
|
model.addAttribute("sporteasyFilter", sporteasy.trim());
|
||||||
|
}
|
||||||
|
|
||||||
// 3. Sort
|
// 3. Sort
|
||||||
java.util.Comparator<Adherent> comparator = (a1, a2) -> 0;
|
java.util.Comparator<Adherent> comparator = (a1, a2) -> 0;
|
||||||
@@ -234,12 +252,20 @@ public class AdherentController {
|
|||||||
existing.setLieuNaissancePays(adherent.getLieuNaissancePays());
|
existing.setLieuNaissancePays(adherent.getLieuNaissancePays());
|
||||||
existing.setNationalite(adherent.getNationalite());
|
existing.setNationalite(adherent.getNationalite());
|
||||||
existing.setEmail(adherent.getEmail());
|
existing.setEmail(adherent.getEmail());
|
||||||
|
existing.setTelephone(adherent.getTelephone());
|
||||||
existing.setRepresentantLegal(adherent.getRepresentantLegal());
|
existing.setRepresentantLegal(adherent.getRepresentantLegal());
|
||||||
existing.setResidentTalange(adherent.isResidentTalange());
|
existing.setResidentTalange(adherent.isResidentTalange());
|
||||||
existing.setSexe(adherent.getSexe());
|
existing.setSexe(adherent.getSexe());
|
||||||
existing.setTypeMaillot(adherent.getTypeMaillot());
|
existing.setTypeMaillot(adherent.getTypeMaillot());
|
||||||
|
existing.setTailleVetement(adherent.getTailleVetement());
|
||||||
|
existing.setPointure(adherent.getPointure());
|
||||||
|
|
||||||
adherentRepository.save(existing);
|
adherentRepository.save(existing);
|
||||||
|
|
||||||
|
List<Licence> licences = licenceRepository.findByAdherentId(existing.getId());
|
||||||
|
for (Licence licence : licences) {
|
||||||
|
categorieService.syncDotationsForLicence(licence);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
adherentRepository.save(adherent);
|
adherentRepository.save(adherent);
|
||||||
}
|
}
|
||||||
@@ -276,4 +302,57 @@ public class AdherentController {
|
|||||||
adherentRepository.delete(adherent);
|
adherentRepository.delete(adherent);
|
||||||
return "redirect:/adherents";
|
return "redirect:/adherents";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@org.springframework.web.bind.annotation.PostMapping("/{id}/sporteasy-invite")
|
||||||
|
public String sendSportEasyInvite(
|
||||||
|
@org.springframework.web.bind.annotation.PathVariable Long id,
|
||||||
|
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "false") boolean force,
|
||||||
|
org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) {
|
||||||
|
|
||||||
|
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||||
|
if (activeSaison == null) {
|
||||||
|
redirectAttributes.addFlashAttribute("errorMessage", "Erreur : Aucune saison active trouvée.");
|
||||||
|
return "redirect:/adherents";
|
||||||
|
}
|
||||||
|
|
||||||
|
Licence licence = licenceRepository.findByAdherentIdAndSaison(id, activeSaison).orElse(null);
|
||||||
|
if (licence == null) {
|
||||||
|
redirectAttributes.addFlashAttribute("errorMessage", "Cet adhérent n'a pas de licence pour la saison active.");
|
||||||
|
return "redirect:/adherents";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (licence.isRenouvellement()) {
|
||||||
|
redirectAttributes.addFlashAttribute("infoMessage", "Les invitations SportEasy sont réservées aux nouveaux adhérents (nouvelle licence).");
|
||||||
|
return "redirect:/adherents";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean success = sportEasyEmailService.sendInvitationForLicence(licence.getId(), force);
|
||||||
|
if (success) {
|
||||||
|
redirectAttributes.addFlashAttribute("successMessage", "L'invitation SportEasy a été envoyée avec succès à l'adhérent.");
|
||||||
|
} else {
|
||||||
|
redirectAttributes.addFlashAttribute("infoMessage", "L'invitation SportEasy avait déjà été envoyée à cet adhérent.");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
redirectAttributes.addFlashAttribute("errorMessage", "Erreur lors de l'envoi de l'invitation : " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return "redirect:/adherents";
|
||||||
|
}
|
||||||
|
|
||||||
|
@org.springframework.web.bind.annotation.PostMapping("/sporteasy-invite-batch")
|
||||||
|
public String sendSportEasyInviteBatch(
|
||||||
|
@org.springframework.web.bind.annotation.RequestParam(required = false) Long categoryId,
|
||||||
|
org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
com.astalange.core.service.SportEasyEmailService.BatchSendResult result =
|
||||||
|
sportEasyEmailService.sendBatchInvitationsForActiveSaison(categoryId);
|
||||||
|
redirectAttributes.addFlashAttribute("successMessage", result.message());
|
||||||
|
} catch (Exception e) {
|
||||||
|
redirectAttributes.addFlashAttribute("errorMessage", "Erreur lors de l'envoi des invitations SportEasy : " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return "redirect:/adherents";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,19 +76,35 @@ public class DotationController {
|
|||||||
@RequestParam(required = false) Long equipementId,
|
@RequestParam(required = false) Long equipementId,
|
||||||
@RequestParam(required = false) Long categorieId,
|
@RequestParam(required = false) Long categorieId,
|
||||||
@RequestParam(required = false) Boolean fourni,
|
@RequestParam(required = false) Boolean fourni,
|
||||||
|
@RequestParam(defaultValue = "0") int page,
|
||||||
|
@RequestParam(defaultValue = "20") int size,
|
||||||
Model model) {
|
Model model) {
|
||||||
|
|
||||||
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||||
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, saisonActive);
|
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, saisonActive);
|
||||||
List<Dotation> dotations = dotationRepository.findAll(spec);
|
List<Dotation> allDotations = dotationRepository.findAll(spec);
|
||||||
|
|
||||||
model.addAttribute("dotations", dotations);
|
int totalElements = allDotations.size();
|
||||||
|
int totalPages = (int) Math.ceil((double) totalElements / size);
|
||||||
|
if (page < 0) page = 0;
|
||||||
|
if (page >= totalPages && totalPages > 0) page = totalPages - 1;
|
||||||
|
|
||||||
|
int start = page * size;
|
||||||
|
int end = Math.min(start + size, totalElements);
|
||||||
|
List<Dotation> pageContent = (start < totalElements) ? allDotations.subList(start, end) : List.of();
|
||||||
|
|
||||||
|
model.addAttribute("dotations", pageContent);
|
||||||
model.addAttribute("equipements", equipementRepository.findAll());
|
model.addAttribute("equipements", equipementRepository.findAll());
|
||||||
model.addAttribute("categories", categorieRepository.findAll());
|
model.addAttribute("categories", categorieRepository.findAll());
|
||||||
model.addAttribute("equipementId", equipementId);
|
model.addAttribute("equipementId", equipementId);
|
||||||
model.addAttribute("categorieId", categorieId);
|
model.addAttribute("categorieId", categorieId);
|
||||||
model.addAttribute("fourni", fourni);
|
model.addAttribute("fourni", fourni);
|
||||||
|
|
||||||
|
model.addAttribute("currentPage", page);
|
||||||
|
model.addAttribute("totalPages", totalPages);
|
||||||
|
model.addAttribute("totalElements", totalElements);
|
||||||
|
model.addAttribute("pageSize", size);
|
||||||
|
|
||||||
return "parametrage/equipements_recherche";
|
return "parametrage/equipements_recherche";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,14 +139,25 @@ public class LicenceController {
|
|||||||
@RequestParam(required = false) String numeroLicence,
|
@RequestParam(required = false) String numeroLicence,
|
||||||
@RequestParam(required = false) String email,
|
@RequestParam(required = false) String email,
|
||||||
@RequestParam(required = false) String typeDemande,
|
@RequestParam(required = false) String typeDemande,
|
||||||
|
@RequestParam(defaultValue = "0") int page,
|
||||||
|
@RequestParam(defaultValue = "20") int size,
|
||||||
org.springframework.ui.Model model) {
|
org.springframework.ui.Model model) {
|
||||||
|
|
||||||
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||||
org.springframework.data.jpa.domain.Specification<Licence> spec = buildLicenceSpecification(nom, prenom, categorieId, numeroLicence, email, typeDemande, saisonActive);
|
org.springframework.data.jpa.domain.Specification<Licence> spec = buildLicenceSpecification(nom, prenom, categorieId, numeroLicence, email, typeDemande, saisonActive);
|
||||||
|
|
||||||
List<Licence> licences = licenceRepository.findAll(spec);
|
List<Licence> allLicences = licenceRepository.findAll(spec);
|
||||||
|
|
||||||
model.addAttribute("licences", licences);
|
int totalElements = allLicences.size();
|
||||||
|
int totalPages = (int) Math.ceil((double) totalElements / size);
|
||||||
|
if (page < 0) page = 0;
|
||||||
|
if (page >= totalPages && totalPages > 0) page = totalPages - 1;
|
||||||
|
|
||||||
|
int start = page * size;
|
||||||
|
int end = Math.min(start + size, totalElements);
|
||||||
|
List<Licence> pageContent = (start < totalElements) ? allLicences.subList(start, end) : List.of();
|
||||||
|
|
||||||
|
model.addAttribute("licences", pageContent);
|
||||||
model.addAttribute("categories", categorieRepository.findAll());
|
model.addAttribute("categories", categorieRepository.findAll());
|
||||||
model.addAttribute("nomFilter", nom);
|
model.addAttribute("nomFilter", nom);
|
||||||
model.addAttribute("prenomFilter", prenom);
|
model.addAttribute("prenomFilter", prenom);
|
||||||
@@ -155,6 +166,11 @@ public class LicenceController {
|
|||||||
model.addAttribute("emailFilter", email);
|
model.addAttribute("emailFilter", email);
|
||||||
model.addAttribute("typeDemandeFilter", typeDemande);
|
model.addAttribute("typeDemandeFilter", typeDemande);
|
||||||
|
|
||||||
|
model.addAttribute("currentPage", page);
|
||||||
|
model.addAttribute("totalPages", totalPages);
|
||||||
|
model.addAttribute("totalElements", totalElements);
|
||||||
|
model.addAttribute("pageSize", size);
|
||||||
|
|
||||||
return "parametrage/licences_recherche";
|
return "parametrage/licences_recherche";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.astalange.web.controller;
|
package com.astalange.web.controller;
|
||||||
|
|
||||||
|
import com.astalange.core.entity.AppUser;
|
||||||
|
import com.astalange.core.entity.Role;
|
||||||
|
import com.astalange.core.repository.AppUserRepository;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.session.SessionRegistry;
|
import org.springframework.security.core.session.SessionRegistry;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
@@ -8,7 +11,9 @@ import org.springframework.ui.Model;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@@ -16,22 +21,73 @@ import java.util.stream.Collectors;
|
|||||||
public class SessionController {
|
public class SessionController {
|
||||||
|
|
||||||
private final SessionRegistry sessionRegistry;
|
private final SessionRegistry sessionRegistry;
|
||||||
|
private final AppUserRepository userRepository;
|
||||||
|
|
||||||
public SessionController(SessionRegistry sessionRegistry) {
|
public SessionController(SessionRegistry sessionRegistry, AppUserRepository userRepository) {
|
||||||
this.sessionRegistry = sessionRegistry;
|
this.sessionRegistry = sessionRegistry;
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UserSessionDTO {
|
||||||
|
private final Long id;
|
||||||
|
private final String username;
|
||||||
|
private final boolean online;
|
||||||
|
private final LocalDateTime lastLoginAt;
|
||||||
|
private final LocalDateTime lastLogoutAt;
|
||||||
|
private final String roles;
|
||||||
|
|
||||||
|
public UserSessionDTO(Long id, String username, boolean online, LocalDateTime lastLoginAt, LocalDateTime lastLogoutAt, String roles) {
|
||||||
|
this.id = id;
|
||||||
|
this.username = username;
|
||||||
|
this.online = online;
|
||||||
|
this.lastLoginAt = lastLoginAt;
|
||||||
|
this.lastLogoutAt = lastLogoutAt;
|
||||||
|
this.roles = roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() { return id; }
|
||||||
|
public String getUsername() { return username; }
|
||||||
|
public boolean isOnline() { return online; }
|
||||||
|
public LocalDateTime getLastLoginAt() { return lastLoginAt; }
|
||||||
|
public LocalDateTime getLastLogoutAt() { return lastLogoutAt; }
|
||||||
|
public String getRoles() { return roles; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("hasRole('ADMIN')")
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
public String viewSessions(Model model) {
|
public String viewSessions(Model model) {
|
||||||
List<Object> principals = sessionRegistry.getAllPrincipals();
|
List<Object> principals = sessionRegistry.getAllPrincipals();
|
||||||
List<String> activeUsers = principals.stream()
|
Set<String> activeUsernames = principals.stream()
|
||||||
.filter(principal -> principal instanceof UserDetails)
|
.filter(principal -> principal instanceof UserDetails)
|
||||||
.map(principal -> ((UserDetails) principal).getUsername())
|
.map(principal -> ((UserDetails) principal).getUsername())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
model.addAttribute("activeUsers", activeUsers);
|
List<AppUser> allUsers = userRepository.findAll();
|
||||||
model.addAttribute("activeCount", activeUsers.size());
|
|
||||||
|
List<UserSessionDTO> userSessions = allUsers.stream().map(user -> {
|
||||||
|
boolean isOnline = activeUsernames.contains(user.getUsername());
|
||||||
|
String rolesStr = user.getRoles().stream()
|
||||||
|
.map(Role::getName)
|
||||||
|
.map(r -> r.replace("ROLE_", ""))
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
|
|
||||||
|
return new UserSessionDTO(
|
||||||
|
user.getId(),
|
||||||
|
user.getUsername(),
|
||||||
|
isOnline,
|
||||||
|
user.getLastLoginAt(),
|
||||||
|
user.getLastLogoutAt(),
|
||||||
|
rolesStr
|
||||||
|
);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
long activeCount = userSessions.stream().filter(UserSessionDTO::isOnline).count();
|
||||||
|
long offlineCount = userSessions.size() - activeCount;
|
||||||
|
|
||||||
|
model.addAttribute("userSessions", userSessions);
|
||||||
|
model.addAttribute("activeCount", activeCount);
|
||||||
|
model.addAttribute("offlineCount", offlineCount);
|
||||||
|
model.addAttribute("totalCount", userSessions.size());
|
||||||
return "admin/sessions";
|
return "admin/sessions";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,21 @@ spring:
|
|||||||
enabled: true
|
enabled: true
|
||||||
locations: classpath:db/migration
|
locations: classpath:db/migration
|
||||||
validate-on-migrate: false
|
validate-on-migrate: false
|
||||||
|
mail:
|
||||||
|
host: ${SPRING_MAIL_HOST:localhost}
|
||||||
|
port: ${SPRING_MAIL_PORT:1025}
|
||||||
|
properties:
|
||||||
|
mail:
|
||||||
|
smtp:
|
||||||
|
auth: false
|
||||||
|
starttls:
|
||||||
|
enable: false
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8080
|
port: 8080
|
||||||
|
|
||||||
app:
|
app:
|
||||||
version: @project.version@
|
version: @project.version@
|
||||||
|
|
||||||
|
sporteasy:
|
||||||
|
base-url: https://www.sporteasy.net/join/
|
||||||
|
|||||||
@@ -413,22 +413,17 @@
|
|||||||
<div th:if="${dot.equipement.taillesDisponibles != null and !dot.equipement.taillesDisponibles.trim().isEmpty()}">
|
<div th:if="${dot.equipement.taillesDisponibles != null and !dot.equipement.taillesDisponibles.trim().isEmpty()}">
|
||||||
<label class="block text-[9px] uppercase font-bold text-gray-400">Taille</label>
|
<label class="block text-[9px] uppercase font-bold text-gray-400">Taille</label>
|
||||||
<select th:name="'taille_' + ${dot.id}" class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
|
<select th:name="'taille_' + ${dot.id}" class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
|
||||||
<option value="" th:selected="${dot.taille == null or dot.taille.isEmpty()}">Choisir...</option>
|
<option value="">Choisir...</option>
|
||||||
<option th:if="${dot.taille != null and !dot.taille.isEmpty()}"
|
<option th:if="${dot.taille != null and !dot.taille.isEmpty() and !#strings.contains(dot.equipement.taillesDisponibles, dot.taille)}"
|
||||||
th:value="${dot.taille}"
|
th:value="${dot.taille}"
|
||||||
th:text="${dot.taille} + ' (Actuelle)'"
|
th:text="${dot.taille} + ' (Actuelle)'"
|
||||||
selected></option>
|
selected></option>
|
||||||
<option th:each="t : ${#strings.arraySplit(dot.equipement.taillesDisponibles, ',')}"
|
<option th:each="t : ${#strings.arraySplit(dot.equipement.taillesDisponibles, ',')}"
|
||||||
th:if="${dot.taille == null or dot.taille != #strings.trim(t)}"
|
|
||||||
th:value="${#strings.trim(t)}"
|
th:value="${#strings.trim(t)}"
|
||||||
th:text="${#strings.trim(t)}"
|
th:text="${#strings.trim(t)}"
|
||||||
th:selected="${dot.taille == null and (#strings.trim(t) == adherent.tailleVetement or #strings.trim(t) == adherent.pointure)}"></option>
|
th:selected="${dot.isTailleOptionSelected(#strings.trim(t))}"></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div th:if="${(dot.equipement.taillesDisponibles == null or dot.equipement.taillesDisponibles.trim().isEmpty())}">
|
|
||||||
<label class="block text-[9px] uppercase font-bold text-gray-400">Taille</label>
|
|
||||||
<input type="text" th:name="'taille_' + ${dot.id}" th:value="${dot.taille != null and !dot.taille.isEmpty() ? dot.taille : (adherent.tailleVetement != null ? adherent.tailleVetement : '')}" class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none" placeholder="Taille/Pointure">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div th:if="${dot.equipement.couleursDisponibles != null and !dot.equipement.couleursDisponibles.trim().isEmpty()}">
|
<div th:if="${dot.equipement.couleursDisponibles != null and !dot.equipement.couleursDisponibles.trim().isEmpty()}">
|
||||||
<label class="block text-[9px] uppercase font-bold text-gray-400">Couleur</label>
|
<label class="block text-[9px] uppercase font-bold text-gray-400">Couleur</label>
|
||||||
|
|||||||
@@ -29,10 +29,29 @@
|
|||||||
<div class="flex-1 overflow-auto p-6">
|
<div class="flex-1 overflow-auto p-6">
|
||||||
<div class="flex justify-between items-center mb-6">
|
<div class="flex justify-between items-center mb-6">
|
||||||
<h3 class="text-xl font-bold text-gray-900">Liste des Adhérents</h3>
|
<h3 class="text-xl font-bold text-gray-900">Liste des Adhérents</h3>
|
||||||
|
<div class="flex items-center space-x-3">
|
||||||
|
<form th:action="@{/adherents/sporteasy-invite-batch}" method="post" onsubmit="return confirm('Envoyer les invitations SportEasy à tous les adhérents non invités de la saison active ?');">
|
||||||
|
<button type="submit" class="bg-indigo-50 text-indigo-700 hover:bg-indigo-100 border border-indigo-200 px-4 py-2 rounded-lg text-sm font-medium transition-colors flex items-center space-x-1.5 shadow-2xs">
|
||||||
|
<svg class="w-4 h-4 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path></svg>
|
||||||
|
<span>Inviter sur SportEasy</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
<a th:href="@{/adherents/new}" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors inline-block">
|
<a th:href="@{/adherents/new}" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors inline-block">
|
||||||
+ Nouvel Adhérent
|
+ Nouvel Adhérent
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Messages d'information -->
|
||||||
|
<div th:if="${successMessage}" class="mb-4 p-4 bg-green-50 border-l-4 border-green-500 rounded-lg text-sm text-green-800 font-medium">
|
||||||
|
<span th:text="${successMessage}"></span>
|
||||||
|
</div>
|
||||||
|
<div th:if="${errorMessage}" class="mb-4 p-4 bg-red-50 border-l-4 border-red-500 rounded-lg text-sm text-red-800 font-medium">
|
||||||
|
<span th:text="${errorMessage}"></span>
|
||||||
|
</div>
|
||||||
|
<div th:if="${infoMessage}" class="mb-4 p-4 bg-blue-50 border-l-4 border-blue-500 rounded-lg text-sm text-blue-800 font-medium">
|
||||||
|
<span th:text="${infoMessage}"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Table Container with Wrapper-level HTMX triggers for filters -->
|
<!-- Table Container with Wrapper-level HTMX triggers for filters -->
|
||||||
<div id="adherents-table-container"
|
<div id="adherents-table-container"
|
||||||
@@ -109,6 +128,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<th class="py-3 px-6 font-medium text-center">Paiement</th>
|
<th class="py-3 px-6 font-medium text-center">Paiement</th>
|
||||||
|
<th class="py-3 px-4 font-medium text-center">SportEasy</th>
|
||||||
<th class="py-3 px-6 font-medium text-right">Actions</th>
|
<th class="py-3 px-6 font-medium text-right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Filter Row -->
|
<!-- Filter Row -->
|
||||||
@@ -141,12 +161,20 @@
|
|||||||
<option value="AUCUNE" th:selected="${paiementFilter == 'AUCUNE'}">Aucune licence</option>
|
<option value="AUCUNE" th:selected="${paiementFilter == 'AUCUNE'}">Aucune licence</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="py-2 px-3">
|
||||||
|
<select id="filterSportEasy" name="sporteasy" class="w-full border border-gray-300 rounded px-2 py-1 text-xs focus:ring-1 focus:ring-blue-500 focus:outline-none">
|
||||||
|
<option value="">Tous</option>
|
||||||
|
<option value="NON_INVITE" th:selected="${sporteasyFilter == 'NON_INVITE'}">Non invité</option>
|
||||||
|
<option value="INVITE" th:selected="${sporteasyFilter == 'INVITE'}">Invité</option>
|
||||||
|
<option value="RENOUVELLEMENT" th:selected="${sporteasyFilter == 'RENOUVELLEMENT'}">Renouvellement</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
<td class="py-2 px-3"></td>
|
<td class="py-2 px-3"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-gray-200 text-sm">
|
<tbody class="divide-y divide-gray-200 text-sm">
|
||||||
<tr th:if="${#lists.isEmpty(adherents)}">
|
<tr th:if="${#lists.isEmpty(adherents)}">
|
||||||
<td colspan="7" class="py-8 text-center text-gray-500">Aucun adhérent enregistré.</td>
|
<td colspan="8" class="py-8 text-center text-gray-500">Aucun adhérent enregistré.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:each="adherent : ${adherents}" class="hover:bg-gray-50 transition-colors adherent-row">
|
<tr th:each="adherent : ${adherents}" class="hover:bg-gray-50 transition-colors adherent-row">
|
||||||
<td class="py-4 px-6 font-medium text-gray-900">
|
<td class="py-4 px-6 font-medium text-gray-900">
|
||||||
@@ -193,6 +221,37 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
<!-- SportEasy Status Column -->
|
||||||
|
<td class="py-3 px-4 text-center">
|
||||||
|
<div th:if="${adherent.getLicenceActuelle() != null}">
|
||||||
|
<div th:if="${adherent.getLicenceActuelle().isRenouvellement()}" class="text-xs text-gray-400 italic">
|
||||||
|
Renouvellement
|
||||||
|
</div>
|
||||||
|
<div th:unless="${adherent.getLicenceActuelle().isRenouvellement()}">
|
||||||
|
<div th:if="${adherent.getLicenceActuelle().getSportEasyEmailSent()}" class="flex flex-col items-center space-y-1">
|
||||||
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800 border border-emerald-200"
|
||||||
|
th:title="${adherent.getLicenceActuelle().getSportEasyEmailSentAt() != null ? 'Envoyé le ' + #temporals.format(adherent.getLicenceActuelle().getSportEasyEmailSentAt(), 'dd/MM/yyyy HH:mm') : 'Invité'}">
|
||||||
|
🟢 Invité
|
||||||
|
</span>
|
||||||
|
<form th:action="@{/adherents/{id}/sporteasy-invite(id=${adherent.id})}" method="post">
|
||||||
|
<input type="hidden" name="force" value="true" />
|
||||||
|
<button type="submit" class="text-[10px] text-gray-500 hover:text-blue-600 underline">Renvoyer</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div th:if="${!adherent.getLicenceActuelle().getSportEasyEmailSent()}" class="flex flex-col items-center space-y-1">
|
||||||
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-600 border border-gray-200">
|
||||||
|
⚪ Non invité
|
||||||
|
</span>
|
||||||
|
<form th:action="@{/adherents/{id}/sporteasy-invite(id=${adherent.id})}" method="post">
|
||||||
|
<button type="submit" class="text-xs font-medium text-indigo-600 hover:text-indigo-800 bg-indigo-50 hover:bg-indigo-100 px-2.5 py-1 rounded-md border border-indigo-200 transition-colors">Inviter</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:if="${adherent.getLicenceActuelle() == null}" class="text-xs text-gray-400 italic">
|
||||||
|
-
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td class="py-4 px-6 text-right flex justify-end space-x-3 items-center">
|
<td class="py-4 px-6 text-right flex justify-end space-x-3 items-center">
|
||||||
<a th:href="@{/adherents/{id}/edit(id=${adherent.id})}" class="text-indigo-600 hover:text-indigo-900 font-medium bg-indigo-50 px-3 py-1 rounded-lg">Voir / Modifier</a>
|
<a th:href="@{/adherents/{id}/edit(id=${adherent.id})}" class="text-indigo-600 hover:text-indigo-900 font-medium bg-indigo-50 px-3 py-1 rounded-lg">Voir / Modifier</a>
|
||||||
<form th:action="@{/adherents/{id}/delete(id=${adherent.id})}" method="post" onsubmit="return confirm('Supprimer cet adhérent ?');">
|
<form th:action="@{/adherents/{id}/delete(id=${adherent.id})}" method="post" onsubmit="return confirm('Supprimer cet adhérent ?');">
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html xmlns:th="http://www.thymeleaf.org">
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Utilisateurs Connectés - AS Talange</title>
|
<title>Utilisateurs & Sessions - AS Talange</title>
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.11"></script>
|
<script src="https://unpkg.com/htmx.org@1.9.11"></script>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||||
@@ -19,41 +19,99 @@
|
|||||||
<main class="flex-1 flex flex-col h-screen overflow-hidden">
|
<main class="flex-1 flex flex-col h-screen overflow-hidden">
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<header class="h-16 bg-white border-b border-gray-200 flex items-center justify-between px-6">
|
<header class="h-16 bg-white border-b border-gray-200 flex items-center justify-between px-6">
|
||||||
<h2 class="text-lg font-semibold text-gray-800">Utilisateurs Connectés</h2>
|
<h2 class="text-lg font-semibold text-gray-800">Suivi des Connectivité & Sessions</h2>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- Main section -->
|
<!-- Main section -->
|
||||||
<div class="flex-1 overflow-auto p-6">
|
<div class="flex-1 overflow-auto p-6">
|
||||||
|
|
||||||
|
<!-- Cards summary -->
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
|
||||||
|
<div class="bg-white p-5 rounded-xl shadow-sm border border-gray-100 flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<p class="text-sm font-medium text-gray-500">Total Utilisateurs</p>
|
||||||
|
<p class="text-2xl font-bold text-gray-900 mt-1" th:text="${totalCount}">0</p>
|
||||||
|
</div>
|
||||||
|
<div class="w-10 h-10 rounded-lg bg-blue-50 text-blue-600 flex items-center justify-center font-bold">
|
||||||
|
👥
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white p-5 rounded-xl shadow-sm border border-gray-100 flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<p class="text-sm font-medium text-gray-500">Sessions Actives (En ligne)</p>
|
||||||
|
<p class="text-2xl font-bold text-green-600 mt-1" th:text="${activeCount}">0</p>
|
||||||
|
</div>
|
||||||
|
<div class="w-10 h-10 rounded-lg bg-green-50 text-green-600 flex items-center justify-center font-bold">
|
||||||
|
🟢
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white p-5 rounded-xl shadow-sm border border-gray-100 flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<p class="text-sm font-medium text-gray-500">Hors Ligne</p>
|
||||||
|
<p class="text-2xl font-bold text-gray-600 mt-1" th:text="${offlineCount}">0</p>
|
||||||
|
</div>
|
||||||
|
<div class="w-10 h-10 rounded-lg bg-gray-100 text-gray-500 flex items-center justify-center font-bold">
|
||||||
|
⚪
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Header & Action -->
|
||||||
<div class="mb-6 flex justify-between items-center">
|
<div class="mb-6 flex justify-between items-center">
|
||||||
<h3 class="text-xl font-bold text-gray-900">
|
<h3 class="text-xl font-bold text-gray-900">
|
||||||
Sessions Actives (<span th:text="${activeCount}">0</span>)
|
Liste des Utilisateurs
|
||||||
</h3>
|
</h3>
|
||||||
<button hx-get="/admin/sessions" hx-target="body" hx-swap="outerHTML" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors">
|
<button hx-get="/admin/sessions" hx-target="body" hx-swap="outerHTML" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors flex items-center space-x-2">
|
||||||
Rafraîchir
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
|
||||||
|
</svg>
|
||||||
|
<span>Rafraîchir</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- User Table -->
|
||||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||||
<table class="w-full text-left border-collapse">
|
<table class="w-full text-left border-collapse">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="bg-gray-50 text-gray-500 text-sm uppercase tracking-wider border-b border-gray-200">
|
<tr class="bg-gray-50 text-gray-500 text-xs uppercase tracking-wider border-b border-gray-200">
|
||||||
<th class="py-3 px-6 font-medium text-left">Nom d'utilisateur</th>
|
<th class="py-3 px-6 font-medium text-left">Utilisateur</th>
|
||||||
|
<th class="py-3 px-6 font-medium text-left">Rôle(s)</th>
|
||||||
<th class="py-3 px-6 font-medium text-left">Statut</th>
|
<th class="py-3 px-6 font-medium text-left">Statut</th>
|
||||||
|
<th class="py-3 px-6 font-medium text-left">Dernière Connexion</th>
|
||||||
|
<th class="py-3 px-6 font-medium text-left">Dernière Déconnexion</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-gray-200 text-sm">
|
<tbody class="divide-y divide-gray-200 text-sm">
|
||||||
<tr th:if="${#lists.isEmpty(activeUsers)}">
|
<tr th:if="${#lists.isEmpty(userSessions)}">
|
||||||
<td colspan="2" class="py-8 text-center text-gray-500">Aucun utilisateur connecté pour le moment.</td>
|
<td colspan="5" class="py-8 text-center text-gray-500">Aucun utilisateur enregistré.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:each="username : ${activeUsers}" class="hover:bg-gray-50 transition-colors">
|
<tr th:each="userSession : ${userSessions}" class="hover:bg-gray-50 transition-colors">
|
||||||
<td class="py-4 px-6 font-medium text-gray-900 flex items-center">
|
<td class="py-4 px-6 font-medium text-gray-900 flex items-center">
|
||||||
<div class="w-8 h-8 rounded-full bg-blue-100 text-blue-600 flex items-center justify-center font-bold mr-3">
|
<div class="w-8 h-8 rounded-full bg-blue-100 text-blue-600 flex items-center justify-center font-bold mr-3 text-xs">
|
||||||
<span th:text="${#strings.substring(username, 0, 1).toUpperCase()}">U</span>
|
<span th:text="${#strings.substring(userSession.username, 0, 1).toUpperCase()}">U</span>
|
||||||
</div>
|
</div>
|
||||||
<span th:text="${username}">username</span>
|
<span th:text="${userSession.username}">username</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="py-4 px-6">
|
<td class="py-4 px-6">
|
||||||
<span class="px-2 py-1 bg-green-100 text-green-800 text-xs font-semibold rounded-full">En ligne</span>
|
<span class="px-2.5 py-0.5 bg-gray-100 text-gray-700 text-xs font-medium rounded border border-gray-200" th:text="${userSession.roles}">ADMIN</span>
|
||||||
|
</td>
|
||||||
|
<td class="py-4 px-6">
|
||||||
|
<span th:if="${userSession.online}" class="inline-flex items-center px-2.5 py-1 bg-green-100 text-green-800 text-xs font-semibold rounded-full">
|
||||||
|
<span class="w-2 h-2 mr-1.5 bg-green-500 rounded-full animate-pulse"></span>
|
||||||
|
En ligne
|
||||||
|
</span>
|
||||||
|
<span th:unless="${userSession.online}" class="inline-flex items-center px-2.5 py-1 bg-gray-100 text-gray-600 text-xs font-medium rounded-full">
|
||||||
|
<span class="w-2 h-2 mr-1.5 bg-gray-400 rounded-full"></span>
|
||||||
|
Hors ligne
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="py-4 px-6 text-gray-600 font-mono text-xs">
|
||||||
|
<span th:text="${userSession.lastLoginAt != null ? #temporals.format(userSession.lastLoginAt, 'dd/MM/yyyy HH:mm:ss') : 'Jamais'}">01/01/2026 10:00:00</span>
|
||||||
|
</td>
|
||||||
|
<td class="py-4 px-6 text-gray-600 font-mono text-xs">
|
||||||
|
<span th:text="${userSession.lastLogoutAt != null ? #temporals.format(userSession.lastLogoutAt, 'dd/MM/yyyy HH:mm:ss') : '-'}">01/01/2026 12:00:00</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -142,7 +142,7 @@
|
|||||||
hx-target="#paiements-table-container"
|
hx-target="#paiements-table-container"
|
||||||
hx-select="#paiements-table-container"
|
hx-select="#paiements-table-container"
|
||||||
hx-include="#filter-form"
|
hx-include="#filter-form"
|
||||||
th:attr="hx-vals=|{'page': ${currentPage - 1}}|"
|
th:attr="hx-vals=|{"page": ${currentPage - 1}}|"
|
||||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||||
Précédent
|
Précédent
|
||||||
</button>
|
</button>
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
hx-target="#paiements-table-container"
|
hx-target="#paiements-table-container"
|
||||||
hx-select="#paiements-table-container"
|
hx-select="#paiements-table-container"
|
||||||
hx-include="#filter-form"
|
hx-include="#filter-form"
|
||||||
th:attr="hx-vals=|{'page': ${pageNum}}|"
|
th:attr="hx-vals=|{"page": ${pageNum}}|"
|
||||||
th:text="${pageNum + 1}"
|
th:text="${pageNum + 1}"
|
||||||
class="px-3 py-1 rounded transition-colors"
|
class="px-3 py-1 rounded transition-colors"
|
||||||
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
||||||
@@ -172,7 +172,7 @@
|
|||||||
hx-target="#paiements-table-container"
|
hx-target="#paiements-table-container"
|
||||||
hx-select="#paiements-table-container"
|
hx-select="#paiements-table-container"
|
||||||
hx-include="#filter-form"
|
hx-include="#filter-form"
|
||||||
th:attr="hx-vals=|{'page': ${currentPage + 1}}|"
|
th:attr="hx-vals=|{"page": ${currentPage + 1}}|"
|
||||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||||
Suivant
|
Suivant
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -64,6 +64,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="sportEasyToken" class="block text-sm font-medium text-gray-700 mb-1">Token ou Lien d'invitation SportEasy</label>
|
||||||
|
<input type="text" id="sportEasyToken" th:field="*{sportEasyToken}" placeholder="ex: https://www.sporteasy.net/join/ABC1234 ou juste ABC1234"
|
||||||
|
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors">
|
||||||
|
<p class="text-xs text-gray-500 mt-1">Saisissez le token du groupe SportEasy ou l'URL complète d'invitation.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pt-4 border-t border-gray-100">
|
<div class="pt-4 border-t border-gray-100">
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">Équipements liés à la catégorie</label>
|
<label class="block text-sm font-medium text-gray-700 mb-2">Équipements liés à la catégorie</label>
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
<div id="equipements-table-container" class="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||||
<table class="w-full text-left border-collapse">
|
<table class="w-full text-left border-collapse">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="bg-gray-50 text-gray-500 text-xs uppercase tracking-wider border-b border-gray-200">
|
<tr class="bg-gray-50 text-gray-500 text-xs uppercase tracking-wider border-b border-gray-200">
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-gray-200 text-sm">
|
<tbody class="divide-y divide-gray-200 text-sm">
|
||||||
<tr th:if="${#lists.isEmpty(dotations)}">
|
<tr th:if="${#lists.isEmpty(dotations)}">
|
||||||
<td colspan="6" class="py-8 text-center text-gray-500">Aucun résultat trouvé pour cette recherche.</td>
|
<td colspan="7" class="py-8 text-center text-gray-500">Aucun résultat trouvé pour cette recherche.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:each="dotation : ${dotations}" class="hover:bg-gray-50">
|
<tr th:each="dotation : ${dotations}" class="hover:bg-gray-50">
|
||||||
<td class="py-3 px-4 font-medium text-gray-900">
|
<td class="py-3 px-4 font-medium text-gray-900">
|
||||||
@@ -92,6 +92,64 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<!-- Pagination Footer -->
|
||||||
|
<div class="px-6 py-4 border-t border-gray-200 flex items-center justify-between bg-gray-50 text-sm text-gray-700">
|
||||||
|
<div th:if="${totalElements > 0}">
|
||||||
|
Affichage de <span class="font-semibold" th:text="${currentPage * pageSize + 1}">1</span> à
|
||||||
|
<span class="font-semibold" th:text="${T(java.lang.Math).min((currentPage + 1) * pageSize, totalElements)}">20</span> sur
|
||||||
|
<span class="font-semibold" th:text="${totalElements}">100</span> équipements
|
||||||
|
</div>
|
||||||
|
<div th:if="${totalElements == 0}">
|
||||||
|
Aucun équipement à afficher
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-2" th:if="${totalPages > 1}">
|
||||||
|
<!-- Page Précédente -->
|
||||||
|
<a th:if="${currentPage > 0}"
|
||||||
|
th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},page=${currentPage - 1})}"
|
||||||
|
hx-get="/admin/equipements/recherche"
|
||||||
|
hx-target="#equipements-table-container"
|
||||||
|
hx-select="#equipements-table-container"
|
||||||
|
hx-push-url="true"
|
||||||
|
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "page": ${currentPage - 1}}|"
|
||||||
|
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||||
|
Précédent
|
||||||
|
</a>
|
||||||
|
<span th:if="${currentPage == 0}" class="px-3 py-1 border border-gray-200 rounded text-gray-400 bg-gray-50 cursor-not-allowed">
|
||||||
|
Précédent
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<!-- Numéros de pages -->
|
||||||
|
<th:block th:each="pageNum : ${#numbers.sequence(0, totalPages - 1)}" th:if="${totalPages > 0}">
|
||||||
|
<a th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},page=${pageNum})}"
|
||||||
|
hx-get="/admin/equipements/recherche"
|
||||||
|
hx-target="#equipements-table-container"
|
||||||
|
hx-select="#equipements-table-container"
|
||||||
|
hx-push-url="true"
|
||||||
|
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "page": ${pageNum}}|"
|
||||||
|
th:text="${pageNum + 1}"
|
||||||
|
class="px-3 py-1 rounded transition-colors"
|
||||||
|
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
||||||
|
1
|
||||||
|
</a>
|
||||||
|
</th:block>
|
||||||
|
|
||||||
|
<!-- Page Suivante -->
|
||||||
|
<a th:if="${currentPage < totalPages - 1}"
|
||||||
|
th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},page=${currentPage + 1})}"
|
||||||
|
hx-get="/admin/equipements/recherche"
|
||||||
|
hx-target="#equipements-table-container"
|
||||||
|
hx-select="#equipements-table-container"
|
||||||
|
hx-push-url="true"
|
||||||
|
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "page": ${currentPage + 1}}|"
|
||||||
|
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||||
|
Suivant
|
||||||
|
</a>
|
||||||
|
<span th:if="${currentPage == totalPages - 1}" class="px-3 py-1 border border-gray-200 rounded text-gray-400 bg-gray-50 cursor-not-allowed">
|
||||||
|
Suivant
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
<div id="licences-table-container" class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<table class="w-full text-left border-collapse min-w-[900px]">
|
<table class="w-full text-left border-collapse min-w-[900px]">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -96,6 +96,64 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Pagination Footer -->
|
||||||
|
<div class="px-6 py-4 border-t border-gray-200 flex items-center justify-between bg-gray-50 text-sm text-gray-700">
|
||||||
|
<div th:if="${totalElements > 0}">
|
||||||
|
Affichage de <span class="font-semibold" th:text="${currentPage * pageSize + 1}">1</span> à
|
||||||
|
<span class="font-semibold" th:text="${T(java.lang.Math).min((currentPage + 1) * pageSize, totalElements)}">20</span> sur
|
||||||
|
<span class="font-semibold" th:text="${totalElements}">100</span> licences
|
||||||
|
</div>
|
||||||
|
<div th:if="${totalElements == 0}">
|
||||||
|
Aucune licence à afficher
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-2" th:if="${totalPages > 1}">
|
||||||
|
<!-- Page Précédente -->
|
||||||
|
<a th:if="${currentPage > 0}"
|
||||||
|
th:href="@{/admin/licences/recherche(nom=${nomFilter},prenom=${prenomFilter},categorieId=${categorieId},numeroLicence=${numeroLicenceFilter},email=${emailFilter},typeDemande=${typeDemandeFilter},page=${currentPage - 1})}"
|
||||||
|
hx-get="/admin/licences/recherche"
|
||||||
|
hx-target="#licences-table-container"
|
||||||
|
hx-select="#licences-table-container"
|
||||||
|
hx-push-url="true"
|
||||||
|
th:attr="hx-vals=|{"nom": "${nomFilter != null ? nomFilter : ''}", "prenom": "${prenomFilter != null ? prenomFilter : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "numeroLicence": "${numeroLicenceFilter != null ? numeroLicenceFilter : ''}", "email": "${emailFilter != null ? emailFilter : ''}", "typeDemande": "${typeDemandeFilter != null ? typeDemandeFilter : ''}", "page": ${currentPage - 1}}|"
|
||||||
|
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||||
|
Précédent
|
||||||
|
</a>
|
||||||
|
<span th:if="${currentPage == 0}" class="px-3 py-1 border border-gray-200 rounded text-gray-400 bg-gray-50 cursor-not-allowed">
|
||||||
|
Précédent
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<!-- Numéros de pages -->
|
||||||
|
<th:block th:each="pageNum : ${#numbers.sequence(0, totalPages - 1)}" th:if="${totalPages > 0}">
|
||||||
|
<a th:href="@{/admin/licences/recherche(nom=${nomFilter},prenom=${prenomFilter},categorieId=${categorieId},numeroLicence=${numeroLicenceFilter},email=${emailFilter},typeDemande=${typeDemandeFilter},page=${pageNum})}"
|
||||||
|
hx-get="/admin/licences/recherche"
|
||||||
|
hx-target="#licences-table-container"
|
||||||
|
hx-select="#licences-table-container"
|
||||||
|
hx-push-url="true"
|
||||||
|
th:attr="hx-vals=|{"nom": "${nomFilter != null ? nomFilter : ''}", "prenom": "${prenomFilter != null ? prenomFilter : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "numeroLicence": "${numeroLicenceFilter != null ? numeroLicenceFilter : ''}", "email": "${emailFilter != null ? emailFilter : ''}", "typeDemande": "${typeDemandeFilter != null ? typeDemandeFilter : ''}", "page": ${pageNum}}|"
|
||||||
|
th:text="${pageNum + 1}"
|
||||||
|
class="px-3 py-1 rounded transition-colors"
|
||||||
|
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
||||||
|
1
|
||||||
|
</a>
|
||||||
|
</th:block>
|
||||||
|
|
||||||
|
<!-- Page Suivante -->
|
||||||
|
<a th:if="${currentPage < totalPages - 1}"
|
||||||
|
th:href="@{/admin/licences/recherche(nom=${nomFilter},prenom=${prenomFilter},categorieId=${categorieId},numeroLicence=${numeroLicenceFilter},email=${emailFilter},typeDemande=${typeDemandeFilter},page=${currentPage + 1})}"
|
||||||
|
hx-get="/admin/licences/recherche"
|
||||||
|
hx-target="#licences-table-container"
|
||||||
|
hx-select="#licences-table-container"
|
||||||
|
hx-push-url="true"
|
||||||
|
th:attr="hx-vals=|{"nom": "${nomFilter != null ? nomFilter : ''}", "prenom": "${prenomFilter != null ? prenomFilter : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "numeroLicence": "${numeroLicenceFilter != null ? numeroLicenceFilter : ''}", "email": "${emailFilter != null ? emailFilter : ''}", "typeDemande": "${typeDemandeFilter != null ? typeDemandeFilter : ''}", "page": ${currentPage + 1}}|"
|
||||||
|
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||||
|
Suivant
|
||||||
|
</a>
|
||||||
|
<span th:if="${currentPage == totalPages - 1}" class="px-3 py-1 border border-gray-200 rounded text-gray-400 bg-gray-50 cursor-not-allowed">
|
||||||
|
Suivant
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
+13
-2
@@ -24,6 +24,14 @@ services:
|
|||||||
- db
|
- db
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
|
mailpit:
|
||||||
|
image: axllent/mailpit
|
||||||
|
container_name: astalange_mailpit
|
||||||
|
ports:
|
||||||
|
- "1025:1025"
|
||||||
|
- "8025:8025"
|
||||||
|
restart: always
|
||||||
|
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
@@ -35,10 +43,13 @@ services:
|
|||||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/astalange
|
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/astalange
|
||||||
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER:-myuser}
|
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER:-myuser}
|
||||||
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD:-mypassword}
|
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD:-mypassword}
|
||||||
- CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY}
|
- SPRING_MAIL_HOST=mailpit
|
||||||
- CAPTCHA_SECRET=${CAPTCHA_SECRET}
|
- SPRING_MAIL_PORT=1025
|
||||||
|
- CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-}
|
||||||
|
- CAPTCHA_SECRET=${CAPTCHA_SECRET:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
- mailpit
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<groupId>com.astalange</groupId>
|
<groupId>com.astalange</groupId>
|
||||||
<artifactId>as-talange-parent</artifactId>
|
<artifactId>as-talange-parent</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.7-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>as-talange-parent</name>
|
<name>as-talange-parent</name>
|
||||||
|
|||||||
Reference in New Issue
Block a user