From c33b9637ea1f3e9c6928a7e1db553c4e483e246a Mon Sep 17 00:00:00 2001 From: Ji-Ha Date: Tue, 5 Jul 2022 23:08:33 +0900 Subject: [PATCH] =?UTF-8?q?[#132]=20refactor(Bookmark):=20Bookmark=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=88=98=EC=A0=95=20-=20Bookmark?= =?UTF-8?q?Dto=20=EB=AA=A8=EB=93=88=ED=99=94=20-=20code=20convention=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20=EC=83=9D=EC=84=B1=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20updateBookmark=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20deleteBookmark=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20changeFolderInfo?= =?UTF-8?q?=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20remin?= =?UTF-8?q?dOff=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20r?= =?UTF-8?q?emindOn=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20-?= =?UTF-8?q?=20moveFolder=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web2/domain/bookmark/entity/Bookmark.kt | 121 ++++++++---------- 1 file changed, 53 insertions(+), 68 deletions(-) diff --git a/src/main/kotlin/com/yapp/web2/domain/bookmark/entity/Bookmark.kt b/src/main/kotlin/com/yapp/web2/domain/bookmark/entity/Bookmark.kt index e7d7685a..1b0e9d40 100644 --- a/src/main/kotlin/com/yapp/web2/domain/bookmark/entity/Bookmark.kt +++ b/src/main/kotlin/com/yapp/web2/domain/bookmark/entity/Bookmark.kt @@ -1,12 +1,10 @@ package com.yapp.web2.domain.bookmark.entity -import io.swagger.annotations.ApiModel -import io.swagger.annotations.ApiModelProperty +import com.yapp.web2.domain.account.entity.Account +import com.yapp.web2.domain.folder.entity.Folder import org.springframework.data.mongodb.core.mapping.Document import java.time.LocalDateTime import javax.persistence.Id -import javax.validation.constraints.NotEmpty -import javax.validation.constraints.NotNull @Document(collection = "Bookmark") class Bookmark( @@ -18,15 +16,38 @@ class Bookmark( this.title = title } - constructor(userId: Long, folderId: Long?, link: String, title: String?, remindTime: String?) : this(userId, folderId, link, title) { + constructor(userId: Long, folderId: Long?, link: String, title: String?, remindTime: String?) : this( + userId, + folderId, + link, + title + ) { this.remindTime = remindTime } - constructor(userId: Long, folderId: Long?, link: String, title: String?, remindTime: String?, image: String?, description: String?) : this(userId, folderId, link, title, remindTime) { + constructor( + userId: Long, + folderId: Long?, + link: String, + title: String?, + image: String?, + description: String? + ) : this(userId, folderId, link, title) { this.description = description this.image = image } + constructor( + account: Account, + link: String, + title: String, + image: String?, + description: String, + remind: Boolean + ) : this(account.id!!, folderId = null, link, title, image, description) { + if (remind) remindOn(Remind(account)) + } + constructor( userId: Long, folderId: Long?, @@ -64,72 +85,17 @@ class Bookmark( var remindList = mutableListOf() - @ApiModel(description = "북마크 수정 DTO") - class UpdateBookmarkDto( - @ApiModelProperty(value = "북마크 이름", required = true, example = "Change Bookmark") - @field:NotEmpty(message = "제목을 입력해주세요") - var title: String, - - @ApiModelProperty(value = "북마크 설명", example = "description") - @field:NotNull(message = "description이 null입니다!") - var description: String - ) - - @ApiModel(description = "북마크 생성 DTO") - class AddBookmarkDto( - - // TODO: 2021/12/04 RequestParam 데이터 검증 - @ApiModelProperty(value = "북마크 url", required = true, example = "https://www.naver.com") - var url: String, - - @ApiModelProperty(value = "북마크 제목", example = "Bookmark Title") - var title: String?, - - @ApiModelProperty(value = "북마크 리마인드 여부", required = true, example = "true") - var remind: Boolean, - - @ApiModelProperty(value = "북마크 이미지", example = "https://yapp-bucket-test.s3.ap-northeast-2.amazonaws.com/basicImage.png") - var image: String?, - - @ApiModelProperty(value = "description", example = "설명 예제...") - var description: String? - ) - - @ApiModel(description = "북마크 이동 API(폴더별 이동)") - class MoveBookmarkDto( - val bookmarkIdList: MutableList, - @ApiModelProperty(value = "이동 후 폴더 ID", required = true, example = "2") - val nextFolderId: Long - ) - - @ApiModel(description = "휴지통 복원 API") - class RestoreBookmarkRequest( - - @ApiModelProperty(value = "복원할 북마크 ID 리스트") - val bookmarkIdList: MutableList? - ) - - @ApiModel(description = "휴지통 영구삭제 API") - class TruncateBookmarkRequest( - - @ApiModelProperty(value = "영구삭제할 북마크 ID 리스트") - val bookmarkIdList: MutableList? - ) - - class RemindList( - val remindBookmarkList: List - ) - - class BookmarkIdList( - val dotoriIdList: MutableList - ) - fun restore(): Bookmark { this.deleted = false this.deleteTime = null return this } + fun updateBookmark(title: String, description: String) { + this.title = title + this.description = description + } + fun deletedByFolder() { this.folderId = null this.folderEmoji = "" @@ -138,14 +104,33 @@ class Bookmark( this.deleteTime = LocalDateTime.now() } - fun remindOff() { - this.remindTime = null + fun deleteBookmark() { + this.deleted = true + this.deleteTime = LocalDateTime.now() + } + + fun changeFolderInfo(folder: Folder) { + this.folderId = folder.id + this.folderName = folder.name + this.folderEmoji = folder.emoji + } + + fun remindOff(userId: Long) { + remindList.remove(Remind(userId)) + } + + fun remindOn(remind: Remind) { + remindList.add(remind) } fun updateRemindCheck() { this.remindCheck = true } + fun moveFolder(nextFolderId: Long) { + this.folderId = nextFolderId + } + fun successRemind() { this.remindStatus = true }