-
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.
- Loading branch information
Showing
22 changed files
with
238 additions
and
178 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
7 changes: 5 additions & 2 deletions
7
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/controller/dto/BoardGetResponse.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,11 +1,14 @@ | ||
package com.ddd.sonnypolabobe.domain.board.controller.dto | ||
|
||
import com.ddd.sonnypolabobe.domain.board.sticker.dto.StickerGetResponse | ||
import com.ddd.sonnypolabobe.domain.polaroid.controller.dto.PolaroidGetResponse | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class BoardGetResponse( | ||
@Schema(description = "제목", example = "쏘니의 보드") | ||
val title: String, | ||
@Schema(description = "작성자", example = "작성자입니다.") | ||
val items: List<PolaroidGetResponse> | ||
@Schema(description = "폴라로이드") | ||
val items: List<PolaroidGetResponse>, | ||
@Schema(description = "스티커 리스트") | ||
val stickers : List<StickerGetResponse>? | ||
) |
15 changes: 0 additions & 15 deletions
15
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/entity/BoardEntity.kt
This file was deleted.
Oops, something went wrong.
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
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/vo/BoardGetOneVo.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,16 @@ | ||
package com.ddd.sonnypolabobe.domain.board.repository.vo | ||
|
||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
data class BoardGetOneVo( | ||
val id: UUID?, | ||
val title: String?, | ||
val polaroidId : Long?, | ||
val imageKey : String?, | ||
val oneLineMessage: String?, | ||
val createdAt: LocalDateTime?, | ||
val userId : Long?, | ||
val nickName: String?, | ||
val options: String? | ||
) |
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
40 changes: 40 additions & 0 deletions
40
...in/kotlin/com/ddd/sonnypolabobe/domain/board/sticker/controller/BoardStickerController.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,40 @@ | ||
package com.ddd.sonnypolabobe.domain.board.sticker.controller | ||
|
||
import com.ddd.sonnypolabobe.domain.board.sticker.dto.StickerCreateRequest | ||
import com.ddd.sonnypolabobe.domain.board.sticker.service.StickerService | ||
import com.ddd.sonnypolabobe.global.response.ApplicationResponse | ||
import com.ddd.sonnypolabobe.global.security.JwtUtil | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestHeader | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/boards/sticker") | ||
class BoardStickerController( | ||
private val jwtUtil: JwtUtil, | ||
private val stickerService: StickerService | ||
) { | ||
|
||
@Tag(name = "1.3.0") | ||
@GetMapping("/recent") | ||
fun getRecentList( @RequestHeader("Authorization") token: String?) | ||
: ApplicationResponse<List<String>> { | ||
val user = token?.let { this.jwtUtil.getAuthenticatedMemberFromToken(it) } | ||
return ApplicationResponse.ok(this.stickerService.getByUserId(user?.id?.toLong())) | ||
} | ||
|
||
@Tag(name = "1.3.0") | ||
@PostMapping | ||
fun createStickerToBoard( | ||
@RequestHeader("Authorization") token: String?, | ||
@RequestBody req : StickerCreateRequest | ||
) : ApplicationResponse<Nothing> { | ||
val user = token?.let { this.jwtUtil.getAuthenticatedMemberFromToken(it) } | ||
this.stickerService.create(req, user?.id?.toLong()) | ||
return ApplicationResponse.ok() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/sticker/dto/StickerCreateRequest.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,10 @@ | ||
package com.ddd.sonnypolabobe.domain.board.sticker.dto | ||
|
||
data class StickerCreateRequest( | ||
val boardId : String, | ||
val stickerId: String, | ||
val x : String, | ||
val y : String, | ||
val scale: String, | ||
val rotate: String | ||
) |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/sticker/dto/StickerGetResponse.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,9 @@ | ||
package com.ddd.sonnypolabobe.domain.board.sticker.dto | ||
|
||
data class StickerGetResponse( | ||
val id : String, | ||
val x : String, | ||
val y : String, | ||
val scale: String, | ||
val rotate : String | ||
) |
11 changes: 11 additions & 0 deletions
11
...in/kotlin/com/ddd/sonnypolabobe/domain/board/sticker/repository/BoardStickerRepository.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,11 @@ | ||
package com.ddd.sonnypolabobe.domain.board.sticker.repository | ||
|
||
import com.ddd.sonnypolabobe.domain.board.sticker.dto.StickerCreateRequest | ||
import com.ddd.sonnypolabobe.domain.board.sticker.dto.StickerGetResponse | ||
import java.util.* | ||
|
||
interface BoardStickerRepository { | ||
fun findByUserId(id: Long) : List<String> | ||
fun insertOne(req: StickerCreateRequest, userId: Long?) | ||
fun findByBoardId(stringToUUID: UUID): List<StickerGetResponse>? | ||
} |
65 changes: 65 additions & 0 deletions
65
...otlin/com/ddd/sonnypolabobe/domain/board/sticker/repository/BoardStickerRepositoryImpl.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,65 @@ | ||
package com.ddd.sonnypolabobe.domain.board.sticker.repository | ||
|
||
import com.ddd.sonnypolabobe.domain.board.sticker.dto.StickerCreateRequest | ||
import com.ddd.sonnypolabobe.domain.board.sticker.dto.StickerGetResponse | ||
import com.ddd.sonnypolabobe.global.util.DateConverter | ||
import com.ddd.sonnypolabobe.global.util.UuidConverter | ||
import com.ddd.sonnypolabobe.jooq.polabo.tables.BoardSticker | ||
import org.jooq.DSLContext | ||
import org.springframework.stereotype.Repository | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
@Repository | ||
class BoardStickerRepositoryImpl( | ||
private val dslContext: DSLContext | ||
) : BoardStickerRepository { | ||
override fun findByUserId(userId: Long): List<String> { | ||
val jSticker = BoardSticker.BOARD_STICKER | ||
return this.dslContext.selectDistinct(jSticker.STICKER_ID) | ||
.from(jSticker) | ||
.where(jSticker.USER_ID.eq(userId)) | ||
.orderBy(jSticker.CREATED_AT.desc()) | ||
.fetchInto(String::class.java) | ||
} | ||
|
||
override fun insertOne(req: StickerCreateRequest, userId: Long?) { | ||
val jSticker = BoardSticker.BOARD_STICKER | ||
this.dslContext.insertInto(jSticker) | ||
.columns( | ||
jSticker.STICKER_ID, | ||
jSticker.BOARD_ID, | ||
jSticker.USER_ID, | ||
jSticker.X, | ||
jSticker.Y, | ||
jSticker.SCALE, | ||
jSticker.ROTATE, | ||
jSticker.CREATED_AT | ||
).values( | ||
req.stickerId, | ||
UuidConverter.uuidToByteArray(UuidConverter.stringToUUID(req.boardId)), | ||
userId, | ||
req.x, | ||
req.y, | ||
req.scale, | ||
req.rotate, | ||
DateConverter.convertToKst(LocalDateTime.now()) | ||
).execute() | ||
} | ||
|
||
override fun findByBoardId(stringToUUID: UUID): List<StickerGetResponse>? { | ||
val jSticker = BoardSticker.BOARD_STICKER | ||
return this.dslContext.select( | ||
jSticker.ID, | ||
jSticker.X, | ||
jSticker.Y, | ||
jSticker.SCALE, | ||
jSticker.ROTATE | ||
) | ||
.from(jSticker) | ||
.where(jSticker.BOARD_ID.eq(UuidConverter.uuidToByteArray(stringToUUID))) | ||
.fetchInto(StickerGetResponse::class.java) | ||
} | ||
|
||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/sticker/service/StickerService.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,20 @@ | ||
package com.ddd.sonnypolabobe.domain.board.sticker.service | ||
|
||
import com.ddd.sonnypolabobe.domain.board.sticker.dto.StickerCreateRequest | ||
import com.ddd.sonnypolabobe.domain.board.sticker.repository.BoardStickerRepository | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
class StickerService( | ||
private val boardStickerRepository: BoardStickerRepository | ||
) { | ||
@Transactional(readOnly = true) | ||
fun getByUserId(id: Long?): List<String> | ||
= id?.let { this.boardStickerRepository.findByUserId(id) } ?: emptyList() | ||
|
||
@Transactional | ||
fun create(req: StickerCreateRequest, userId: Long?) { | ||
this.boardStickerRepository.insertOne(req, userId) | ||
} | ||
} |
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
Oops, something went wrong.