1
This commit is contained in:
parent
186f55e7bb
commit
8da12654e2
@ -83,11 +83,11 @@ dependencies {
|
||||
implementation("dev.langchain4j:langchain4j-open-ai:1.0.0-beta1")
|
||||
implementation("dev.langchain4j:langchain4j:1.0.0-beta1")
|
||||
|
||||
|
||||
|
||||
implementation("com.google.inject:guice:5.1.0")
|
||||
implementation("org.reflections:reflections:0.10.2")
|
||||
implementation("cn.hutool:hutool-all:5.8.24")
|
||||
implementation("cn.hutool:hutool-core:5.8.24")
|
||||
implementation("cn.hutool:hutool-json:5.8.24")
|
||||
implementation("cn.hutool:hutool-crypto:5.8.24")
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2")
|
||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.15.2")
|
||||
// implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")
|
||||
@ -99,10 +99,6 @@ dependencies {
|
||||
implementation("ch.qos.logback:logback-classic:1.4.14")
|
||||
implementation("org.codehaus.janino:janino:3.1.8")
|
||||
|
||||
// jpa
|
||||
// implementation("jakarta.persistence:jakarta.persistence-api:3.2.0")
|
||||
// implementation("jakarta.validation:jakarta.validation-api:3.1.0")
|
||||
|
||||
// db
|
||||
implementation("org.postgresql:postgresql:42.7.5")
|
||||
implementation("com.ongres.scram:client:2.1")
|
||||
|
||||
@ -3,7 +3,7 @@ package app.data.domain.account
|
||||
import app.data.domain.account.modle.AccountRoleAccessDTO
|
||||
import app.data.domain.account.modle.AccountRoleDTO
|
||||
import com.google.inject.ImplementedBy
|
||||
import org.aikrai.vertx.db.Repository
|
||||
import org.aikrai.vertx.db.wrapper.Repository
|
||||
|
||||
@ImplementedBy(AccountRepositoryImpl::class)
|
||||
interface AccountRepository : Repository<Long, Account> {
|
||||
|
||||
@ -4,7 +4,7 @@ import app.data.domain.account.modle.AccountRoleAccessDTO
|
||||
import app.data.domain.account.modle.AccountRoleDTO
|
||||
import com.google.inject.Inject
|
||||
import io.vertx.sqlclient.SqlClient
|
||||
import org.aikrai.vertx.db.RepositoryImpl
|
||||
import org.aikrai.vertx.db.wrapper.RepositoryImpl
|
||||
|
||||
class AccountRepositoryImpl @Inject constructor(
|
||||
sqlClient: SqlClient
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package app.data.domain.menu
|
||||
|
||||
import com.google.inject.ImplementedBy
|
||||
import org.aikrai.vertx.db.Repository
|
||||
import org.aikrai.vertx.db.wrapper.Repository
|
||||
|
||||
@ImplementedBy(MenuRepositoryImpl::class)
|
||||
interface MenuRepository : Repository<Long, Menu> {
|
||||
|
||||
@ -2,7 +2,7 @@ package app.data.domain.menu
|
||||
|
||||
import com.google.inject.Inject
|
||||
import io.vertx.sqlclient.SqlClient
|
||||
import org.aikrai.vertx.db.RepositoryImpl
|
||||
import org.aikrai.vertx.db.wrapper.RepositoryImpl
|
||||
|
||||
class MenuRepositoryImpl @Inject constructor(
|
||||
sqlClient: SqlClient
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package app.data.domain.role
|
||||
|
||||
import com.google.inject.ImplementedBy
|
||||
import org.aikrai.vertx.db.Repository
|
||||
import org.aikrai.vertx.db.wrapper.Repository
|
||||
|
||||
@ImplementedBy(RoleRepositoryImpl::class)
|
||||
interface RoleRepository : Repository<Long, Role>
|
||||
|
||||
@ -2,7 +2,7 @@ package app.data.domain.role
|
||||
|
||||
import com.google.inject.Inject
|
||||
import io.vertx.sqlclient.SqlClient
|
||||
import org.aikrai.vertx.db.RepositoryImpl
|
||||
import org.aikrai.vertx.db.wrapper.RepositoryImpl
|
||||
|
||||
class RoleRepositoryImpl @Inject constructor(
|
||||
sqlClient: SqlClient
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
package app.example
|
||||
|
||||
import org.aikrai.vertx.db.annotation.TableField
|
||||
import org.aikrai.vertx.db.annotation.TableId
|
||||
import org.aikrai.vertx.db.annotation.TableName
|
||||
|
||||
/**
|
||||
* 订单实体类
|
||||
*/
|
||||
@TableName("tb_order")
|
||||
class Order {
|
||||
@TableId
|
||||
var id: Long = 0
|
||||
|
||||
@TableField("order_no", type = "VARCHAR(32)")
|
||||
var orderNo: String = ""
|
||||
|
||||
@TableField("open_id", type = "BIGINT")
|
||||
var openId: Long = 0
|
||||
|
||||
@TableField("user_id", type = "BIGINT")
|
||||
var userId: Long = 0
|
||||
|
||||
@TableField("updated_at", type = "TIMESTAMP")
|
||||
var updatedAt: String? = null
|
||||
}
|
||||
@ -1,150 +0,0 @@
|
||||
//package app.example
|
||||
//
|
||||
//import org.aikrai.vertx.gen.AnnotationMapping
|
||||
//import org.aikrai.vertx.gen.ColumnMapping
|
||||
//import org.aikrai.vertx.gen.SqlAnnotationMapper
|
||||
//import org.aikrai.vertx.gen.SqlGenerator
|
||||
//
|
||||
///**
|
||||
// * 表名注解示例
|
||||
// */
|
||||
//@Target(AnnotationTarget.CLASS)
|
||||
//@Retention(AnnotationRetention.RUNTIME)
|
||||
//annotation class TableName(val value: String)
|
||||
//
|
||||
///**
|
||||
// * 列名注解示例
|
||||
// */
|
||||
//@Target(AnnotationTarget.FIELD)
|
||||
//@Retention(AnnotationRetention.RUNTIME)
|
||||
//annotation class Column(val value: String, val type: String = "VARCHAR(255)")
|
||||
//
|
||||
///**
|
||||
// * 主键注解示例
|
||||
// */
|
||||
//@Target(AnnotationTarget.FIELD)
|
||||
//@Retention(AnnotationRetention.RUNTIME)
|
||||
//annotation class Id(val value: Boolean = true)
|
||||
//
|
||||
///**
|
||||
// * 非空注解示例
|
||||
// */
|
||||
//@Target(AnnotationTarget.FIELD)
|
||||
//@Retention(AnnotationRetention.RUNTIME)
|
||||
//annotation class NotNull(val value: Boolean = true)
|
||||
//
|
||||
///**
|
||||
// * 默认值注解示例
|
||||
// */
|
||||
//@Target(AnnotationTarget.FIELD)
|
||||
//@Retention(AnnotationRetention.RUNTIME)
|
||||
//annotation class DefaultValue(val value: String)
|
||||
//
|
||||
///**
|
||||
// * 用户实体类示例
|
||||
// */
|
||||
//@TableName("tb_user")
|
||||
//class User {
|
||||
// @Id
|
||||
// @Column("id", "SERIAL")
|
||||
// @NotNull
|
||||
// var id: Long = 0
|
||||
//
|
||||
// @Column("username")
|
||||
// @NotNull
|
||||
// var username: String = ""
|
||||
//
|
||||
// @Column("email")
|
||||
// var email: String? = null
|
||||
//
|
||||
// @Column("created_at", "TIMESTAMP")
|
||||
// @DefaultValue("CURRENT_TIMESTAMP")
|
||||
// var createdAt: String = ""
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * SQL注解映射示例
|
||||
// */
|
||||
//class SqlAnnotationExample {
|
||||
// companion object {
|
||||
// /**
|
||||
// * 创建注解映射器
|
||||
// */
|
||||
// fun createMapper(): SqlAnnotationMapper {
|
||||
// val mapper = SqlAnnotationMapper()
|
||||
//
|
||||
// // 设置表名映射
|
||||
// mapper.tableName = AnnotationMapping(
|
||||
// annotationClass = TableName::class,
|
||||
// propertyName = "value"
|
||||
// )
|
||||
//
|
||||
// // 设置列名映射
|
||||
// mapper.addColumnMapping(
|
||||
// ColumnMapping(
|
||||
// nameMapping = AnnotationMapping(
|
||||
// annotationClass = Column::class,
|
||||
// propertyName = "value"
|
||||
// ),
|
||||
// typeMapping = AnnotationMapping(
|
||||
// annotationClass = Column::class,
|
||||
// propertyName = "type"
|
||||
// ),
|
||||
// nullableMapping = AnnotationMapping(
|
||||
// annotationClass = NotNull::class,
|
||||
// propertyName = "value"
|
||||
// ),
|
||||
// defaultValueMapping = AnnotationMapping(
|
||||
// annotationClass = DefaultValue::class,
|
||||
// propertyName = "value"
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
//
|
||||
// // 设置主键映射
|
||||
// mapper.primaryKeyMapping = AnnotationMapping(
|
||||
// annotationClass = Id::class,
|
||||
// propertyName = "value"
|
||||
// )
|
||||
//
|
||||
// return mapper
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 测试SQL生成
|
||||
// */
|
||||
// fun testSqlGeneration() {
|
||||
// // 创建注解映射器
|
||||
// val mapper = createMapper()
|
||||
//
|
||||
// // 生成各种SQL
|
||||
// val createTableSql = SqlGenerator.generateCreateTableSql(User::class, mapper)
|
||||
// val insertSql = SqlGenerator.generateInsertSql(User::class, mapper)
|
||||
// val updateSql = SqlGenerator.generateUpdateSql(User::class, mapper)
|
||||
// val deleteSql = SqlGenerator.generateDeleteSql(User::class, mapper)
|
||||
// val selectSql = SqlGenerator.generateSelectSql(User::class, mapper)
|
||||
// val selectByPkSql = SqlGenerator.generateSelectByPrimaryKeySql(User::class, mapper)
|
||||
//
|
||||
// // 打印SQL
|
||||
// println("Create Table SQL:")
|
||||
// println(createTableSql)
|
||||
// println("\nInsert SQL:")
|
||||
// println(insertSql)
|
||||
// println("\nUpdate SQL:")
|
||||
// println(updateSql)
|
||||
// println("\nDelete SQL:")
|
||||
// println(deleteSql)
|
||||
// println("\nSelect SQL:")
|
||||
// println(selectSql)
|
||||
// println("\nSelect By PK SQL:")
|
||||
// println(selectByPkSql)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * 主函数,用于演示
|
||||
// */
|
||||
//fun main() {
|
||||
// SqlAnnotationExample.testSqlGeneration()
|
||||
//}
|
||||
@ -1,94 +0,0 @@
|
||||
//package app.example
|
||||
//
|
||||
//import org.aikrai.vertx.db.annotation.TableField
|
||||
//import org.aikrai.vertx.db.annotation.TableId
|
||||
//import org.aikrai.vertx.db.annotation.TableName
|
||||
//import org.aikrai.vertx.gen.AnnotationMapping
|
||||
//import org.aikrai.vertx.gen.ColumnMapping
|
||||
//import org.aikrai.vertx.gen.SqlAnnotationMapper
|
||||
//import org.aikrai.vertx.gen.SqlMigrationGenerator
|
||||
//import org.reflections.Reflections
|
||||
//import kotlin.reflect.KClass
|
||||
//
|
||||
///**
|
||||
// * PostgreSQL数据库迁移工具示例
|
||||
// */
|
||||
//class SqlMigrationExample {
|
||||
// companion object {
|
||||
// /**
|
||||
// * 创建注解映射器
|
||||
// */
|
||||
// fun createMapper(): SqlAnnotationMapper {
|
||||
// val mapper = SqlAnnotationMapper()
|
||||
//
|
||||
// // 设置表名映射
|
||||
// mapper.tableName = AnnotationMapping(
|
||||
// annotationClass = TableName::class,
|
||||
// propertyName = "value"
|
||||
// )
|
||||
//
|
||||
// // 设置列名映射
|
||||
// mapper.addColumnMapping(
|
||||
// ColumnMapping(
|
||||
// nameMapping = AnnotationMapping(
|
||||
// annotationClass = TableField::class,
|
||||
// propertyName = "value"
|
||||
// ),
|
||||
// typeMapping = AnnotationMapping(
|
||||
// annotationClass = TableField::class,
|
||||
// propertyName = "type"
|
||||
// ),
|
||||
// nullableMapping = AnnotationMapping(
|
||||
// annotationClass = TableField::class,
|
||||
// propertyName = "nullable"
|
||||
// ),
|
||||
// defaultValueMapping = AnnotationMapping(
|
||||
// annotationClass = TableField::class,
|
||||
// propertyName = "default"
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
//
|
||||
// // 设置主键映射
|
||||
// mapper.primaryKeyMapping = AnnotationMapping(
|
||||
// annotationClass = TableId::class,
|
||||
// propertyName = "value"
|
||||
// )
|
||||
//
|
||||
// return mapper
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 测试数据库迁移生成
|
||||
// */
|
||||
// fun testMigrationGeneration() {
|
||||
// // 创建注解映射器
|
||||
// val mapper = createMapper()
|
||||
//
|
||||
// // 扫描实体类
|
||||
// val entityClasses = scanEntityClasses("app.example")
|
||||
//
|
||||
// // 生成迁移文件
|
||||
// SqlMigrationGenerator.generateMigrations(entityClasses, mapper)
|
||||
//
|
||||
// println("数据库迁移文件生成完成")
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 扫描包路径下标记了@TableName注解的实体类
|
||||
// */
|
||||
// private fun scanEntityClasses(packagePath: String): List<KClass<*>> {
|
||||
// val reflections = Reflections(packagePath)
|
||||
// val entityClasses = reflections.getTypesAnnotatedWith(TableName::class.java)
|
||||
//
|
||||
// return entityClasses.map { it.kotlin }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * 主函数,用于演示
|
||||
// */
|
||||
//fun main() {
|
||||
// SqlMigrationExample.testMigrationGeneration()
|
||||
//}
|
||||
@ -3,17 +3,17 @@ package app
|
||||
import org.aikrai.vertx.db.annotation.TableField
|
||||
import org.aikrai.vertx.db.annotation.TableId
|
||||
import org.aikrai.vertx.db.annotation.TableName
|
||||
import org.aikrai.vertx.gen.AnnotationMapping
|
||||
import org.aikrai.vertx.gen.ColumnMapping
|
||||
import org.aikrai.vertx.gen.SqlAnnotationMapper
|
||||
import org.aikrai.vertx.gen.SqlMigrationGenerator
|
||||
import org.reflections.Reflections
|
||||
import kotlin.reflect.KClass
|
||||
import org.aikrai.vertx.db.migration.AnnotationMapping
|
||||
import org.aikrai.vertx.db.migration.ColumnMapping
|
||||
import org.aikrai.vertx.db.migration.SqlAnnotationMapper
|
||||
import org.aikrai.vertx.db.migration.SqlMigrationGenerator
|
||||
|
||||
object GenerateMigration {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
testMigrationGeneration()
|
||||
val entityPackage = "app.data.domain"
|
||||
|
||||
migrationGeneration(entityPackage)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,26 +62,16 @@ object GenerateMigration {
|
||||
/**
|
||||
* 测试数据库迁移生成
|
||||
*/
|
||||
private fun testMigrationGeneration() {
|
||||
private fun migrationGeneration(entityPackage: String) {
|
||||
// 创建注解映射器
|
||||
val mapper = createMapper()
|
||||
|
||||
// 扫描实体类
|
||||
val entityClasses = scanEntityClasses("app.example")
|
||||
val entityClasses = scanEntityClasses(entityPackage)
|
||||
|
||||
// 生成迁移文件
|
||||
SqlMigrationGenerator.generateMigrations(entityClasses, mapper)
|
||||
|
||||
println("数据库迁移文件生成完成")
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫描包路径下标记了@TableName注解的实体类
|
||||
*/
|
||||
private fun scanEntityClasses(packagePath: String): List<KClass<*>> {
|
||||
val reflections = Reflections(packagePath)
|
||||
val entityClasses = reflections.getTypesAnnotatedWith(TableName::class.java)
|
||||
|
||||
return entityClasses.map { it.kotlin }
|
||||
}
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
apifox:
|
||||
token: APS-xxxxxxxxxxxxxxxxxxxx
|
||||
projectId: xxxxx
|
||||
folderId: xxxxx
|
||||
@ -1,14 +0,0 @@
|
||||
databases:
|
||||
name: vertx-demo
|
||||
host: 127.0.0.1
|
||||
port: 5432
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
database: 0
|
||||
password: xxx
|
||||
maxPoolSize: 8
|
||||
maxPoolWaiting: 2000
|
||||
@ -1,5 +0,0 @@
|
||||
server:
|
||||
port: 8080
|
||||
package: app
|
||||
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
package org.aikrai.vertx.db.migration
|
||||
|
||||
class DbMigration {
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package org.aikrai.vertx.gen
|
||||
package org.aikrai.vertx.db.migration
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.aikrai.vertx.gen
|
||||
package org.aikrai.vertx.db.migration
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.aikrai.vertx.gen
|
||||
package org.aikrai.vertx.db.migration
|
||||
|
||||
import org.aikrai.vertx.db.annotation.TableName
|
||||
import org.reflections.Reflections
|
||||
import org.w3c.dom.Document
|
||||
import org.w3c.dom.Element
|
||||
import java.io.File
|
||||
@ -46,6 +48,15 @@ class SqlMigrationGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫描包路径下标记了@TableName注解的实体类
|
||||
*/
|
||||
private fun scanEntityClasses(packagePath: String): List<KClass<*>> {
|
||||
val reflections = Reflections(packagePath)
|
||||
val entityClasses = reflections.getTypesAnnotatedWith(TableName::class.java)
|
||||
return entityClasses.map { it.kotlin }
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建必要的目录
|
||||
*/
|
||||
@ -1,4 +1,4 @@
|
||||
package org.aikrai.vertx.db
|
||||
package org.aikrai.vertx.db.wrapper
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.aikrai.vertx.db
|
||||
package org.aikrai.vertx.db.wrapper
|
||||
|
||||
import io.vertx.kotlin.coroutines.coAwait
|
||||
import io.vertx.sqlclient.Row
|
||||
@ -1,4 +1,4 @@
|
||||
package org.aikrai.vertx.db
|
||||
package org.aikrai.vertx.db.wrapper
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.aikrai.vertx.db
|
||||
package org.aikrai.vertx.db.wrapper
|
||||
|
||||
import cn.hutool.core.util.IdUtil
|
||||
import cn.hutool.core.util.StrUtil
|
||||
Loading…
x
Reference in New Issue
Block a user