Merge pull request 'develop' (#307) from develop into main
All checks were successful
CD - Deploy on main / deploy (push) Successful in 1m17s
All checks were successful
CD - Deploy on main / deploy (push) Successful in 1m17s
Reviewed-on: #307
This commit was merged in pull request #307.
This commit is contained in:
@@ -27,6 +27,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.hibernate.annotations.Formula;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -183,6 +184,14 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
private Integer nbreIndivisiaire;
|
private Integer nbreIndivisiaire;
|
||||||
private String autreAdresse;
|
private String autreAdresse;
|
||||||
private Float superficie ;
|
private Float superficie ;
|
||||||
|
@Formula("""
|
||||||
|
(
|
||||||
|
SELECT COUNT(DISTINCT (bat.id))
|
||||||
|
FROM enquete e
|
||||||
|
join batiment bat on bat.parcelle_id =e.parcelle_id
|
||||||
|
WHERE bat.parcelle_id = parcelle_id
|
||||||
|
)
|
||||||
|
""")
|
||||||
private Integer nbreBatiment;
|
private Integer nbreBatiment;
|
||||||
private Integer nbrePiscine;
|
private Integer nbrePiscine;
|
||||||
private Long montantMensuelleLocation;
|
private Long montantMensuelleLocation;
|
||||||
|
|||||||
@@ -22,7 +22,15 @@ import java.time.LocalDate;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Where(clause = " deleted = false")
|
//@Where(clause = " deleted = false")
|
||||||
|
@Table(
|
||||||
|
uniqueConstraints = {
|
||||||
|
@UniqueConstraint(
|
||||||
|
name = "uk_participer_equipe_user",
|
||||||
|
columnNames = {"equipe_id", "user_id"}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
public class Participer extends BaseEntity implements Serializable {
|
public class Participer extends BaseEntity implements Serializable {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.gmss.fiscad.implementations.rfu.metier;
|
|||||||
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
||||||
import io.gmss.fiscad.entities.rfu.metier.Participer;
|
import io.gmss.fiscad.entities.rfu.metier.Participer;
|
||||||
|
import io.gmss.fiscad.exceptions.ApplicationException;
|
||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.ParticiperService;
|
import io.gmss.fiscad.interfaces.rfu.metier.ParticiperService;
|
||||||
@@ -41,12 +42,22 @@ public class ParticiperServiceImpl implements ParticiperService {
|
|||||||
throw new BadRequestException("Impossible de créer la participation: L'équipe doit être précisée.");
|
throw new BadRequestException("Impossible de créer la participation: L'équipe doit être précisée.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (participerPaylaodWeb.getUserId() == null) {
|
if (participerPaylaodWeb.getUserId() == null) {
|
||||||
throw new BadRequestException("Impossible de créer la participation : Le participant doit être précisé.");
|
throw new BadRequestException("Impossible de créer la participation : Le participant doit être précisé.");
|
||||||
}else {
|
}else {
|
||||||
if(!userRepository.existsById(participerPaylaodWeb.getUserId()))
|
if(!userRepository.existsById(participerPaylaodWeb.getUserId()))
|
||||||
throw new BadRequestException("Impossible de créer un nouveau participer: Le participant doit être précisé.");
|
throw new BadRequestException("Impossible de créer un nouveau participer: Le participant doit être précisé.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (participerRepository.existsByEquipeIdAndUserId(
|
||||||
|
participerPaylaodWeb.getEquipeId(),
|
||||||
|
participerPaylaodWeb.getUserId())) {
|
||||||
|
throw new ApplicationException("Cet utilisateur participe déjà à cette équipe.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Participer participer= entityFromPayLoadService.getParticiperFromPayLoadWeb(participerPaylaodWeb);
|
Participer participer= entityFromPayLoadService.getParticiperFromPayLoadWeb(participerPaylaodWeb);
|
||||||
participer= participerRepository.save(participer);
|
participer= participerRepository.save(participer);
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface ParticiperRepository extends JpaRepository<Participer, Long> {
|
public interface ParticiperRepository extends JpaRepository<Participer, Long> {
|
||||||
|
boolean existsByEquipeIdAndUserId(Long equipeId, Long userId);
|
||||||
@Query("""
|
@Query("""
|
||||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParticiperPayloadWeb(
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParticiperPayloadWeb(
|
||||||
p.id,
|
p.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user