-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from MEOGO-DSM/44-bookmark
🏄 :: (Meogo-44) bookmark
- Loading branch information
Showing
6 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ogo/domain/bookmark/BookmarkRepository.kt → ...ain/bookmark/domain/BookmarkRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package org.meogo.domain.bookmark | ||
package org.meogo.domain.bookmark.domain | ||
|
||
import org.meogo.domain.user.domain.User | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import java.util.UUID | ||
|
||
interface BookmarkRepository : JpaRepository<Bookmark, UUID> { | ||
fun findAllBySchoolId(schoolId: Int): List<Bookmark>? | ||
fun findAllByUser(user: User): List<Bookmark>? | ||
|
||
fun existsBySchoolIdAndUser(schoolId: Int, user: User): Boolean | ||
fun findBySchoolIdAndUser(schoolId: Int, user: User): Bookmark? | ||
|
||
fun deleteBySchoolIdAndUser(schoolId: Int, user: User) | ||
fun existsBySchoolIdAndUser(schoolId: Int, user: User): Boolean | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/org/meogo/domain/bookmark/exception/BookmarkNotFoundException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.meogo.domain.bookmark.exception | ||
|
||
import org.meogo.global.error.exception.ErrorCode | ||
import org.meogo.global.error.exception.MeogoException | ||
|
||
object BookmarkNotFoundException : MeogoException( | ||
ErrorCode.BOOKMARK_NOT_FOUND | ||
) |
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/org/meogo/domain/bookmark/presentation/BookmarkController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.meogo.domain.bookmark.presentation | ||
|
||
import org.meogo.domain.bookmark.service.BookmarkService | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.DeleteMapping | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/bookmark") | ||
class BookmarkController( | ||
private val bookmarkService: BookmarkService | ||
) { | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@PostMapping | ||
fun create(@RequestParam(name = "school_id")schoolId: Int) = | ||
bookmarkService.execute(schoolId) | ||
|
||
@GetMapping("/query/my") | ||
fun myBookmarks() = | ||
bookmarkService.queryBookmarkedSchool() | ||
|
||
@GetMapping("/query") | ||
fun isBookmarked(@RequestParam(name = "school_id")schoolId: Int) = | ||
bookmarkService.queryIsBookmarked(schoolId) | ||
|
||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@DeleteMapping | ||
fun delete(@RequestParam(name = "school_id")schoolId: Int) = | ||
bookmarkService.deleteBookmark(schoolId) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters