AJOUT : champs Mes Photos partagées dans la page mes-photos
This commit is contained in:
@@ -97,6 +97,7 @@ public class PhotoController {
|
||||
@RequestParam(name = "pagePrivees", defaultValue = "0") int pagePrivees,
|
||||
@RequestParam(name = "pagePubliques", defaultValue = "0") int pagePubliques,
|
||||
@RequestParam(name = "pagePartagees", defaultValue = "0") int pagePartagees,
|
||||
@RequestParam(name = "pageMesPartagees", defaultValue = "0") int pageMesPartagees,
|
||||
Model model,
|
||||
Authentication auth
|
||||
) {
|
||||
@@ -105,11 +106,13 @@ public class PhotoController {
|
||||
model.addAttribute("photosPrivees", photoService.listPrivatePhotos(email, pagePrivees, 12));
|
||||
model.addAttribute("photosPubliques", photoService.listPublicPhotos(email, pagePubliques, 12));
|
||||
model.addAttribute("photosPartagees", photoService.listSharedWith(email, pagePartagees, 12));
|
||||
model.addAttribute("mesPhotosPartagees", photoService.listSharedPhotos(email, pageMesPartagees, 12));
|
||||
|
||||
// Ajouter les 3 index séparés
|
||||
model.addAttribute("pagePrivees", pagePrivees);
|
||||
model.addAttribute("pagePubliques", pagePubliques);
|
||||
model.addAttribute("pagePartagees", pagePartagees);
|
||||
model.addAttribute("pageMesPartagees", pageMesPartagees);
|
||||
return "mes-photos";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package local.epul4a.fotosharing.repository;
|
||||
|
||||
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 java.util.List;
|
||||
@@ -11,5 +13,4 @@ public interface PartageRepository extends JpaRepository<Partage, Long> {
|
||||
// vérifier si un utilisateur a accès partagé
|
||||
boolean existsByPhoto_IdAndUtilisateur_Email(Long photoId, String email);
|
||||
List<Partage> findByUtilisateur_Email(String email);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,4 +23,6 @@ public interface PhotoRepository extends JpaRepository<Photo, Long> {
|
||||
String email,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public interface PhotoService {
|
||||
Page<Photo> listPrivatePhotos(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> listSharedPhotos(String email, int page, int size);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -147,4 +147,14 @@ public class PhotoServiceImpl implements PhotoService {
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,22 @@
|
||||
|
||||
</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>
|
||||
<div>
|
||||
<a th:each="p : ${photosPartagees.content}"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -43,6 +43,22 @@
|
||||
|
||||
</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>
|
||||
<div>
|
||||
<a th:each="p : ${photosPartagees.content}"
|
||||
|
||||
Reference in New Issue
Block a user