@@ -13,13 +13,13 @@ import com.teamapi.palette.repository.ChatRepository
13
13
import com.teamapi.palette.repository.RoomRepository
14
14
import com.teamapi.palette.response.ErrorCode
15
15
import com.teamapi.palette.response.exception.CustomException
16
- import org.springframework.ai.image.ImageResponse
17
- import org.springframework.data.domain.*
18
16
import kotlinx.coroutines.flow.filter
19
17
import kotlinx.coroutines.flow.map
20
18
import kotlinx.coroutines.flow.toList
21
19
import kotlinx.coroutines.reactor.awaitSingle
22
20
import org.slf4j.LoggerFactory
21
+ import org.springframework.data.domain.PageRequest
22
+ import org.springframework.data.domain.Pageable
23
23
import org.springframework.stereotype.Service
24
24
import reactor.core.publisher.Mono
25
25
import reactor.kotlin.core.util.function.component1
@@ -41,13 +41,15 @@ class ChatService(
41
41
room.validateUser(sessionHolder)
42
42
43
43
val userId = sessionHolder.me()
44
- chatRepository.save(Chat (
45
- message = message,
46
- datetime = LocalDateTime .now(),
47
- roomId = roomId,
48
- userId = userId,
49
- isAi = false
50
- ))
44
+ chatRepository.save(
45
+ Chat (
46
+ message = message,
47
+ datetime = LocalDateTime .now(),
48
+ roomId = roomId,
49
+ userId = userId,
50
+ isAi = false
51
+ )
52
+ )
51
53
val (chat, image) = Mono .zip(createUserReturn(message), draw(message)).awaitSingle()
52
54
53
55
val stamp = LocalDateTime .now()
@@ -114,7 +116,7 @@ class ChatService(
114
116
)
115
117
)
116
118
117
- // fun createPrompt(text: String) = chatCompletion(
119
+ // fun createPrompt(text: String) = chatCompletion(
118
120
// ChatCompletionsOptions(
119
121
// listOf(
120
122
// ChatRequestSystemMessage(
@@ -132,17 +134,13 @@ class ChatService(
132
134
// )
133
135
// )
134
136
// )
135
- fun getMyImage (pageNumber : Int , pageSize : Int ): Mono < PageImpl < String > > {
137
+ suspend fun getMyImage (pageNumber : Int , pageSize : Int ): List < String > {
136
138
val page = PageRequest .of(pageNumber, pageSize)
137
- return sessionHolder
138
- .me()
139
- .flatMap { userId ->
140
- chatRepository.findByIsAiAndUserId(true , userId, page)
141
- .map { it.resource }
142
- .collectList()
143
- .zipWith(chatRepository.count())
144
- .map { p -> PageImpl (p.t1, page, p.t2) }
145
- }
139
+ val userId = sessionHolder.me()
140
+
141
+ return chatRepository.findChatByIsAiIsAndUserIdIsAndResourceIs(true , userId, " IMAGE" , page)
142
+ .map { it.message }
143
+ .toList()
146
144
}
147
145
148
146
private fun chatCompletion (options : ChatCompletionsOptions ) = azure.getChatCompletions(
0 commit comments