From 7b640665d947930c03135512595f9fc46e503d46 Mon Sep 17 00:00:00 2001 From: won0104 <98508955+won0104@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:05:03 +0900 Subject: [PATCH 01/22] =?UTF-8?q?feat:=20AlbumPage=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=9E=84=EC=8B=9C=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team2_be/album/page/AlbumPage.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/example/team2_be/album/page/AlbumPage.java diff --git a/src/main/java/com/example/team2_be/album/page/AlbumPage.java b/src/main/java/com/example/team2_be/album/page/AlbumPage.java new file mode 100644 index 00000000..d10b5bf6 --- /dev/null +++ b/src/main/java/com/example/team2_be/album/page/AlbumPage.java @@ -0,0 +1,23 @@ +package com.example.team2_be.album.page; + +import com.example.team2_be.BaseEntity; +import com.example.team2_be.album.Album; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "albumPage") +@Getter +@ToString +@NoArgsConstructor +public class AlbumPage extends BaseEntity { + @ManyToOne + @JoinColumn(name = "album_id") + private Album album; +} From 23f6ed2499365bfe27d8a91370855e445bc9cb97 Mon Sep 17 00:00:00 2001 From: won0104 <98508955+won0104@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:05:17 +0900 Subject: [PATCH 02/22] =?UTF-8?q?feat:=20Trashs=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/team2_be/trashs/Trashs.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/example/team2_be/trashs/Trashs.java diff --git a/src/main/java/com/example/team2_be/trashs/Trashs.java b/src/main/java/com/example/team2_be/trashs/Trashs.java new file mode 100644 index 00000000..e7d61460 --- /dev/null +++ b/src/main/java/com/example/team2_be/trashs/Trashs.java @@ -0,0 +1,40 @@ +package com.example.team2_be.trashs; + +import com.example.team2_be.BaseEntity; +import com.example.team2_be.album.page.AlbumPage; +import com.example.team2_be.user.User; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import javax.persistence.*; +import java.time.LocalDateTime; + +@Entity +@Table(name = "trashs") +@Getter +@ToString +@NoArgsConstructor +public class Trashs extends BaseEntity { + @ManyToOne + @JoinColumn(name = "user_id",nullable = false) + private User user; + + @ManyToOne + @JoinColumn (name ="albumPage_id",nullable = false) + private AlbumPage albumPage; + + + @Column (nullable = false) + private LocalDateTime deleteAt; + + @Builder + public Trashs(Long id, User user, AlbumPage albumPage) { + super(id); + this.user = user; + this.albumPage =albumPage; + // 앨범 페이지 삭제 시간 + this.deleteAt = this.getCreateAt().plusDays(7); + } +} From c4cf4dd52843cc5994da4e17640c27eb3ca05959 Mon Sep 17 00:00:00 2001 From: won0104 <98508955+won0104@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:10:36 +0900 Subject: [PATCH 03/22] =?UTF-8?q?refactor:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/team2_be/trashs/Trashs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/team2_be/trashs/Trashs.java b/src/main/java/com/example/team2_be/trashs/Trashs.java index e7d61460..51141506 100644 --- a/src/main/java/com/example/team2_be/trashs/Trashs.java +++ b/src/main/java/com/example/team2_be/trashs/Trashs.java @@ -34,7 +34,7 @@ public Trashs(Long id, User user, AlbumPage albumPage) { super(id); this.user = user; this.albumPage =albumPage; - // 앨범 페이지 삭제 시간 + // 앨범 페이지 삭제 시간 - 여기서 할지 serviced에서 할지 테스트 필요 this.deleteAt = this.getCreateAt().plusDays(7); } } From 4b68fc3a5349fee926534ac6ecdd28c9aa7852e7 Mon Sep 17 00:00:00 2001 From: won0104 <98508955+won0104@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:46:54 +0900 Subject: [PATCH 04/22] =?UTF-8?q?feat:=20Trashs=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/team2_be/trashs/TrashsController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/example/team2_be/trashs/TrashsController.java diff --git a/src/main/java/com/example/team2_be/trashs/TrashsController.java b/src/main/java/com/example/team2_be/trashs/TrashsController.java new file mode 100644 index 00000000..bfebfb93 --- /dev/null +++ b/src/main/java/com/example/team2_be/trashs/TrashsController.java @@ -0,0 +1,12 @@ +package com.example.team2_be.trashs; + +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/albums/{albumId}/trashs") +public class TrashsController { + +} From d12643aef5d769becc7bfcc13a52284ba9541f9e Mon Sep 17 00:00:00 2001 From: won0104 <98508955+won0104@users.noreply.github.com> Date: Wed, 18 Oct 2023 12:58:49 +0900 Subject: [PATCH 05/22] =?UTF-8?q?feat:=20=ED=9C=B4=EC=A7=80=ED=86=B5=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/team2_be/trashs/TrashsController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/example/team2_be/trashs/TrashsController.java b/src/main/java/com/example/team2_be/trashs/TrashsController.java index bfebfb93..c6f425f1 100644 --- a/src/main/java/com/example/team2_be/trashs/TrashsController.java +++ b/src/main/java/com/example/team2_be/trashs/TrashsController.java @@ -1,6 +1,11 @@ package com.example.team2_be.trashs; +import com.example.team2_be.core.security.CustomUserDetails; +import com.example.team2_be.core.utils.ApiUtils; import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -9,4 +14,11 @@ @RequestMapping("/albums/{albumId}/trashs") public class TrashsController { + //휴지통 조회 GET + @GetMapping("/") + public ResponseEntity findTrashs(@AuthenticationPrincipal CustomUserDetails userDetails){ + Long userId = userDetails.getUser().getId(); + + } + } From 7b2a9df6454b33499fb6577242484e00872e0b3e Mon Sep 17 00:00:00 2001 From: won0104 <98508955+won0104@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:16:11 +0900 Subject: [PATCH 06/22] =?UTF-8?q?feat:=20TrashsFindResponseDTO=20=EB=94=94?= =?UTF-8?q?=ED=8B=B0=EC=98=A4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trash/dto/TrashsFindResponseDTO.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/com/example/team2_be/trash/dto/TrashsFindResponseDTO.java diff --git a/src/main/java/com/example/team2_be/trash/dto/TrashsFindResponseDTO.java b/src/main/java/com/example/team2_be/trash/dto/TrashsFindResponseDTO.java new file mode 100644 index 00000000..8556da83 --- /dev/null +++ b/src/main/java/com/example/team2_be/trash/dto/TrashsFindResponseDTO.java @@ -0,0 +1,38 @@ +package com.example.team2_be.trash.dto; + +import com.example.team2_be.trash.Trash; +import lombok.Getter; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +@Getter +public class TrashsFindResponseDTO { + private Long albumId; + private List Trashs; + + + public TrashsFindResponseDTO (Long albumId, List trashs){ + this.albumId = albumId; + this.Trashs = trashs.stream() + .map(TrashDTO::new) + .collect((Collectors.toList())); + } + + @Getter + public static class TrashDTO{ + private Long trashId; + private Long albumPageId; + private LocalDateTime createAt; + private LocalDateTime deleteAt; + + public TrashDTO(Trash trash) { + this.trashId = trash.getId(); + this.albumPageId = trash.getAlbumPage().getId(); + this.createAt = trash.getCreateAt(); + this.deleteAt = trash.getDeleteAt(); + } + } +} + From ebffb323649d2c334ffe0a9a0830b0127ac49da8 Mon Sep 17 00:00:00 2001 From: won0104 <98508955+won0104@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:16:43 +0900 Subject: [PATCH 07/22] =?UTF-8?q?refactor:=20trashs=20->=20trash=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team2_be/{trashs/Trashs.java => trash/Trash.java} | 6 +++--- .../TrashsController.java => trash/TrashController.java} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/main/java/com/example/team2_be/{trashs/Trashs.java => trash/Trash.java} (86%) rename src/main/java/com/example/team2_be/{trashs/TrashsController.java => trash/TrashController.java} (78%) diff --git a/src/main/java/com/example/team2_be/trashs/Trashs.java b/src/main/java/com/example/team2_be/trash/Trash.java similarity index 86% rename from src/main/java/com/example/team2_be/trashs/Trashs.java rename to src/main/java/com/example/team2_be/trash/Trash.java index 51141506..7514ccad 100644 --- a/src/main/java/com/example/team2_be/trashs/Trashs.java +++ b/src/main/java/com/example/team2_be/trash/Trash.java @@ -1,4 +1,4 @@ -package com.example.team2_be.trashs; +package com.example.team2_be.trash; import com.example.team2_be.BaseEntity; import com.example.team2_be.album.page.AlbumPage; @@ -16,7 +16,7 @@ @Getter @ToString @NoArgsConstructor -public class Trashs extends BaseEntity { +public class Trash extends BaseEntity { @ManyToOne @JoinColumn(name = "user_id",nullable = false) private User user; @@ -30,7 +30,7 @@ public class Trashs extends BaseEntity { private LocalDateTime deleteAt; @Builder - public Trashs(Long id, User user, AlbumPage albumPage) { + public Trash(Long id, User user, AlbumPage albumPage) { super(id); this.user = user; this.albumPage =albumPage; diff --git a/src/main/java/com/example/team2_be/trashs/TrashsController.java b/src/main/java/com/example/team2_be/trash/TrashController.java similarity index 78% rename from src/main/java/com/example/team2_be/trashs/TrashsController.java rename to src/main/java/com/example/team2_be/trash/TrashController.java index c6f425f1..3e513afe 100644 --- a/src/main/java/com/example/team2_be/trashs/TrashsController.java +++ b/src/main/java/com/example/team2_be/trash/TrashController.java @@ -1,4 +1,4 @@ -package com.example.team2_be.trashs; +package com.example.team2_be.trash; import com.example.team2_be.core.security.CustomUserDetails; import com.example.team2_be.core.utils.ApiUtils; @@ -12,11 +12,11 @@ @RestController @RequiredArgsConstructor @RequestMapping("/albums/{albumId}/trashs") -public class TrashsController { +public class TrashController { //휴지통 조회 GET @GetMapping("/") - public ResponseEntity findTrashs(@AuthenticationPrincipal CustomUserDetails userDetails){ + public ResponseEntity findTrashs (@AuthenticationPrincipal CustomUserDetails userDetails){ Long userId = userDetails.getUser().getId(); } From a2bfebc541d92001856ad4b40034ed6fbfa7ad9a Mon Sep 17 00:00:00 2001 From: won0104 <98508955+won0104@users.noreply.github.com> Date: Fri, 20 Oct 2023 16:19:24 +0900 Subject: [PATCH 08/22] =?UTF-8?q?refactor:=20trashService=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/team2_be/trash/TrashController.java | 3 ++- src/main/java/com/example/team2_be/trash/trashService.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/example/team2_be/trash/trashService.java diff --git a/src/main/java/com/example/team2_be/trash/TrashController.java b/src/main/java/com/example/team2_be/trash/TrashController.java index 3e513afe..df166b9c 100644 --- a/src/main/java/com/example/team2_be/trash/TrashController.java +++ b/src/main/java/com/example/team2_be/trash/TrashController.java @@ -2,6 +2,7 @@ import com.example.team2_be.core.security.CustomUserDetails; import com.example.team2_be.core.utils.ApiUtils; +import com.example.team2_be.trash.dto.TrashsFindResponseDTO; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -18,7 +19,7 @@ public class TrashController { @GetMapping("/") public ResponseEntity findTrashs (@AuthenticationPrincipal CustomUserDetails userDetails){ Long userId = userDetails.getUser().getId(); - + TrashsFindResponseDTO findDTO = trashService.findTrashsByAlbumId(); } } diff --git a/src/main/java/com/example/team2_be/trash/trashService.java b/src/main/java/com/example/team2_be/trash/trashService.java new file mode 100644 index 00000000..ef4923e8 --- /dev/null +++ b/src/main/java/com/example/team2_be/trash/trashService.java @@ -0,0 +1,4 @@ +package com.example.team2_be.trash; + +public class trashService { +} From 4a1acf2a9f0b7d1867a6f1c9be30a8104fc8fd25 Mon Sep 17 00:00:00 2001 From: JB Date: Fri, 20 Oct 2023 16:54:43 +0900 Subject: [PATCH 09/22] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/team2_be/trash/TrashController.java | 8 ++++---- ...hsFindResponseDTO.java => TrashesFindResponseDTO.java} | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) rename src/main/java/com/example/team2_be/trash/dto/{TrashsFindResponseDTO.java => TrashesFindResponseDTO.java} (81%) diff --git a/src/main/java/com/example/team2_be/trash/TrashController.java b/src/main/java/com/example/team2_be/trash/TrashController.java index df166b9c..3a8a4e27 100644 --- a/src/main/java/com/example/team2_be/trash/TrashController.java +++ b/src/main/java/com/example/team2_be/trash/TrashController.java @@ -2,7 +2,7 @@ import com.example.team2_be.core.security.CustomUserDetails; import com.example.team2_be.core.utils.ApiUtils; -import com.example.team2_be.trash.dto.TrashsFindResponseDTO; +import com.example.team2_be.trash.dto.TrashesFindResponseDTO; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -12,14 +12,14 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/albums/{albumId}/trashs") +@RequestMapping("/albums/{albumId}/trashes") public class TrashController { //휴지통 조회 GET @GetMapping("/") - public ResponseEntity findTrashs (@AuthenticationPrincipal CustomUserDetails userDetails){ + public ResponseEntity findTrashes (@AuthenticationPrincipal CustomUserDetails userDetails){ Long userId = userDetails.getUser().getId(); - TrashsFindResponseDTO findDTO = trashService.findTrashsByAlbumId(); + TrashesFindResponseDTO findDTO = trashService.findTrashesByAlbumId(); } } diff --git a/src/main/java/com/example/team2_be/trash/dto/TrashsFindResponseDTO.java b/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java similarity index 81% rename from src/main/java/com/example/team2_be/trash/dto/TrashsFindResponseDTO.java rename to src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java index 8556da83..c2060f9f 100644 --- a/src/main/java/com/example/team2_be/trash/dto/TrashsFindResponseDTO.java +++ b/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java @@ -8,14 +8,14 @@ import java.util.stream.Collectors; @Getter -public class TrashsFindResponseDTO { +public class TrashesFindResponseDTO { private Long albumId; - private List Trashs; + private List Trashes; - public TrashsFindResponseDTO (Long albumId, List trashs){ + public TrashesFindResponseDTO(Long albumId, List trashes){ this.albumId = albumId; - this.Trashs = trashs.stream() + this.Trashes = trashes.stream() .map(TrashDTO::new) .collect((Collectors.toList())); } From 0588c3e181d45f0f7bdcbb0ece98148d3c19c98f Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 05:50:04 +0900 Subject: [PATCH 10/22] =?UTF-8?q?feat:=20=ED=9C=B4=EC=A7=80=ED=86=B5=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=9D=91=EB=8B=B5=20DTO=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/team2_be/trash/dto/TrashesFindResponseDTO.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java b/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java index c2060f9f..70bc8f71 100644 --- a/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java +++ b/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java @@ -23,13 +23,15 @@ public TrashesFindResponseDTO(Long albumId, List trashes){ @Getter public static class TrashDTO{ private Long trashId; - private Long albumPageId; + private String image; + private String deleter; private LocalDateTime createAt; private LocalDateTime deleteAt; public TrashDTO(Trash trash) { this.trashId = trash.getId(); - this.albumPageId = trash.getAlbumPage().getId(); + this.image = trash.getAlbumPage().getImage(); + this.deleter = trash.getUser().getNickname(); this.createAt = trash.getCreateAt(); this.deleteAt = trash.getDeleteAt(); } From af22c89310f7205e376cf15fa3a2191d85ca32ca Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 16:04:06 +0900 Subject: [PATCH 11/22] =?UTF-8?q?feat:=20=ED=9C=B4=EC=A7=80=ED=86=B5=20?= =?UTF-8?q?=EB=A0=88=ED=8F=AC=EC=A7=80=ED=86=A0=EB=A6=AC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/team2_be/trash/TrashJPARepository.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/example/team2_be/trash/TrashJPARepository.java diff --git a/src/main/java/com/example/team2_be/trash/TrashJPARepository.java b/src/main/java/com/example/team2_be/trash/TrashJPARepository.java new file mode 100644 index 00000000..6d5425a5 --- /dev/null +++ b/src/main/java/com/example/team2_be/trash/TrashJPARepository.java @@ -0,0 +1,12 @@ +package com.example.team2_be.trash; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface TrashJPARepository extends JpaRepository { + @Query("select t from Trash t where t.albumPage.album.id = :albumId") + List findAllByAlbumId(@Param("albumId") Long albumId); +} From e7ee6bb8948aa8035137bdcfc52619f317e7c117 Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 16:34:36 +0900 Subject: [PATCH 12/22] =?UTF-8?q?feat:=20#52=20=ED=9C=B4=EC=A7=80=ED=86=B5?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/team2_be/trash/trashService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/example/team2_be/trash/trashService.java b/src/main/java/com/example/team2_be/trash/trashService.java index ef4923e8..ee243def 100644 --- a/src/main/java/com/example/team2_be/trash/trashService.java +++ b/src/main/java/com/example/team2_be/trash/trashService.java @@ -1,4 +1,22 @@ package com.example.team2_be.trash; +import com.example.team2_be.trash.dto.TrashesFindResponseDTO; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) public class trashService { + + private final TrashJPARepository trashJPARepository; + + public TrashesFindResponseDTO findAll(Long albumId){ + List trashes = trashJPARepository.findAllByAlbumId(albumId); + + return new TrashesFindResponseDTO(albumId, trashes); + } } From 26771e675a6ec221f2038fabb37130b7789fd054 Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 16:34:56 +0900 Subject: [PATCH 13/22] =?UTF-8?q?feat:=20#52=20=ED=9C=B4=EC=A7=80=ED=86=B5?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/team2_be/trash/TrashController.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/team2_be/trash/TrashController.java b/src/main/java/com/example/team2_be/trash/TrashController.java index 3a8a4e27..1fb2261e 100644 --- a/src/main/java/com/example/team2_be/trash/TrashController.java +++ b/src/main/java/com/example/team2_be/trash/TrashController.java @@ -7,6 +7,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -15,11 +16,14 @@ @RequestMapping("/albums/{albumId}/trashes") public class TrashController { + private final trashService trashService; + //휴지통 조회 GET @GetMapping("/") - public ResponseEntity findTrashes (@AuthenticationPrincipal CustomUserDetails userDetails){ - Long userId = userDetails.getUser().getId(); - TrashesFindResponseDTO findDTO = trashService.findTrashesByAlbumId(); + public ResponseEntity> findTrashes (@PathVariable Long albumId){ + TrashesFindResponseDTO findDTO = trashService.findAll(albumId); + + return ResponseEntity.ok(ApiUtils.success(findDTO)); } } From 198a75d51bc67e569d85de0905de981629ec79c3 Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 17:05:03 +0900 Subject: [PATCH 14/22] =?UTF-8?q?feat:=20#52=20=EC=95=A8=EB=B2=94=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B3=B5=EA=B5=AC=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/team2_be/trash/trashService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/example/team2_be/trash/trashService.java b/src/main/java/com/example/team2_be/trash/trashService.java index ee243def..3850e074 100644 --- a/src/main/java/com/example/team2_be/trash/trashService.java +++ b/src/main/java/com/example/team2_be/trash/trashService.java @@ -1,5 +1,6 @@ package com.example.team2_be.trash; +import com.example.team2_be.core.error.exception.NotFoundException; import com.example.team2_be.trash.dto.TrashesFindResponseDTO; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -19,4 +20,11 @@ public TrashesFindResponseDTO findAll(Long albumId){ return new TrashesFindResponseDTO(albumId, trashes); } + + public void restoreTrash(Long trashId){ + Trash trash = trashJPARepository.findById(trashId) + .orElseThrow(() -> new NotFoundException("해당 페이지가 휴지통 내에 존재하지 않습니다.")); + + trashJPARepository.delete(trash); + } } From 24f4af5910962ceb0477dc55f7ad0db375de2489 Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 17:05:32 +0900 Subject: [PATCH 15/22] =?UTF-8?q?feat:=20#52=20=EC=95=A8=EB=B2=94=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B3=B5=EA=B5=AC=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/team2_be/trash/TrashController.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/team2_be/trash/TrashController.java b/src/main/java/com/example/team2_be/trash/TrashController.java index 1fb2261e..6cd2ca3d 100644 --- a/src/main/java/com/example/team2_be/trash/TrashController.java +++ b/src/main/java/com/example/team2_be/trash/TrashController.java @@ -6,10 +6,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequiredArgsConstructor @@ -26,4 +23,10 @@ public ResponseEntity> findTrashes (@ return ResponseEntity.ok(ApiUtils.success(findDTO)); } + @PostMapping("/{trashId}") + public ResponseEntity> restoreTrash(@PathVariable String albumId, @PathVariable Long trashId){ + trashService.restoreTrash(trashId); + + return ResponseEntity.ok(ApiUtils.success(null)); + } } From 4ab858a3f0558371d111ef0b008c520315d05c06 Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 17:06:13 +0900 Subject: [PATCH 16/22] =?UTF-8?q?refactor:=20=ED=9C=B4=EC=A7=80=ED=86=B5?= =?UTF-8?q?=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EC=9D=B4=EB=A6=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/team2_be/trash/TrashController.java | 4 +--- .../team2_be/trash/{trashService.java => TrashService.java} | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) rename src/main/java/com/example/team2_be/trash/{trashService.java => TrashService.java} (97%) diff --git a/src/main/java/com/example/team2_be/trash/TrashController.java b/src/main/java/com/example/team2_be/trash/TrashController.java index 6cd2ca3d..2d88d63a 100644 --- a/src/main/java/com/example/team2_be/trash/TrashController.java +++ b/src/main/java/com/example/team2_be/trash/TrashController.java @@ -1,11 +1,9 @@ package com.example.team2_be.trash; -import com.example.team2_be.core.security.CustomUserDetails; import com.example.team2_be.core.utils.ApiUtils; import com.example.team2_be.trash.dto.TrashesFindResponseDTO; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; -import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @RestController @@ -13,7 +11,7 @@ @RequestMapping("/albums/{albumId}/trashes") public class TrashController { - private final trashService trashService; + private final TrashService trashService; //휴지통 조회 GET @GetMapping("/") diff --git a/src/main/java/com/example/team2_be/trash/trashService.java b/src/main/java/com/example/team2_be/trash/TrashService.java similarity index 97% rename from src/main/java/com/example/team2_be/trash/trashService.java rename to src/main/java/com/example/team2_be/trash/TrashService.java index 3850e074..282aaeff 100644 --- a/src/main/java/com/example/team2_be/trash/trashService.java +++ b/src/main/java/com/example/team2_be/trash/TrashService.java @@ -11,7 +11,7 @@ @Service @RequiredArgsConstructor @Transactional(readOnly = true) -public class trashService { +public class TrashService { private final TrashJPARepository trashJPARepository; From 778227da11d5cf8a805840d8e4734037e4662b83 Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 17:13:53 +0900 Subject: [PATCH 17/22] =?UTF-8?q?refactor:=20=ED=9C=B4=EC=A7=80=ED=86=B5?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/team2_be/trash/TrashController.java | 2 +- src/main/java/com/example/team2_be/trash/TrashService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/team2_be/trash/TrashController.java b/src/main/java/com/example/team2_be/trash/TrashController.java index 2d88d63a..eedd30ef 100644 --- a/src/main/java/com/example/team2_be/trash/TrashController.java +++ b/src/main/java/com/example/team2_be/trash/TrashController.java @@ -16,7 +16,7 @@ public class TrashController { //휴지통 조회 GET @GetMapping("/") public ResponseEntity> findTrashes (@PathVariable Long albumId){ - TrashesFindResponseDTO findDTO = trashService.findAll(albumId); + TrashesFindResponseDTO findDTO = trashService.findTrashes(albumId); return ResponseEntity.ok(ApiUtils.success(findDTO)); } diff --git a/src/main/java/com/example/team2_be/trash/TrashService.java b/src/main/java/com/example/team2_be/trash/TrashService.java index 282aaeff..7bf1741b 100644 --- a/src/main/java/com/example/team2_be/trash/TrashService.java +++ b/src/main/java/com/example/team2_be/trash/TrashService.java @@ -15,7 +15,7 @@ public class TrashService { private final TrashJPARepository trashJPARepository; - public TrashesFindResponseDTO findAll(Long albumId){ + public TrashesFindResponseDTO findTrashes(Long albumId){ List trashes = trashJPARepository.findAllByAlbumId(albumId); return new TrashesFindResponseDTO(albumId, trashes); From 6049e6cca6c8636056622c47a8c21e306fed145d Mon Sep 17 00:00:00 2001 From: JB Date: Sat, 21 Oct 2023 17:17:57 +0900 Subject: [PATCH 18/22] =?UTF-8?q?refactor:=20#52=20=ED=9C=B4=EC=A7=80?= =?UTF-8?q?=ED=86=B5=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/team2_be/trash/dto/TrashesFindResponseDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java b/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java index 70bc8f71..2555c6ed 100644 --- a/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java +++ b/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java @@ -30,7 +30,7 @@ public static class TrashDTO{ public TrashDTO(Trash trash) { this.trashId = trash.getId(); - this.image = trash.getAlbumPage().getImage(); + // 휴지통 페이지 미리보기 이미지 추가 this.deleter = trash.getUser().getNickname(); this.createAt = trash.getCreateAt(); this.deleteAt = trash.getDeleteAt(); From c724ac6980ebc940ff9174c2ef84c3710225483c Mon Sep 17 00:00:00 2001 From: JB Date: Sun, 22 Oct 2023 19:40:08 +0900 Subject: [PATCH 19/22] =?UTF-8?q?refactor:=20#52=20=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EB=B8=94=20=EB=84=A4=EC=9E=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/team2_be/album/page/AlbumPage.java | 1 - src/main/java/com/example/team2_be/trash/Trash.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/com/example/team2_be/album/page/AlbumPage.java b/src/main/java/com/example/team2_be/album/page/AlbumPage.java index d10b5bf6..48c2c47a 100644 --- a/src/main/java/com/example/team2_be/album/page/AlbumPage.java +++ b/src/main/java/com/example/team2_be/album/page/AlbumPage.java @@ -12,7 +12,6 @@ import javax.persistence.Table; @Entity -@Table(name = "albumPage") @Getter @ToString @NoArgsConstructor diff --git a/src/main/java/com/example/team2_be/trash/Trash.java b/src/main/java/com/example/team2_be/trash/Trash.java index 7514ccad..42e67fc3 100644 --- a/src/main/java/com/example/team2_be/trash/Trash.java +++ b/src/main/java/com/example/team2_be/trash/Trash.java @@ -12,7 +12,6 @@ import java.time.LocalDateTime; @Entity -@Table(name = "trashs") @Getter @ToString @NoArgsConstructor From b857b02626cdbe148036684fa696cf331476da67 Mon Sep 17 00:00:00 2001 From: JB Date: Mon, 23 Oct 2023 17:30:45 +0900 Subject: [PATCH 20/22] =?UTF-8?q?refactor:=20#52=20=EC=97=94=ED=8A=B8=20?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/team2_be/trash/TrashController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/team2_be/trash/TrashController.java b/src/main/java/com/example/team2_be/trash/TrashController.java index eedd30ef..85a2ae37 100644 --- a/src/main/java/com/example/team2_be/trash/TrashController.java +++ b/src/main/java/com/example/team2_be/trash/TrashController.java @@ -14,7 +14,7 @@ public class TrashController { private final TrashService trashService; //휴지통 조회 GET - @GetMapping("/") + @GetMapping public ResponseEntity> findTrashes (@PathVariable Long albumId){ TrashesFindResponseDTO findDTO = trashService.findTrashes(albumId); From 69bc59da49104763419fd2c55f955e29c7941aad Mon Sep 17 00:00:00 2001 From: JB Date: Mon, 23 Oct 2023 17:34:38 +0900 Subject: [PATCH 21/22] =?UTF-8?q?refactor:=20#52=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EB=AA=85=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/team2_be/trash/dto/TrashesFindResponseDTO.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java b/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java index 2555c6ed..32d46515 100644 --- a/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java +++ b/src/main/java/com/example/team2_be/trash/dto/TrashesFindResponseDTO.java @@ -10,12 +10,12 @@ @Getter public class TrashesFindResponseDTO { private Long albumId; - private List Trashes; + private List trashes; public TrashesFindResponseDTO(Long albumId, List trashes){ this.albumId = albumId; - this.Trashes = trashes.stream() + this.trashes = trashes.stream() .map(TrashDTO::new) .collect((Collectors.toList())); } From 5b66aeae60ca9b4212b4e341d9afc1b8d4da71a7 Mon Sep 17 00:00:00 2001 From: JB Date: Mon, 23 Oct 2023 17:35:04 +0900 Subject: [PATCH 22/22] =?UTF-8?q?refactor:=20#52=20=ED=8A=B8=EB=9E=9C?= =?UTF-8?q?=EC=9E=AD=EC=85=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/team2_be/trash/TrashService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/example/team2_be/trash/TrashService.java b/src/main/java/com/example/team2_be/trash/TrashService.java index 7bf1741b..c3d1e96a 100644 --- a/src/main/java/com/example/team2_be/trash/TrashService.java +++ b/src/main/java/com/example/team2_be/trash/TrashService.java @@ -21,6 +21,7 @@ public TrashesFindResponseDTO findTrashes(Long albumId){ return new TrashesFindResponseDTO(albumId, trashes); } + @Transactional public void restoreTrash(Long trashId){ Trash trash = trashJPARepository.findById(trashId) .orElseThrow(() -> new NotFoundException("해당 페이지가 휴지통 내에 존재하지 않습니다."));