Skip to content

Conversation

@huicunjun
Copy link

@huicunjun huicunjun commented Jul 31, 2025

增加BaseMapper 下所有AbstractWrapper 相关的方法的语法糖,如下,已有逻辑不改变。

新增类
BaseMapperExt.kt
CompareDsl.kt
DbExt.kt
FuncDsl.kt
WrapperExt.kt

`

val user: User? = selectOne {
eq(User::id, id)

        User::id eq id
        User::id ne id
        User::id le id
        User::id lt id
        User::id ge id
        User::id gt id

        User::id between ("2025-01-01 00:00:00" to "2025-01-01 23:23:59")

        User::name like "baomidou"
        User::name notLike "baomidou"
        User::name likeLeft "baomidou"
        User::name notLikeLeft "baomidou"
        User::name notLikeRight "baomidou"

        User::id.isNull
        User::id.isNotNull
        User::name isIn arrayOf("baomidou")
        User::name isIn listOf("baomidou")
        User::name isNotIn arrayOf("baomidou")
        User::name isNotIn listOf("baomidou")
    }

    val user2: User? =User::class.ktQuery {
        User::id eq id
        User::id ne id
    }.one()

    val user3: User? = ktQuery<User> {
        User::id eq id
        User::id ne id
        User::id le id
        User::id lt id
        User::id ge id
        User::id gt id

        User::id between ("2025-01-01 00:00:00" to "2025-01-01 23:23:59")

        User::name like "%baomidou%"
        User::name notLike "%baomidou%"
        User::name likeLeft "%baomidou%"
        User::name notLikeLeft "%baomidou%"
        User::name notLikeRight "%baomidou%"

        User::id.isNull
        User::id.isNotNull
        User::name isIn arrayOf("%baomidou%")
        User::name isIn listOf("%baomidou%")
        User::name isNotIn arrayOf("%baomidou%")
        User::name isNotIn listOf("%baomidou%")
    }.one()   

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant