From adc1048a2768dd265bb6ac25f7a184bf57365c31 Mon Sep 17 00:00:00 2001 From: JeonHaeseung <414catherine@gmail.com> Date: Sun, 14 Jul 2024 19:36:29 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[remove]=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=9E=84=EB=B2=A0=EB=8D=94=EB=B8=94=20=EC=9A=94?= =?UTF-8?q?=EC=86=8C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/entity/ScheduleDate.java | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 src/main/java/Ness/Backend/domain/schedule/entity/ScheduleDate.java diff --git a/src/main/java/Ness/Backend/domain/schedule/entity/ScheduleDate.java b/src/main/java/Ness/Backend/domain/schedule/entity/ScheduleDate.java deleted file mode 100644 index 360c1d1..0000000 --- a/src/main/java/Ness/Backend/domain/schedule/entity/ScheduleDate.java +++ /dev/null @@ -1,21 +0,0 @@ -package Ness.Backend.domain.schedule.entity; - - -import jakarta.persistence.Embeddable; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Embeddable -@NoArgsConstructor -@Getter -public class ScheduleDate { - private String time; - private String date; - - @Builder - public ScheduleDate(String time, String date){ - this.time = time; - this.date = date; - } -} From 996b3f3701996da9b74caee4a4cb75220e93457f Mon Sep 17 00:00:00 2001 From: JeonHaeseung <414catherine@gmail.com> Date: Sun, 14 Jul 2024 21:09:57 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[feat]=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20?= =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=A5=B4=EA=B3=BC=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/bookmark/entity/Bookmark.java | 40 +++++++++++++++++++ .../domain/schedule/entity/Schedule.java | 6 +++ 2 files changed, 46 insertions(+) create mode 100644 src/main/java/Ness/Backend/domain/bookmark/entity/Bookmark.java diff --git a/src/main/java/Ness/Backend/domain/bookmark/entity/Bookmark.java b/src/main/java/Ness/Backend/domain/bookmark/entity/Bookmark.java new file mode 100644 index 0000000..336ec62 --- /dev/null +++ b/src/main/java/Ness/Backend/domain/bookmark/entity/Bookmark.java @@ -0,0 +1,40 @@ +package Ness.Backend.domain.bookmark.entity; + +import Ness.Backend.domain.schedule.entity.Schedule; +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.ZonedDateTime; + +@Entity +@Getter +@NoArgsConstructor +public class Bookmark { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "bookmark_id") + private Long id; + + private String contents; + + private ZonedDateTime datetime; + + private String title; + + private String url; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "schedule_id") + private Schedule schedule; + + @Builder + public Bookmark(String contents, ZonedDateTime datetime, String title, String url, Schedule schedule){ + this.contents = contents; + this.datetime = datetime; + this.title = title; + this.url = url; + this.schedule = schedule; + } +} diff --git a/src/main/java/Ness/Backend/domain/schedule/entity/Schedule.java b/src/main/java/Ness/Backend/domain/schedule/entity/Schedule.java index 8331d29..755db00 100644 --- a/src/main/java/Ness/Backend/domain/schedule/entity/Schedule.java +++ b/src/main/java/Ness/Backend/domain/schedule/entity/Schedule.java @@ -1,5 +1,6 @@ package Ness.Backend.domain.schedule.entity; +import Ness.Backend.domain.bookmark.entity.Bookmark; import Ness.Backend.domain.category.entity.Category; import Ness.Backend.domain.chat.entity.Chat; import Ness.Backend.domain.member.entity.Member; @@ -9,6 +10,8 @@ import lombok.NoArgsConstructor; import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.List; @Entity @Getter @@ -43,6 +46,9 @@ public class Schedule { @JoinColumn(name = "chat_id") private Chat chat; + @OneToMany(mappedBy = "schedule") + private List bookmarks = new ArrayList<>(); + @Builder public Schedule(Long id, String info, String location, String person, ZonedDateTime startTime, ZonedDateTime endTime, Member member, Category category, Chat chat) { From fe1f565ff208e7e11234af646798c453b2e8ac76 Mon Sep 17 00:00:00 2001 From: JeonHaeseung <414catherine@gmail.com> Date: Sun, 14 Jul 2024 21:10:33 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[feat]=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20DTO=20=EC=83=9D=EC=84=B1=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bookmark/dto/request/PostBookmarkDto.java | 20 +++++++++++++ .../bookmark/dto/response/GetBookmarkDto.java | 30 +++++++++++++++++++ .../dto/response/GetBookmarkListDto.java | 17 +++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/main/java/Ness/Backend/domain/bookmark/dto/request/PostBookmarkDto.java create mode 100644 src/main/java/Ness/Backend/domain/bookmark/dto/response/GetBookmarkDto.java create mode 100644 src/main/java/Ness/Backend/domain/bookmark/dto/response/GetBookmarkListDto.java diff --git a/src/main/java/Ness/Backend/domain/bookmark/dto/request/PostBookmarkDto.java b/src/main/java/Ness/Backend/domain/bookmark/dto/request/PostBookmarkDto.java new file mode 100644 index 0000000..a6d5498 --- /dev/null +++ b/src/main/java/Ness/Backend/domain/bookmark/dto/request/PostBookmarkDto.java @@ -0,0 +1,20 @@ +package Ness.Backend.domain.bookmark.dto.request; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.ZonedDateTime; + +@Data +@NoArgsConstructor +public class PostBookmarkDto { + private Long scheduleId; + + private String contents; + + private ZonedDateTime datetime; + + private String title; + + private String url; +} diff --git a/src/main/java/Ness/Backend/domain/bookmark/dto/response/GetBookmarkDto.java b/src/main/java/Ness/Backend/domain/bookmark/dto/response/GetBookmarkDto.java new file mode 100644 index 0000000..199d44e --- /dev/null +++ b/src/main/java/Ness/Backend/domain/bookmark/dto/response/GetBookmarkDto.java @@ -0,0 +1,30 @@ +package Ness.Backend.domain.bookmark.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.ZonedDateTime; + +@Data +public class GetBookmarkDto { + private Long id; + + private String contents; + + private ZonedDateTime datetime; + + private String title; + + private String url; + + @Builder + public GetBookmarkDto(Long id, String contents, ZonedDateTime datetime, String title, String url){ + this.id = id; + this.contents = contents; + this.datetime = datetime; + this.title = title; + this.url = url; + } +} diff --git a/src/main/java/Ness/Backend/domain/bookmark/dto/response/GetBookmarkListDto.java b/src/main/java/Ness/Backend/domain/bookmark/dto/response/GetBookmarkListDto.java new file mode 100644 index 0000000..d2a56b6 --- /dev/null +++ b/src/main/java/Ness/Backend/domain/bookmark/dto/response/GetBookmarkListDto.java @@ -0,0 +1,17 @@ +package Ness.Backend.domain.bookmark.dto.response; + +import Ness.Backend.domain.chat.dto.response.GetChatDto; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class GetBookmarkListDto { + private List bookmarkList; +} From 584a77c061adcd90da11f378be4a442c86840a20 Mon Sep 17 00:00:00 2001 From: JeonHaeseung <414catherine@gmail.com> Date: Sun, 14 Jul 2024 21:18:22 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[feat]=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1,=20=EC=A1=B0=ED=9A=8C,=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20API=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/bookmark/BookmarkController.java | 33 +++++++++++ .../domain/bookmark/BookmarkRepository.java | 12 ++++ .../domain/bookmark/BookmarkService.java | 58 +++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 src/main/java/Ness/Backend/domain/bookmark/BookmarkController.java create mode 100644 src/main/java/Ness/Backend/domain/bookmark/BookmarkRepository.java create mode 100644 src/main/java/Ness/Backend/domain/bookmark/BookmarkService.java diff --git a/src/main/java/Ness/Backend/domain/bookmark/BookmarkController.java b/src/main/java/Ness/Backend/domain/bookmark/BookmarkController.java new file mode 100644 index 0000000..42d40ae --- /dev/null +++ b/src/main/java/Ness/Backend/domain/bookmark/BookmarkController.java @@ -0,0 +1,33 @@ +package Ness.Backend.domain.bookmark; + +import Ness.Backend.domain.bookmark.dto.request.PostBookmarkDto; +import Ness.Backend.domain.bookmark.dto.response.GetBookmarkListDto; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/bookmark") +public class BookmarkController { + private final BookmarkService bookmarkService; + + @PostMapping("") + public ResponseEntity createBookmark(@RequestBody PostBookmarkDto postBookmarkDto){ + bookmarkService.createBookmark(postBookmarkDto); + return new ResponseEntity<>(HttpStatusCode.valueOf(200)); + } + + @GetMapping("") + public ResponseEntity getBookmark(@RequestParam Long scheduleId){ + GetBookmarkListDto listDto = bookmarkService.getBookmark(scheduleId); + return new ResponseEntity<>(listDto, HttpStatusCode.valueOf(200)); + } + + @DeleteMapping("") + public ResponseEntity deleteBookmark(@RequestParam Long bookmarkId){ + bookmarkService.deleteBookmark(bookmarkId); + return new ResponseEntity<>(HttpStatusCode.valueOf(200)); + } +} diff --git a/src/main/java/Ness/Backend/domain/bookmark/BookmarkRepository.java b/src/main/java/Ness/Backend/domain/bookmark/BookmarkRepository.java new file mode 100644 index 0000000..7db0dc7 --- /dev/null +++ b/src/main/java/Ness/Backend/domain/bookmark/BookmarkRepository.java @@ -0,0 +1,12 @@ +package Ness.Backend.domain.bookmark; + +import Ness.Backend.domain.bookmark.entity.Bookmark; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface BookmarkRepository extends JpaRepository { + List findBookmarksBySchedule_Id(Long scheduleId); +} diff --git a/src/main/java/Ness/Backend/domain/bookmark/BookmarkService.java b/src/main/java/Ness/Backend/domain/bookmark/BookmarkService.java new file mode 100644 index 0000000..499304c --- /dev/null +++ b/src/main/java/Ness/Backend/domain/bookmark/BookmarkService.java @@ -0,0 +1,58 @@ +package Ness.Backend.domain.bookmark; + +import Ness.Backend.domain.bookmark.dto.request.PostBookmarkDto; +import Ness.Backend.domain.bookmark.dto.response.GetBookmarkDto; +import Ness.Backend.domain.bookmark.dto.response.GetBookmarkListDto; +import Ness.Backend.domain.bookmark.entity.Bookmark; +import Ness.Backend.domain.schedule.ScheduleRepository; +import Ness.Backend.domain.schedule.entity.Schedule; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@RequiredArgsConstructor +public class BookmarkService { + private final BookmarkRepository bookmarkRepository; + private final ScheduleRepository scheduleRepository; + + @Transactional + public void createBookmark(PostBookmarkDto postBookmarkDto){ + Schedule schedule = scheduleRepository.findScheduleById(postBookmarkDto.getScheduleId()); + + Bookmark bookmark = Bookmark.builder() + .contents(postBookmarkDto.getContents()) + .title(postBookmarkDto.getTitle()) + .datetime(postBookmarkDto.getDatetime()) + .url(postBookmarkDto.getUrl()) + .schedule(schedule) + .build(); + + bookmarkRepository.save(bookmark); + } + + @Transactional(readOnly = true) + public GetBookmarkListDto getBookmark(Long scheduleId){ + List bookmarks = bookmarkRepository.findBookmarksBySchedule_Id(scheduleId); + + List bookmarkDtos = bookmarks.stream() + .map(bookmark -> GetBookmarkDto.builder() + .id(bookmark.getId()) + .contents(bookmark.getContents()) + .title(bookmark.getTitle()) + .url(bookmark.getUrl()) + .datetime(bookmark.getDatetime()) + .build()) + .toList(); + + return new GetBookmarkListDto(bookmarkDtos); + } + + @Transactional + public void deleteBookmark(Long bookmarkId) { + bookmarkRepository.findById(bookmarkId) + .ifPresent(bookmark -> bookmarkRepository.delete(bookmark)); + } +} From 51a4070946c4bda15e1e56fe89076cb8d3bb2fe9 Mon Sep 17 00:00:00 2001 From: JeonHaeseung <414catherine@gmail.com> Date: Sun, 14 Jul 2024 21:34:12 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[fix]=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=82=AC=ED=95=AD=EC=9D=B4=20VectorDB=EC=97=90=EB=8A=94=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8D=98=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Backend/domain/category/CategoryService.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/Ness/Backend/domain/category/CategoryService.java b/src/main/java/Ness/Backend/domain/category/CategoryService.java index ed3b890..688c505 100644 --- a/src/main/java/Ness/Backend/domain/category/CategoryService.java +++ b/src/main/java/Ness/Backend/domain/category/CategoryService.java @@ -76,6 +76,22 @@ public void putUserCategory(Long memberId, PutCategoryDto putCategoryDto){ //중복되지 않은 카테고리일 경우는 변경사항 저장 가능 log.info(putCategoryDto.getId() + "번 카테고리 " + changeCategory.getName() + " 수정"); changeCategory.changeCategory(putCategoryDto.getName(), putCategoryDto.getColor()); + + //카테고리 이름 또는 컬러 변경 사항을 VectorDB에도 저장 + List changeScheduleList = scheduleRepository.findSchedulesByCategory_Id(putCategoryDto.getId()); + changeScheduleList.forEach(schedule -> { + scheduleService.putAiSchedule( + schedule.getInfo(), + schedule.getLocation(), + schedule.getPerson(), + schedule.getStartTime(), + schedule.getEndTime(), + putCategoryDto.getName(), + schedule.getCategory().getId(), + putCategoryDto.getColor(), + schedule.getMember().getId(), + schedule.getId()); + }); } else { throw new DuplicateCategoryException();