Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#132 공유 #162

Merged
merged 12 commits into from
Jul 9, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class AccountService(
private val folderService: FolderService,
private val accountRepository: AccountRepository,
private val jwtProvider: JwtProvider,
private val aes256Util: AES256Util,
private val s3Uploader: S3Uploader,
private val passwordEncoder: PasswordEncoder,
private val mailSender: JavaMailSender
Expand Down Expand Up @@ -194,7 +193,7 @@ class AccountService(
@Transactional
fun acceptInvitation(token: String, folderToken: String) {
val account = jwtProvider.getAccountFromToken(token)
val folderId = aes256Util.decrypt(folderToken).toLong()
val folderId = jwtProvider.getIdFromToken(folderToken)
val rootFolder = folderService.findByFolderId(folderId)

if(rootFolder.rootFolderId != null) throw FolderNotRootException()
Expand Down
21 changes: 4 additions & 17 deletions src/main/kotlin/com/yapp/web2/domain/bookmark/BookmarkDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class BookmarkDto {
)
}

fun addBookmarkDtoToBookmark(bookmarkDto: AddBookmarkDto, account: Account): Bookmark {
return Bookmark(account, bookmarkDto.link, bookmarkDto.title, bookmarkDto.image, bookmarkDto.description, bookmarkDto.remind)
}

fun addBookmarkDtoToSharedBookmark(bookmarkDto: AddBookmarkDto, account: Account, folder: Folder): BookmarkInterface {
return SharedBookmark(
account,
Expand Down Expand Up @@ -121,21 +125,4 @@ class BookmarkDto {
val title: String,
val description: String
)

data class BookmarkRequestDto(
val id: String,
val userId: Long?,
val link: String,
val title: String?,
val description: String?,
val image: String?,
val folderId: Long?,
val folderEmoji: String?,
val folderName: String?,
val clickCount: Int,
val deleteTime: LocalDateTime?,
val deleted: Boolean,
val saveTime: LocalDateTime,
val parentBookmarkId: String?
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yapp.web2.domain.bookmark.controller

import com.yapp.web2.domain.bookmark.entity.Bookmark
import com.yapp.web2.domain.bookmark.BookmarkDto
import com.yapp.web2.domain.bookmark.service.BookmarkService
import com.yapp.web2.util.ControllerUtil
import com.yapp.web2.util.Message
Expand All @@ -27,7 +27,7 @@ class BookmarkController(
fun createBookmark(
request: HttpServletRequest,
@PathVariable @ApiParam(value = "북마크를 지정할 폴더 ID", example = "12", required = true) folderId: Long,
@RequestBody @ApiParam(value = "북마크 생성 정보", required = true) bookmark: Bookmark.AddBookmarkDto
@RequestBody @ApiParam(value = "북마크 생성 정보", required = true) bookmark: BookmarkDto.AddBookmarkDto
): ResponseEntity<String> {
val token = ControllerUtil.extractAccessToken(request)
bookmarkService.addBookmark(token, folderId, bookmark)
Expand All @@ -39,16 +39,29 @@ class BookmarkController(
fun createBookmark(
request: HttpServletRequest,
@RequestParam @ApiParam(value = "북마크를 지정할 폴더 ID", example = "12", required = true) folderId: Long?,
@RequestBody @ApiParam(value = "북마크 생성 정보", required = true) bookmark: Bookmark.AddBookmarkDto
@RequestBody @ApiParam(value = "북마크 생성 정보", required = true) bookmark: BookmarkDto.AddBookmarkDto
): ResponseEntity<String> {
val token = ControllerUtil.extractAccessToken(request)
bookmarkService.addBookmark(token, folderId, bookmark)
return ResponseEntity.status(HttpStatus.OK).body(Message.SAVED)
}

@ApiOperation(value = "여러개의 북마크 생성 API")
@PostMapping("/list")
fun createBookmarkList(
request: HttpServletRequest,
@RequestParam(required = false) @ApiParam(value = "북마크가 저장될 폴더 ID", example = "12") folderId: Long?,
@ApiParam(value = "북마크 생성 리스트 정보") @RequestBody dto: BookmarkDto.AddBookmarkListDto
): ResponseEntity<String> {
println(folderId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요건 제거해도 될 것 같아요 ㅋㅋ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵넵!

val token = ControllerUtil.extractAccessToken(request)
bookmarkService.addBookmarkList(token, folderId, dto)
return ResponseEntity.status(HttpStatus.OK).body(Message.SAVED)
}

@ApiOperation(value = "북마크 삭제 API")
@PostMapping("/delete")
fun deleteBookmark(@RequestBody bookmarkList: Bookmark.BookmarkIdList): ResponseEntity<String> {
fun deleteBookmark(@RequestBody bookmarkList: BookmarkDto.BookmarkIdList): ResponseEntity<String> {
bookmarkService.deleteBookmark(bookmarkList)
return ResponseEntity.status(HttpStatus.OK).body(Message.DELETED)
}
Expand All @@ -57,15 +70,16 @@ class BookmarkController(
@PatchMapping("/{bookmarkId}")
fun updateBookmark(
@PathVariable @ApiParam(value = "북마크 ID", example = "10", required = true) bookmarkId: String,
@RequestBody @Valid @ApiParam(value = "북마크 수정 정보", required = true) dto: Bookmark.UpdateBookmarkDto
@RequestBody @Valid @ApiParam(value = "북마크 수정 정보", required = true) dto: BookmarkDto.UpdateBookmarkDto
): ResponseEntity<String> {
bookmarkService.updateBookmark(bookmarkId, dto)
return ResponseEntity.status(HttpStatus.OK).body(Message.UPDATED)
}

@ApiOperation(value = "여러 북마크 이동 API")
@PostMapping("/moveList")
fun moveBookmarkList(
@RequestBody moveBookmarkDto: Bookmark.MoveBookmarkDto
@RequestBody @ApiParam(value = "북마크 이동 정보", required = true) moveBookmarkDto: BookmarkDto.MoveBookmarkDto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

): ResponseEntity<String> {
bookmarkService.moveBookmarkList(moveBookmarkDto)
return ResponseEntity.status(HttpStatus.OK).body(Message.UPDATED)
Expand All @@ -76,20 +90,20 @@ class BookmarkController(
@PatchMapping("/move/{bookmarkId}")
fun moveBookmark(
@PathVariable @ApiParam(value = "북마크 ID", example = "10", required = true) bookmarkId: String,
@RequestBody @ApiParam(value = "북마크 이동 정보", required = true) bookmark: Bookmark.MoveBookmarkDto
@RequestBody @ApiParam(value = "북마크 이동 정보", required = true) dto: BookmarkDto.MoveBookmarkDto
): ResponseEntity<String> {
bookmarkService.moveBookmark(bookmarkId, bookmark)
bookmarkService.moveBookmarkList(dto)
return ResponseEntity.status(HttpStatus.OK).body(Message.MOVED)
}

@PostMapping("/remind/{bookmarkId}")
@GetMapping("/remindOn/{bookmarkId}")
fun toggleOnRemindBookmark(request: HttpServletRequest, @PathVariable bookmarkId: String): ResponseEntity<String> {
val token = ControllerUtil.extractAccessToken(request)
bookmarkService.toggleOnRemindBookmark(token, bookmarkId)
return ResponseEntity.status(HttpStatus.OK).body(Message.UPDATED)
}

@DeleteMapping("/remind/{bookmarkId}")
@GetMapping("/remindOff/{bookmarkId}")
fun toggleOffRemindBookmark(request: HttpServletRequest, @PathVariable bookmarkId: String): ResponseEntity<String> {
val token = ControllerUtil.extractAccessToken(request)
bookmarkService.toggleOffRemindBookmark(token, bookmarkId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ class BookmarkPageController(
) {
@GetMapping("/{folderId}")
fun getBookmarkPage(
request: HttpServletRequest,
@PathVariable folderId: Long,
pageable: Pageable,
@RequestParam remind: Boolean
): ResponseEntity<Page<BookmarkDto.BookmarkRequestDto>> {
): ResponseEntity<Page<Bookmark>> {
val accessToken = ControllerUtil.extractAccessToken(request)
return ResponseEntity.status(HttpStatus.OK)
.body(bookmarkPageService.getAllPageByFolderId(folderId, pageable, remind))
.body(bookmarkPageService.getAllPageByFolderId(accessToken, folderId, pageable, remind))
}

@GetMapping("/main")
fun getAllBookmarkPage(
request: HttpServletRequest,
pageable: Pageable,
@RequestParam remind: Boolean
): ResponseEntity<Page<BookmarkDto.BookmarkRequestDto>> {
): ResponseEntity<Page<Bookmark>> {
val token = ControllerUtil.extractAccessToken(request)
return ResponseEntity.status(HttpStatus.OK)
.body(bookmarkPageService.getAllPageByUserId(token, pageable, remind))
Expand All @@ -42,12 +44,11 @@ class BookmarkPageController(
@GetMapping("/trash")
fun getTrashBookmarkPage(
request: HttpServletRequest,
pageable: Pageable,
@RequestParam remind: Boolean
pageable: Pageable
): ResponseEntity<Page<Bookmark>> {
val token = ControllerUtil.extractAccessToken(request)
return ResponseEntity.status(HttpStatus.OK)
.body(bookmarkPageService.getTrashPageByUserId(token, pageable, remind))
.body(bookmarkPageService.getTrashPageByUserId(token, pageable))
}

@GetMapping("/search/{keyWord}")
Expand All @@ -64,7 +65,7 @@ class BookmarkPageController(
@GetMapping("/today")
fun getTodayRemindBookmarkList(
request: HttpServletRequest
): ResponseEntity<Bookmark.RemindList> {
): ResponseEntity<BookmarkDto.RemindList> {
val token = ControllerUtil.extractAccessToken(request)
val todayRemindBookmarkList = bookmarkPageService.getTodayRemindBookmark(token)
return ResponseEntity.status(HttpStatus.OK).body(todayRemindBookmarkList)
Expand All @@ -74,7 +75,7 @@ class BookmarkPageController(
fun getBookmarkPageByFolderToken(
@PathVariable folderToken: String,
pageable: Pageable
): ResponseEntity<Page<BookmarkDto.BookmarkRequestDto>> {
): ResponseEntity<Page<Bookmark>> {
return ResponseEntity.status(HttpStatus.OK)
.body(bookmarkPageService.getAllPageByEncryptFolderId(folderToken, pageable))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yapp.web2.domain.bookmark.controller

import com.yapp.web2.domain.bookmark.entity.Bookmark
import com.yapp.web2.domain.bookmark.BookmarkDto
import com.yapp.web2.domain.bookmark.service.BookmarkPageService
import com.yapp.web2.domain.bookmark.service.BookmarkService
import com.yapp.web2.util.Message
Expand All @@ -18,14 +18,14 @@ class TrashController(
) {
@ApiOperation("북마크 복원 API")
@PatchMapping("/restore")
fun restoreBookmarks(@RequestBody @ApiParam(value = "복원할 북마크 ID 리스트", required = true) request: Bookmark.RestoreBookmarkRequest): ResponseEntity<String> {
fun restoreBookmarks(@RequestBody @ApiParam(value = "복원할 북마크 ID 리스트", required = true) request: BookmarkDto.RestoreBookmarkRequest): ResponseEntity<String> {
bookmarkService.restore(request.bookmarkIdList)
return ResponseEntity.status(HttpStatus.OK).body(Message.SUCCESS)
}

@ApiOperation("북마크 영구삭제 API")
@PostMapping("/truncate")
fun permanentDelete(@RequestBody @ApiParam(value = "영구삭제할 북마크 ID 리스트", required = true) request: Bookmark.TruncateBookmarkRequest): ResponseEntity<String> {
fun permanentDelete(@RequestBody @ApiParam(value = "영구삭제할 북마크 ID 리스트", required = true) request: BookmarkDto.TruncateBookmarkRequest): ResponseEntity<String> {
bookmarkService.permanentDelete(request.bookmarkIdList)
return ResponseEntity.status(HttpStatus.OK).body(Message.SUCCESS)
}
Expand Down
Loading