Skip to content

feat:增强kotlin的BaseMapper语法糖以及dsl写法 #6880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 3.0
Choose a base branch
from

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