AJOUT : champs Mes Photos partagées dans la page mes-photos

This commit is contained in:
2025-12-02 20:00:44 +01:00
parent ce5ed0cbe3
commit f0e20be396
10 changed files with 51 additions and 1 deletions

View File

@@ -97,6 +97,7 @@ public class PhotoController {
@RequestParam(name = "pagePrivees", defaultValue = "0") int pagePrivees, @RequestParam(name = "pagePrivees", defaultValue = "0") int pagePrivees,
@RequestParam(name = "pagePubliques", defaultValue = "0") int pagePubliques, @RequestParam(name = "pagePubliques", defaultValue = "0") int pagePubliques,
@RequestParam(name = "pagePartagees", defaultValue = "0") int pagePartagees, @RequestParam(name = "pagePartagees", defaultValue = "0") int pagePartagees,
@RequestParam(name = "pageMesPartagees", defaultValue = "0") int pageMesPartagees,
Model model, Model model,
Authentication auth Authentication auth
) { ) {
@@ -105,11 +106,13 @@ public class PhotoController {
model.addAttribute("photosPrivees", photoService.listPrivatePhotos(email, pagePrivees, 12)); model.addAttribute("photosPrivees", photoService.listPrivatePhotos(email, pagePrivees, 12));
model.addAttribute("photosPubliques", photoService.listPublicPhotos(email, pagePubliques, 12)); model.addAttribute("photosPubliques", photoService.listPublicPhotos(email, pagePubliques, 12));
model.addAttribute("photosPartagees", photoService.listSharedWith(email, pagePartagees, 12)); model.addAttribute("photosPartagees", photoService.listSharedWith(email, pagePartagees, 12));
model.addAttribute("mesPhotosPartagees", photoService.listSharedPhotos(email, pageMesPartagees, 12));
// Ajouter les 3 index séparés // Ajouter les 3 index séparés
model.addAttribute("pagePrivees", pagePrivees); model.addAttribute("pagePrivees", pagePrivees);
model.addAttribute("pagePubliques", pagePubliques); model.addAttribute("pagePubliques", pagePubliques);
model.addAttribute("pagePartagees", pagePartagees); model.addAttribute("pagePartagees", pagePartagees);
model.addAttribute("pageMesPartagees", pageMesPartagees);
return "mes-photos"; return "mes-photos";
} }

View File

@@ -1,6 +1,8 @@
package local.epul4a.fotosharing.repository; package local.epul4a.fotosharing.repository;
import local.epul4a.fotosharing.model.Partage; import local.epul4a.fotosharing.model.Partage;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
@@ -11,5 +13,4 @@ public interface PartageRepository extends JpaRepository<Partage, Long> {
// vérifier si un utilisateur a accès partagé // vérifier si un utilisateur a accès partagé
boolean existsByPhoto_IdAndUtilisateur_Email(Long photoId, String email); boolean existsByPhoto_IdAndUtilisateur_Email(Long photoId, String email);
List<Partage> findByUtilisateur_Email(String email); List<Partage> findByUtilisateur_Email(String email);
} }

View File

@@ -23,4 +23,6 @@ public interface PhotoRepository extends JpaRepository<Photo, Long> {
String email, String email,
Pageable pageable Pageable pageable
); );
} }

View File

@@ -20,6 +20,8 @@ public interface PhotoService {
Page<Photo> listPrivatePhotos(String email, int page, int size); Page<Photo> listPrivatePhotos(String email, int page, int size);
Page<Photo> listPublicPhotos(String email, int page, int size); Page<Photo> listPublicPhotos(String email, int page, int size);
Page<Photo> listSharedWith(String email, int page, int size); Page<Photo> listSharedWith(String email, int page, int size);
Page<Photo> listSharedPhotos(String email, int page, int size);

View File

@@ -147,4 +147,14 @@ public class PhotoServiceImpl implements PhotoService {
return new PageImpl<>(sublist, PageRequest.of(page, size), photos.size()); return new PageImpl<>(sublist, PageRequest.of(page, size), photos.size());
} }
@Override
public Page<Photo> listSharedPhotos(String email, int page, int size) {
Pageable pageable = PageRequest.of(page, size);
return photoRepository.findByProprietaire_EmailAndVisibilite(
email,
Photo.Visibilite.SHARED,
pageable
);
}
} }

View File

@@ -43,6 +43,22 @@
</div> </div>
<h2>Mes photos partagées</h2>
<div>
<a th:each="p : ${mesPhotosPartagees.content}"
th:href="@{'/photo/' + ${p.id}}">
<img th:src="@{'/photo/' + ${p.id} + '/raw'}" width="120"/>
</a>
</div>
<div>
<a th:if="${mesPhotosPartagees.hasPrevious()}"
th:href="@{/mes-photos(pageMesPartagees=${pageMesPartagees - 1})}"></a>
<span th:text="'Page ' + (${pageMesPartagees}+1)"></span>
<a th:if="${mesPhotosPartagees.hasNext()}"
th:href="@{/mes-photos(pageMesPartagees=${pageMesPartagees + 1})}"></a>
</div>
<h2>Photos partagées avec moi</h2> <h2>Photos partagées avec moi</h2>
<div> <div>
<a th:each="p : ${photosPartagees.content}" <a th:each="p : ${photosPartagees.content}"

View File

@@ -43,6 +43,22 @@
</div> </div>
<h2>Mes photos partagées</h2>
<div>
<a th:each="p : ${mesPhotosPartagees.content}"
th:href="@{'/photo/' + ${p.id}}">
<img th:src="@{'/photo/' + ${p.id} + '/raw'}" width="120"/>
</a>
</div>
<div>
<a th:if="${mesPhotosPartagees.hasPrevious()}"
th:href="@{/mes-photos(pageMesPartagees=${pageMesPartagees - 1})}"></a>
<span th:text="'Page ' + (${pageMesPartagees}+1)"></span>
<a th:if="${mesPhotosPartagees.hasNext()}"
th:href="@{/mes-photos(pageMesPartagees=${pageMesPartagees + 1})}"></a>
</div>
<h2>Photos partagées avec moi</h2> <h2>Photos partagées avec moi</h2>
<div> <div>
<a th:each="p : ${photosPartagees.content}" <a th:each="p : ${photosPartagees.content}"