新增代理服务与边缘节点注册功能
This commit is contained in:
@@ -1,25 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"proxy-server/server/pkg/env"
|
||||
"proxy-server/server/pkg/orm"
|
||||
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
env.Init()
|
||||
orm.Init()
|
||||
|
||||
g := gen.NewGenerator(gen.Config{
|
||||
OutPath: "../../temp-out",
|
||||
Mode: gen.WithoutContext | gen.WithDefaultQuery | gen.WithQueryInterface,
|
||||
})
|
||||
g.UseDB(orm.DB)
|
||||
g.ApplyBasic(
|
||||
g.GenerateAllTable()...,
|
||||
// 初始化
|
||||
db, _ := gorm.Open(
|
||||
postgres.Open("host=localhost user=test password=test dbname=app port=5432 sslmode=disable TimeZone=Asia/Shanghai"),
|
||||
&gorm.Config{
|
||||
NamingStrategy: schema.NamingStrategy{
|
||||
SingularTable: true,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
g.Execute()
|
||||
g := gen.NewGenerator(gen.Config{
|
||||
OutPath: "server/repo/queries",
|
||||
ModelPkgPath: "models",
|
||||
Mode: gen.WithDefaultQuery | gen.WithoutContext,
|
||||
})
|
||||
g.UseDB(db)
|
||||
|
||||
common := []gen.ModelOpt{
|
||||
gen.FieldModify(func(field gen.Field) gen.Field {
|
||||
if field.Type == "time.Time" {
|
||||
field.Type = "orm.LocalDateTime"
|
||||
}
|
||||
return field
|
||||
}),
|
||||
}
|
||||
|
||||
// 生成需要的模型
|
||||
g.GenerateModel("channel", common...)
|
||||
g.GenerateModel("node", common...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user