diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java index 3412ff72..5c68ccb6 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java @@ -91,17 +91,17 @@ public class FlexGlobalConfig { /** * 默认的逻辑删除字段,允许设置 {@code null} 忽略匹配。 */ - private String logicDeleteColumn = "del_flag"; + private String logicDeleteColumn; /** * 默认的多租户字段,允许设置 {@code null} 忽略匹配。 */ - private String tenantColumn = "tenant_id"; + private String tenantColumn; /** * 默认的乐观锁字段,允许设置 {@code null} 忽略匹配。 */ - private String versionColumn = "version"; + private String versionColumn; public boolean isPrintBanner() { return printBanner; @@ -323,7 +323,7 @@ public class FlexGlobalConfig { } public void setNormalValueOfLogicDelete(Object normalValueOfLogicDelete) { - FlexAssert.notNull(normalValueOfLogicDelete,"normalValueOfLogicDelete"); + FlexAssert.notNull(normalValueOfLogicDelete, "normalValueOfLogicDelete"); this.normalValueOfLogicDelete = normalValueOfLogicDelete; } @@ -332,7 +332,7 @@ public class FlexGlobalConfig { } public void setDeletedValueOfLogicDelete(Object deletedValueOfLogicDelete) { - FlexAssert.notNull(deletedValueOfLogicDelete,"deletedValueOfLogicDelete"); + FlexAssert.notNull(deletedValueOfLogicDelete, "deletedValueOfLogicDelete"); this.deletedValueOfLogicDelete = deletedValueOfLogicDelete; } diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java index 05a04b39..18d351be 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java @@ -150,7 +150,17 @@ public class TableInfo { } public void setTableName(String tableName) { - this.tableName = tableName; + int indexOf = tableName.indexOf("."); + if (indexOf > 0) { + if (StringUtil.isBlank(schema)) { + this.schema = tableName.substring(0, indexOf); + this.tableName = tableName.substring(indexOf + 1); + } else { + this.tableName = tableName; + } + } else { + this.tableName = tableName; + } } public Class getEntityClass() { diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java index de78dc77..f205ea42 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java @@ -134,8 +134,8 @@ public class TableInfoFactory { //初始化表名 Table table = entityClass.getAnnotation(Table.class); if (table != null) { - tableInfo.setTableName(table.value()); tableInfo.setSchema(table.schema()); + tableInfo.setTableName(table.value()); tableInfo.setCamelToUnderline(table.camelToUnderline()); if (table.onInsert().length > 0) { diff --git a/mybatis-flex-kotlin/pom.xml b/mybatis-flex-kotlin/pom.xml deleted file mode 100755 index 830fa4c0..00000000 --- a/mybatis-flex-kotlin/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - 4.0.0 - - com.mybatis-flex - parent - 1.5.7 - - - mybatis-flex-kotlin - - - 8 - 8 - 1.9.0 - true - UTF-8 - - - - - com.mybatis-flex - mybatis-flex-core - ${mybatis-flex.version} - - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - provided - - - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - -Xjvm-default=all - - - - - compile - process-sources - - compile - - - - - test-compile - test-compile - - test-compile - - - - - - - - diff --git a/mybatis-flex-kotlin/readme.md b/mybatis-flex-kotlin/readme.md new file mode 100644 index 00000000..a3d2834c --- /dev/null +++ b/mybatis-flex-kotlin/readme.md @@ -0,0 +1,3 @@ +# MyBatis-Flex-Kotlin + +模块已迁移至:https://gitee.com/mybatis-flex/mybatis-flex-kotlin diff --git a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/db/DbConfig.kt b/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/db/DbConfig.kt deleted file mode 100644 index 0b5a7fe3..00000000 --- a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/db/DbConfig.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.kotlin.db - -import java.util.NoSuchElementException -import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KProperty - -/** - * 数据库配置对象,暂时未启用 - * @author 卡莫sama(yuanjiashuai) - * @date 2023/8/7 - */ -object DbConfig { - - var url: String by IfNullVar { "" } - var username: String by IfNullVar { "" } - var password: String by IfNullVar { "" } - - -} - -class IfNullVar(private var init: (() -> T)?) : ReadWriteProperty { - private var _value: T? = null - - override fun getValue(thisRef: Any?, property: KProperty<*>): T { - if (_value == null && init != null) { - synchronized(this) { - if (_value == null) { - _value = init?.invoke() - //释放引用 - init = null - } - } - } - return this._value?:throw NoSuchElementException() - } - - override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { - _value = value - } -} diff --git a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/db/DbExtensions.kt b/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/db/DbExtensions.kt deleted file mode 100644 index a0e1e4b2..00000000 --- a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/db/DbExtensions.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.kotlin.extensions.db - -import com.mybatisflex.core.mybatis.Mappers -import com.mybatisflex.core.query.QueryColumn -import com.mybatisflex.core.query.QueryCondition -import com.mybatisflex.core.row.Db.selectListByQuery -import com.mybatisflex.core.row.Db.selectOneByQuery -import com.mybatisflex.core.row.Row -import com.mybatisflex.core.table.TableDef -import com.mybatisflex.core.table.TableInfoFactory -import com.mybatisflex.kotlin.extensions.model.filter -import com.mybatisflex.kotlin.extensions.model.toEntities -import com.mybatisflex.kotlin.scope.QueryScope -import com.mybatisflex.kotlin.scope.queryScope - - -/* - * 数据库简单操作扩展 - * @author 卡莫sama(yuanjiashuai) - */ - -inline fun mapper(): M = Mappers.ofMapperClass(M::class.java) - -inline fun queryOne( - vararg columns: QueryColumn, - schema: String? = null, - tableName: String? = null, - noinline init: QueryScope.() -> Unit -): T = queryRow(schema = schema, tableName = tableName, columns = columns, init = init).toEntity(T::class.java) - - -fun queryRow( - vararg columns: QueryColumn?, - schema: String? = null, - tableName: String? = null, - init: QueryScope.() -> Unit -): Row = - selectOneByQuery( - schema, - tableName, - queryScope(columns = columns, init = init) - ) - - -inline fun query( - vararg columns: QueryColumn?, - schema: String? = null, - tableName: String? = null, - noinline init: QueryScope.() -> Unit -): List = - queryRows(schema = schema, tableName = tableName, columns = columns, init = init) - .toEntities() - -fun queryRows( - vararg columns: QueryColumn?, - schema: String? = null, - tableName: String? = null, - init: QueryScope.() -> Unit -): List = selectListByQuery( - schema,tableName,queryScope(columns = columns, init = init) -) - -// filter----------- -inline fun filter( - tableName: String, - schema: String, - vararg columns: QueryColumn?, - queryCondition: QueryCondition = QueryCondition.createEmpty() -): List = selectListByQuery( - schema, - tableName, - queryScope(*columns).where(queryCondition) -).toEntities() - -inline fun filter( - vararg columns: QueryColumn?, - init: () -> QueryCondition -): List { - val tableInfo = TableInfoFactory.ofEntityClass(E::class.java) - return filter( - columns = columns, - schema = tableInfo.schema, - tableName = tableInfo.tableName, - queryCondition = init() - ) -} - -inline fun filter( - tableDef: T, - vararg columns: QueryColumn?, - init: T.() -> QueryCondition -): List = tableDef.filter(columns = columns, init = init) - - - diff --git a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/mapper/MapperExtensions.kt b/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/mapper/MapperExtensions.kt deleted file mode 100644 index dd201a23..00000000 --- a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/mapper/MapperExtensions.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.kotlin.extensions.mapper - -import com.mybatisflex.core.BaseMapper -import com.mybatisflex.core.query.QueryCondition -import com.mybatisflex.kotlin.scope.QueryScope -import com.mybatisflex.kotlin.scope.queryScope -/* - * 映射器操作扩展 - * @author 卡莫sama(yuanjiashuai) - */ -fun BaseMapper<*>.queryList(init: (QueryScope.() -> Unit)?): List = - this.selectListByQuery(queryScope(init = init)) as List - -fun BaseMapper.update(entity: T, init: () -> QueryCondition): Int = - this.updateByCondition(entity, init()) - -fun BaseMapper.delete(init: (QueryScope.() -> Unit)?): Int = - this.deleteByQuery(queryScope(init = init)) - - diff --git a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/model/ModelExtensions.kt b/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/model/ModelExtensions.kt deleted file mode 100644 index f41972c2..00000000 --- a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/model/ModelExtensions.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.kotlin.extensions.model - -import com.mybatisflex.core.activerecord.Model -import com.mybatisflex.core.mybatis.Mappers -import com.mybatisflex.core.query.QueryColumn -import com.mybatisflex.core.query.QueryCondition -import com.mybatisflex.core.row.Db.* -import com.mybatisflex.core.row.Row -import com.mybatisflex.core.row.RowUtil -import com.mybatisflex.core.table.TableDef -import com.mybatisflex.core.table.TableInfoFactory -import com.mybatisflex.core.util.SqlUtil -import com.mybatisflex.kotlin.extensions.db.* -import com.mybatisflex.kotlin.scope.QueryScope -import java.io.Serializable - -/* - * 实体操作扩展 - * @author 卡莫sama(yuanjiashuai) - */ - -infix fun Row.to(entryClass: Class): T { - return RowUtil.toEntity(this, entryClass) -} - -inline fun T.filter( - vararg columns: QueryColumn?, - init: T.() -> QueryCondition -): List { - val tableInfo = TableInfoFactory.ofEntityClass(E::class.java) - return filter( - columns = columns, - schema = tableInfo.schema, - tableName = tableInfo.tableName, - queryCondition = init() - ) -} - -inline fun TableDef.query( - vararg columns: QueryColumn?, - noinline init: QueryScope.() -> Unit -): List { - return query( - columns = columns, - schema = this.schema, - tableName = this.tableName, - init = init - ) -} - -inline fun TableDef.all(): List = selectAll(schema, tableName).toEntities() - -inline fun Collection.toEntities() = map { it to E::class.java }.toList() - -inline fun> List.batchInsert(): Int = Mappers.ofEntityClass(E::class.java).insertBatch(this) - -fun< E:Model> List.batchUpdateById(): Boolean = all(Model::updateById) - -inline fun> List. batchDeleteById(): Boolean { - //拿到集合中所有实体的主键 - val primaryValues = this.map { it.pkValues() }.flatMap(Array<*>::toMutableList).map { it as Serializable } - return SqlUtil.toBool(Mappers.ofEntityClass(E::class.java).deleteBatchByIds(primaryValues)) -} - diff --git a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/sql/SqlExtensions.kt b/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/sql/SqlExtensions.kt deleted file mode 100644 index 4d50f374..00000000 --- a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/extensions/sql/SqlExtensions.kt +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.kotlin.extensions.sql - -import com.mybatisflex.core.query.* -import java.util.function.Consumer - -/* - * sql操作扩展 - * @author 卡莫sama(yuanjiashuai) - * @date 2023/8/7 - */ - - -//logic------ -inline fun `if`(test: Boolean, block: () -> QueryCondition): QueryCondition = - if (test) block() else QueryCondition.createEmpty() - -inline fun QueryCondition.andIf(test: Boolean, block: () -> QueryCondition): QueryCondition = - if (test) this.and(block()) else this - -inline fun QueryCondition.orIf(test: Boolean, block: () -> QueryCondition): QueryCondition = - if (test) this.or(block()) else this - -infix fun QueryCondition.and(other: QueryCondition): QueryCondition = this.and(other) - -infix fun QueryCondition.or(other: QueryCondition): QueryCondition = this.or(other) - -//Comparable------ -infix fun QueryColumn.like(value: String): QueryCondition = this.like(value) - -infix fun QueryColumn.eq(value: Any?): QueryCondition = this.eq(value) - -infix fun QueryColumn.ne(value: Any?): QueryCondition = this.ne(value) - -infix fun QueryColumn.`=`(value: Any?): QueryCondition = this.eq(value) - -infix fun QueryColumn.`!=`(value: Any?): QueryCondition = this.ne(value) - -infix fun QueryColumn.gt(value: Any?): QueryCondition = this.gt(value) - -infix fun QueryColumn.ge(value: Any?): QueryCondition = this.ge(value) - -infix fun QueryColumn.le(value: Any?): QueryCondition = this.le(value) - -infix fun QueryColumn.lt(value: Any?): QueryCondition = this.lt(value) - -//range----- -infix fun QueryColumn.between(pair: Pair): QueryCondition = this.between(pair.first, pair.second) - -infix fun QueryColumn.notBetween(pair: Pair): QueryCondition = this.notBetween(pair.first, pair.second) - -infix fun QueryColumn.between(range: ClosedRange<*>): QueryCondition = this.between(range.start, range.endInclusive) - -infix fun QueryColumn.notBetween(range: ClosedRange<*>): QueryCondition = - this.notBetween(range.start, range.endInclusive) - -infix fun QueryColumn.notIn(value: Collection): QueryCondition = this.notIn(value) - -infix fun QueryColumn.notIn(values: Array): QueryCondition = this.notIn(values) - -infix fun QueryColumn.`in`(value: Collection): QueryCondition = this.`in`(value) - -infix fun QueryColumn.`in`(values: Array): QueryCondition = this.`in`(values) - -infix fun QueryColumn.`in`(range: IntRange): QueryCondition = this.`in`(range.toList()) - -//as----- -infix fun QueryWrapper.`as`(alias: String?) = this.`as`(alias) - -//join------ -infix fun Joiner.`as`(alias: String?): Joiner = this.`as`(alias) - -infix fun Joiner.on(on: String?): M = this.on(on) - -infix fun Joiner.on(on: QueryCondition?): M = this.on(on) - -infix fun Joiner.on(consumer: Consumer): M = this.on(consumer) - -// orderBy------ -infix fun QueryWrapper.orderBy(orderBys: Collection): QueryWrapper = - this.orderBy(*orderBys.toTypedArray()) - -infix fun QueryWrapper.orderBy(orderBy: QueryOrderBy?): QueryWrapper = this.orderBy(orderBy) - -operator fun QueryColumn.unaryPlus(): QueryOrderBy = this.asc() - -operator fun QueryColumn.unaryMinus(): QueryOrderBy = this.desc() - -// limit------ -infix fun QueryWrapper.limit(rows: Number): QueryWrapper = this.limit(rows) - -infix fun QueryWrapper.limit(pair: Pair): QueryWrapper = this.limit(pair.first, pair.second) - -infix fun QueryWrapper.limit(range: IntRange): QueryWrapper = this.limit(range.first, range.last) - diff --git a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/scope/BootstrapScope.kt b/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/scope/BootstrapScope.kt deleted file mode 100644 index 85ed4f3e..00000000 --- a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/scope/BootstrapScope.kt +++ /dev/null @@ -1,58 +0,0 @@ -package com.mybatisflex.kotlin.scope -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.mybatisflex.core.MybatisFlexBootstrap -import javax.sql.DataSource - -class BootstrapScope(private val instant: MybatisFlexBootstrap = MybatisFlexBootstrap.getInstance()) { - - fun dataSources(dataSourceScope: DataSourceScope.() -> Unit) = - dataSourceScope(DataSourceScope(instant)) - - - operator fun Class.unaryPlus(): MybatisFlexBootstrap = - instant.addMapper(this) - - operator fun DataSource.unaryPlus(): MybatisFlexBootstrap = - instant.setDataSource(this) - - infix fun String.of(dataSource: DataSource): MybatisFlexBootstrap = - instant.setDataSource(this, dataSource) - -} - -class DataSourceScope(private val bootstrap: MybatisFlexBootstrap) { - - - fun dataSource(dataSourceKey: String, dataSource: DataSource) = - bootstrap.addDataSource(dataSourceKey, dataSource) - -} - - -fun buildBootstrap( - instant: MybatisFlexBootstrap = MybatisFlexBootstrap.getInstance(), - scope: BootstrapScope.(MybatisFlexBootstrap) -> Unit -): MybatisFlexBootstrap { - scope(BootstrapScope(instant), instant) - return instant -} - - - - - diff --git a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/scope/QueryScope.kt b/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/scope/QueryScope.kt deleted file mode 100755 index 035141f3..00000000 --- a/mybatis-flex-kotlin/src/main/kotlin/com/mybatisflex/kotlin/scope/QueryScope.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.kotlin.scope - -import com.mybatisflex.core.query.QueryColumn -import com.mybatisflex.core.query.QueryCondition -import com.mybatisflex.core.query.QueryWrapper -import com.mybatisflex.core.table.TableDef -/** - * 查询作用域 - * @author 卡莫sama(yuanjiashuai) - * @date 2023/8/7 - */ -class QueryScope :QueryWrapper() { - companion object CurrentQueryScope : ThreadLocal() - - fun from(init: (QueryScope.() -> Unit)? = null): QueryWrapper = this.from(queryScope(init = init)) - - fun where(tableDef: T, build: T.() -> QueryCondition): QueryWrapper = this.where(build(tableDef)) - - fun where(build: QueryScope.() -> QueryCondition): QueryWrapper = this.where(build(this)) - - operator fun String.get(name: String): QueryColumn = QueryColumn(this, name) - - operator fun String.unaryMinus(): QueryColumn = QueryColumn(this) - -} - - -fun queryScope(vararg columns: QueryColumn?, init: (QueryScope.() -> Unit)? = null): QueryWrapper { - val builder = QueryScope() - - if (columns.isNotEmpty()) { - builder.select(*columns) - } - //用于嵌套查询拿到上层查询包装对象 - init?.also { - val prentQueryScope = QueryScope.get() - QueryScope.set(builder) - it(builder) - QueryScope.set(prentQueryScope) - } - - return builder -} - - diff --git a/mybatis-flex-processor/src/main/java/com/mybatisflex/processor/MybatisFlexProcessor.java b/mybatis-flex-processor/src/main/java/com/mybatisflex/processor/MybatisFlexProcessor.java index 9a6e39bc..a737c093 100644 --- a/mybatis-flex-processor/src/main/java/com/mybatisflex/processor/MybatisFlexProcessor.java +++ b/mybatis-flex-processor/src/main/java/com/mybatisflex/processor/MybatisFlexProcessor.java @@ -180,8 +180,8 @@ public class MybatisFlexProcessor extends AbstractProcessor { TableInfo tableInfo = new TableInfo(); tableInfo.setEntityName(entityClass); tableInfo.setEntitySimpleName(entityClassName); - tableInfo.setTableName(table.value()); tableInfo.setSchema(table.schema()); + tableInfo.setTableName(table.value()); tableInfo.setEntityComment(elementUtils.getDocComment(entityClassElement)); // 生成 TableDef 文件 diff --git a/mybatis-flex-processor/src/main/java/com/mybatisflex/processor/entity/TableInfo.java b/mybatis-flex-processor/src/main/java/com/mybatisflex/processor/entity/TableInfo.java index b3796e9f..389835b5 100644 --- a/mybatis-flex-processor/src/main/java/com/mybatisflex/processor/entity/TableInfo.java +++ b/mybatis-flex-processor/src/main/java/com/mybatisflex/processor/entity/TableInfo.java @@ -78,7 +78,17 @@ public class TableInfo { } public void setTableName(String tableName) { - this.tableName = tableName; + int indexOf = tableName.indexOf("."); + if (indexOf > 0) { + if (schema == null || schema.trim().length() == 0) { + this.schema = tableName.substring(0, indexOf); + this.tableName = tableName.substring(indexOf + 1); + } else { + this.tableName = tableName; + } + } else { + this.tableName = tableName; + } } public String getSchema() { diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexProperties.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexProperties.java index 38913e93..b158c1ca 100644 --- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexProperties.java +++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexProperties.java @@ -797,17 +797,18 @@ public class MybatisFlexProperties { /** * 默认的逻辑删除字段。 */ - private String logicDeleteColumn = "del_flag"; + private String logicDeleteColumn; /** * 默认的多租户字段。 */ - private String tenantColumn = "tenant_id"; + private String tenantColumn; /** * 默认的乐观锁字段。 */ - private String versionColumn = "version"; + private String versionColumn; + public boolean isPrintBanner() { return printBanner; diff --git a/mybatis-flex-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/mybatis-flex-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json index d2603595..cbb5a749 100644 --- a/mybatis-flex-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/mybatis-flex-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -71,6 +71,21 @@ "name": "mybatis-flex.global-config.key-config.key-type", "description": "ID 生成策略", "type": "com.mybatisflex.annotation.KeyType" + }, + { + "name": "mybatis-flex.global-config.logic-delete-column", + "description": "全局默认逻辑删除字段", + "type": "java.lang.String" + }, + { + "name": "mybatis-flex.global-config.tenant-column", + "description": "全局默认多租户字段", + "type": "java.lang.String" + }, + { + "name": "mybatis-flex.global-config.version-column", + "description": "全局默认逻辑乐观锁字段", + "type": "java.lang.String" } ] } diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/.gitignore b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/.gitignore deleted file mode 100755 index 5ff6309b..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/pom.xml b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/pom.xml deleted file mode 100755 index 70f4477e..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/pom.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - 4.0.0 - - com.mybatis-flex - mybatis-flex-test - 1.5.7 - - - mybatis-flex-spring-kotlin-test - - - 8 - 8 - true - UTF-8 - 1.9.0 - - - - - com.mybatis-flex - mybatis-flex-kotlin - ${mybatis-flex.version} - - - - com.mybatis-flex - mybatis-flex-spring - ${mybatis-flex.version} - - - - org.springframework - spring-jdbc - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - - - com.h2database - h2 - 2.1.214 - - - - org.springframework - spring-test - test - - - org.assertj - assertj-core - 3.22.0 - test - - - org.jetbrains.kotlin - kotlin-test-junit - ${kotlin.version} - test - - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - - -Xjvm-default=all - - - - no-arg - - - - - - - - org.jetbrains.kotlin - kotlin-maven-sam-with-receiver - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-maven-noarg - ${kotlin.version} - - - - - kapt - - kapt - - - - ${project.basedir}/src/main/kotlin - - - - - com.mybatis-flex - mybatis-flex-processor - ${mybatis-flex.version} - - - - - - - compile - process-sources - - compile - - - - - test-compile - - test-compile - - - - - - - diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/AppConfig.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/AppConfig.kt deleted file mode 100755 index 3e71a6c2..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/AppConfig.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.test - -import com.mybatisflex.core.mybatis.FlexConfiguration -import com.mybatisflex.spring.FlexSqlSessionFactoryBean -import org.apache.ibatis.logging.stdout.StdOutImpl -import org.apache.ibatis.session.SqlSessionFactory -import org.mybatis.spring.SqlSessionFactoryBean -import org.mybatis.spring.annotation.MapperScan -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.context.event.ContextStartedEvent -import org.springframework.context.event.EventListener -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType -import javax.sql.DataSource - -@Configuration -@MapperScan("com.mybatisflex.test.mapper") -open class AppConfig { - - - @Bean - open fun dataSource(): DataSource? { - return EmbeddedDatabaseBuilder() - .setType(EmbeddedDatabaseType.H2) - .addScript("schema.sql") - .addScript("data-kt.sql") - .build() - } - - @Bean - open fun sqlSessionFactory(dataSource: DataSource): SqlSessionFactory? { - val factoryBean: SqlSessionFactoryBean = FlexSqlSessionFactoryBean() - factoryBean.setDataSource(dataSource) - val configuration = FlexConfiguration() - configuration.logImpl = StdOutImpl::class.java - factoryBean.setConfiguration(configuration) - return factoryBean.getObject() - } - - @EventListener(classes = [ContextStartedEvent::class]) - open fun handleContextStartedEvent() { - println("handleContextStartedEvent listener invoked!") - } - - - -} - - diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/mapper/AccountMapper.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/mapper/AccountMapper.kt deleted file mode 100755 index 571f6cec..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/mapper/AccountMapper.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.mybatisflex.test.mapper - -import com.mybatisflex.core.BaseMapper -import com.mybatisflex.kotlin.extensions.mapper.queryList -import com.mybatisflex.kotlin.extensions.sql.* -import com.mybatisflex.test.model.Account - - -@JvmDefaultWithCompatibility -interface AccountMapper : BaseMapper { - - - fun findByAge(age: Int, vararg ids: Int): List = queryList { - select(Account.ALL_COLUMNS) - from(Account) - where(Account) { - (AGE `=` age) and `if`(ids.isNotEmpty()) { - ID `in` ids.asList() - } - } - } - -} - diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/model/Account.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/model/Account.kt deleted file mode 100755 index 56cddc52..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/model/Account.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.test.model - -import com.mybatisflex.annotation.Id -import com.mybatisflex.annotation.NoneListener -import com.mybatisflex.annotation.Table -import com.mybatisflex.core.activerecord.Model -import com.mybatisflex.test.model.table.AccountTableDef -import java.util.* -/** - * 测试用数据类(最好不要写成data class,否则没有无参构造需要与数据库字段数据顺序一致) - * @author 卡莫sama(yuanjiashuai) - * @date 2023/8/7 - */ -@Table(value = "tb_account", onUpdate = [NoneListener::class], onSet = [AccountOnSetListener::class]) -data class Account( - @Id var id: Int, - var userName: String?, - var age: Int?, - var birthday: Date?, -) : Model(){ - companion object : AccountTableDef() - - override fun toString(): String { - return "Account(id=$id, userName=$userName, birthday=$birthday, age=$age)" - } -} - diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/model/AccountOnSetListener.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/model/AccountOnSetListener.kt deleted file mode 100755 index 606dbac1..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/model/AccountOnSetListener.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.test.model - -import com.mybatisflex.annotation.SetListener - - -class AccountOnSetListener : SetListener { - override fun onSet(entity: Any, property: String, value: Any): Any { - println(">>>>>>> property: $property value:$value") - return value - } -} - diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/data-kt.sql b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/data-kt.sql deleted file mode 100755 index 959cc26e..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/data-kt.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO tb_account(id, user_name, age, birthday) -VALUES (1, '张三', 18, '2020-01-11'), - (2, '李四', 19, '2021-03-21'); diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/mybatis-flex.properties b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/mybatis-flex.properties deleted file mode 100755 index 929568bf..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/mybatis-flex.properties +++ /dev/null @@ -1,4 +0,0 @@ -processor.mappersGenerateEnable=false -processor.tablesNameStyle=lowerCase -processor.tablesDefSuffix=Def -processor.allInTables=true diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/schema.sql b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/schema.sql deleted file mode 100755 index 161937d0..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE IF NOT EXISTS `tb_account` -( - `id` INTEGER , - `user_name` VARCHAR(100) NOT NULL, - `age` INTEGER, - `birthday` DATETIME -); diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinSpringTest.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinSpringTest.kt deleted file mode 100755 index 1ba41622..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinSpringTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.test - -import com.mybatisflex.test.mapper.AccountMapper -import org.assertj.core.api.WithAssertions -import org.junit.runner.RunWith - -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner -import kotlin.test.Test - - -@RunWith(SpringJUnit4ClassRunner::class) -@ContextConfiguration(classes = [AppConfig::class]) -class KotlinSpringTest : WithAssertions { - @Autowired - lateinit var accountMapper: AccountMapper - - @Test - fun testSelectByQuery() { - val accounts = accountMapper.findByAge(18,2) - accounts.forEach(::println) - } - - -} diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinTest.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinTest.kt deleted file mode 100644 index 075666f5..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinTest.kt +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.mybatisflex.test - -import com.mybatisflex.core.FlexConsts -import com.mybatisflex.core.activerecord.Model -import com.mybatisflex.core.audit.AuditManager -import com.mybatisflex.core.audit.ConsoleMessageCollector -import com.mybatisflex.kotlin.extensions.db.filter -import com.mybatisflex.kotlin.extensions.db.mapper -import com.mybatisflex.kotlin.extensions.db.query -import com.mybatisflex.kotlin.extensions.model.* -import com.mybatisflex.kotlin.extensions.sql.* -import com.mybatisflex.kotlin.scope.buildBootstrap -import com.mybatisflex.test.mapper.AccountMapper -import com.mybatisflex.test.model.Account -import com.mybatisflex.test.model.table.AccountTableDef.ACCOUNT -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType -import javax.sql.DataSource -import kotlin.streams.toList -import kotlin.test.Test - - -class KotlinTest { - @Test - fun testDb() { - val dataSource: DataSource = EmbeddedDatabaseBuilder() - .setType(EmbeddedDatabaseType.H2) - .addScript("schema.sql") - .addScript("data-kt.sql") - .build() - - AuditManager.setAuditEnable(true) - AuditManager.setMessageCollector(ConsoleMessageCollector()) - - buildBootstrap { -// 此方法体 it 是 MybatisFlexBootstrap 实例 -// 配置Mapper -// 1.通过+(重写自增)的方式 - +AccountMapper::class.java -// 2.通过原始的方式 -// it.addMapper(AccountMapper::class.java) - -// 配置单dataSource -// 1.通过+(重写自增)的方式 - +dataSource -// 2.通过原始的方式 -// it.setDataSource(dataSource) - -// 配置多dataSource -// 1.通过of(中缀)的方式 - FlexConsts.NAME of dataSource -// "dataSource1" of dataSource -// "dataSource2" of dataSource -// 2.通过dsl(中缀)的方式 - dataSources { -// dataSource(FlexConsts.NAME,dataSource) -// dataSource("dataSource1",dataSource) -// dataSource("dataSource2",dataSource) - } -// 3.通过原始的方式 -// it.addDataSource(FlexConsts.NAME,dataSource) - }.start() - -// 查询表对象对应的所有实体数据 - ACCOUNT.all().forEach(::println) -// ACCOUNT.query {}.forEach(::println) - -// a and (b or c) -// filter: - filter { - ACCOUNT.ID `=` 1 and - (ACCOUNT.AGE `in` (17..19) or (ACCOUNT.BIRTHDAY between ("2020-01-10" to "2020-01-12")) ) - }.forEach(::println) - -// query: - query { - from(Account) - where(Account) { - (AGE `in` (17..19) or (BIRTHDAY between ("2020-01-10" .. "2020-01-12")) ) - } orderBy -Account.ID - }.forEach(::println) - -// 查询表对象对应的实体数据并根据条件过滤 - filter { - ACCOUNT.AGE `=` 12 or - //if的第一个参数为true时则会调用花括号类的方法返回一个条件对象与上面那个条件对象相连接 - `if`(true) { ACCOUNT.ID between (1 to 2) } -// `if`(false) { ACCOUNT.ID `in` listOf(1, 2) } - }.stream().peek(::println) -// 过滤后修改id再次保存 - .peek { it.id = it.id.plus(2) }.forEach(Model<*>::save) -// 使用表对象filter或者DB对象有两个泛型的filter方法时方法体内this为表对象无需XXX.AA调用,直接AA -// ACCOUNT.filter { -// AGE `=` 12 or -// `if`(true) { ID `in` listOf(1, 2) } -// }.stream().peek(::println).peek { it.id = it.id.plus(6) }.forEach(Entry::save) - - println("保存后————————") -// 获得mapper实例通过自定义的默认方法查,并将查到的删除 - mapper().findByAge(18, 1, 2).stream().peek { println(it) }.forEach{it.removeById()} - - println("删除后————————") - Account.all().stream().peek { println(it) }.map { - it.userName = "kamo" - it - }.forEach{it.updateById()} - println("更新后————————") - - ACCOUNT.all().stream().peek { println(it) }.map { - it.id = it.id.plus(5) - it.userName = "akino" - it - }.toList().batchInsert() - - println("批量插入后————————") - ACCOUNT.all().stream().peek { println(it) }.toList().filter { it.id.rem(2) == 0 }.batchDeleteById() - - println("批量删除后————————") - //直接使用函数查询时需指定from表 - query { from(ACCOUNT) }.stream().peek { println(it) }.toList().filter { it.id.rem(3) == 0 }.map { - it.userName = "cloud-player" - it - }.batchUpdateById() - - println("批量更新后————————") - //使用表对象查询时无需指定from表 - ACCOUNT.query {}.forEach(::println) - } - -} diff --git a/mybatis-flex-test/pom.xml b/mybatis-flex-test/pom.xml index 825bbeb5..64d8312b 100644 --- a/mybatis-flex-test/pom.xml +++ b/mybatis-flex-test/pom.xml @@ -19,7 +19,6 @@ mybatis-flex-spring-test mybatis-flex-spring-boot-test mybatis-flex-spring-cloud-test - mybatis-flex-spring-kotlin-test diff --git a/pom.xml b/pom.xml index e26626c4..3df64e0f 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,6 @@ mybatis-flex-solon-plugin mybatis-flex-test mybatis-flex-processor - mybatis-flex-kotlin