Skip to content

Commit

Permalink
[#132] feature(bookmark)
Browse files Browse the repository at this point in the history
- bookmarkDto의 AddBookmarkListDto의 list를 mutableList로 변경
- addBookmark Controller 하나로 통일
  • Loading branch information
Ji-Ha committed Jun 26, 2022
1 parent 870b519 commit 5aba854
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class BookmarkDto {
@ApiModel(description = "북마크 생성 리스트 DTO")
data class AddBookmarkListDto(
@ApiModelProperty(value = "북마크 객체 리스트", required = true)
val addBookmarkList: ImmutableList<AddBookmarkDto>
val addBookmarkList: MutableList<AddBookmarkDto>
)

@ApiModel(description = "북마크 이동 API(폴더별 이동)")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.yapp.web2.domain.bookmark.controller

import com.yapp.web2.domain.bookmark.BookmarkDto
import com.yapp.web2.domain.bookmark.service.PersonalBookmarkService
import com.yapp.web2.util.ControllerUtil
import com.yapp.web2.util.Message
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import javax.servlet.http.HttpServletRequest

@RestController
@RequestMapping("/api/v1/bookmarkInterface")
class BookmarkInterfaceController(
private val personalBookmarkService: PersonalBookmarkService
) {


// TODO: 2022/06/26 로직 안에서 personal shared 나눠서 저장하기
@ApiOperation(value = "여러개의 북마크 생성 API")
@PostMapping
fun createBookmarkList(
request: HttpServletRequest,
@RequestParam(required = false) @ApiParam(value = "북마크가 저장될 폴더 ID", example = "12") folderId: Long?,
@ApiParam(value = "북마크 생성 리스트 정보") @RequestBody dto: BookmarkDto.AddBookmarkListDto
): ResponseEntity<String> {
println(folderId)
val token = ControllerUtil.extractAccessToken(request)
personalBookmarkService.addBookmarkList(token, folderId, dto)
return ResponseEntity.status(HttpStatus.OK).body(Message.SAVED)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.yapp.web2.domain.bookmark.BookmarkDto
import com.yapp.web2.domain.bookmark.service.PersonalBookmarkService
import com.yapp.web2.util.ControllerUtil
import com.yapp.web2.util.Message
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.http.HttpStatus
Expand All @@ -18,42 +17,6 @@ import javax.validation.Valid
class PersonalBookmarkController(
private val personalBookmarkService: PersonalBookmarkService
) {

@ApiOperation(value = "북마크 생성 API")
@PostMapping("/{folderId}")
fun createBookmark(
request: HttpServletRequest,
@PathVariable @ApiParam(value = "북마크를 지정할 폴더 ID", example = "12", required = true) folderId: Long?,
@RequestBody @ApiParam(value = "북마크 생성 정보", required = true) bookmark: BookmarkDto.AddBookmarkDto
): ResponseEntity<String> {
val token = ControllerUtil.extractAccessToken(request)
personalBookmarkService.addBookmark(token, folderId, bookmark)
return ResponseEntity.status(HttpStatus.OK).body(Message.SAVED)
}

@ApiOperation(value = "폴더에 속하지 않는 북마크 생성 API")
@PostMapping
fun createBookmarkNoFolder(
request: HttpServletRequest,
@RequestBody @ApiParam(value = "북마크 생성 정보", required = true) bookmark: BookmarkDto.AddBookmarkDto
): ResponseEntity<String> {
val token = ControllerUtil.extractAccessToken(request)
personalBookmarkService.addBookmark(token, null, bookmark)
return ResponseEntity.status(HttpStatus.OK).body(Message.SAVED)
}

@ApiOperation(value = "여러개의 북마크 생성 API")
@PostMapping("/list/{folderId}")
fun createBookmarkList(
request: HttpServletRequest,
@PathVariable @ApiParam(value = "북마크가 저장될 폴더 ID", example = "12") folderId: Long?,
@RequestBody @ApiParam(value = "북마크 생성 리스트 정보", required = true) dto: BookmarkDto.AddBookmarkListDto
): ResponseEntity<String> {
val token = ControllerUtil.extractAccessToken(request)
personalBookmarkService.addBookmarkList(token, folderId, dto)
return ResponseEntity.status(HttpStatus.OK).body(Message.SAVED)
}

@ApiOperation(value = "북마크 삭제 API")
@PostMapping("/delete")
fun deleteBookmark(@RequestBody bookmarkList: BookmarkDto.BookmarkIdList): ResponseEntity<String> {
Expand Down

0 comments on commit 5aba854

Please sign in to comment.