@@ -3,20 +3,27 @@ package com.ddd.sonnypolabobe.domain.board.service
3
3
import com.ddd.sonnypolabobe.domain.board.controller.dto.BoardCreateRequest
4
4
import com.ddd.sonnypolabobe.domain.board.controller.dto.BoardGetResponse
5
5
import com.ddd.sonnypolabobe.domain.board.repository.BoardJooqRepository
6
+ import com.ddd.sonnypolabobe.domain.board.sticker.dto.StickerGetResponse
7
+ import com.ddd.sonnypolabobe.domain.board.sticker.repository.BoardStickerRepository
6
8
import com.ddd.sonnypolabobe.domain.polaroid.controller.dto.PolaroidGetResponse
9
+ import com.ddd.sonnypolabobe.domain.polaroid.enumerate.PolaroidOption
7
10
import com.ddd.sonnypolabobe.domain.user.dto.UserDto
8
11
import com.ddd.sonnypolabobe.global.exception.ApplicationException
9
12
import com.ddd.sonnypolabobe.global.exception.CustomErrorCode
10
13
import com.ddd.sonnypolabobe.global.security.AuthenticatedMember
11
14
import com.ddd.sonnypolabobe.global.util.S3Util
12
15
import com.ddd.sonnypolabobe.global.util.UuidConverter
16
+ import com.fasterxml.jackson.core.type.TypeReference
17
+ import com.fasterxml.jackson.databind.ObjectMapper
13
18
import org.springframework.beans.factory.annotation.Value
14
19
import org.springframework.stereotype.Service
15
20
import java.util.*
21
+ import javax.swing.text.html.HTML.Tag.U
16
22
17
23
@Service
18
24
class BoardService (
19
25
private val boardJooqRepository : BoardJooqRepository ,
26
+ private val boardStickerRepository : BoardStickerRepository ,
20
27
private val s3Util : S3Util ,
21
28
@Value(" \$ {limit.count}" )
22
29
private val limit : Int
@@ -29,22 +36,24 @@ class BoardService(
29
36
return id.run {
30
37
val queryResult =
31
38
boardJooqRepository.selectOneById(UuidConverter .stringToUUID(this @run))
32
- val groupByTitle = queryResult.groupBy { it.value1() }
39
+ val stickers = boardStickerRepository.findByBoardId(UuidConverter .stringToUUID(id))
40
+ val groupByTitle = queryResult.groupBy { it.title }
33
41
groupByTitle.map { entry ->
34
42
val title = entry.key
35
43
val polaroids = entry.value.map {
36
44
PolaroidGetResponse (
37
- id = it.value2() ? : 0L ,
38
- imageUrl = it.value3()?.let { it1 -> s3Util.getImgUrl(it1) } ? : " " ,
39
- oneLineMessage = it.value4() ? : " 폴라보와의 추억 한 줄" ,
40
- userId = it.value6() ? : 0L ,
41
- nickname = it.value7() ? : " " ,
42
- isMine = it.value6() == user?.id?.toLong(),
43
- createdAt = it.value5()
45
+ id = it.polaroidId ? : 0L ,
46
+ imageUrl = it.imageKey?.let { it1 -> s3Util.getImgUrl(it1) } ? : " " ,
47
+ oneLineMessage = it.oneLineMessage ? : " 폴라보와의 추억 한 줄" ,
48
+ userId = it.userId ? : 0L ,
49
+ nickname = it.nickName ? : " " ,
50
+ isMine = it.userId == user?.id?.toLong(),
51
+ createdAt = it.createdAt,
52
+ options = it.options?.let { ObjectMapper ().readValue(it, object : TypeReference <Map <PolaroidOption , String >>() {})}
44
53
45
54
)
46
- }.filter { it.id != 0L }
47
- BoardGetResponse (title = title ? : " " , items = polaroids)
55
+ }.filter { it.id != 0L }.distinctBy { it.id }
56
+ BoardGetResponse (title = title ? : " " , items = polaroids, stickers = stickers )
48
57
}
49
58
}
50
59
}
0 commit comments