Composition Test 1
This commit is contained in:
parent
b7716b980b
commit
097e5d1f01
@ -6,6 +6,7 @@ import com.example.demo.model.test_db.Tables.MESSAGES
|
||||
import com.example.demo.model.test_db.tables.Users.USERS
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import org.jooq.Condition
|
||||
import org.jooq.DSLContext
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.context.annotation.Lazy
|
||||
@ -20,22 +21,22 @@ class UserService(@Autowired @Lazy private val dsl: DSLContext) {
|
||||
fun users(): Flux<User> {
|
||||
return Flux
|
||||
.from(dsl
|
||||
.select()
|
||||
.from(Tables.USERS))
|
||||
.map {
|
||||
User(it.get(USERS.ID), it.get(USERS.NAME))
|
||||
}
|
||||
.select()
|
||||
.from(Tables.USERS))
|
||||
.map {
|
||||
User(it.get(USERS.ID), it.get(USERS.NAME))
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun users2(): Flow<User> {
|
||||
return dsl
|
||||
.select()
|
||||
.from(USERS)
|
||||
.fetch()
|
||||
.map { userRecord ->
|
||||
User(userRecord.get(USERS.ID), userRecord.get(USERS.NAME))
|
||||
}
|
||||
.asFlow()
|
||||
.select()
|
||||
.from(USERS)
|
||||
.fetch()
|
||||
.map { userRecord ->
|
||||
User(userRecord.get(USERS.ID), userRecord.get(USERS.NAME))
|
||||
}
|
||||
.asFlow()
|
||||
}
|
||||
|
||||
suspend fun getUserMessages(userName: String): Flow<String> = dsl
|
||||
@ -45,5 +46,15 @@ class UserService(@Autowired @Lazy private val dsl: DSLContext) {
|
||||
.map { it.get(MESSAGES.MESSAGE) }
|
||||
.asFlow()
|
||||
|
||||
fun test() = dsl
|
||||
.select(Query.messages)
|
||||
.from(MESSAGES)
|
||||
.where(Query.complexClause)
|
||||
.fetch()
|
||||
.asFlow()
|
||||
|
||||
private object Query {
|
||||
val messages = listOf(MESSAGES.MESSAGE)
|
||||
val complexClause: Condition = MESSAGES.MESSAGE.eq("")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user