网关实现自定义接口安全检查与边缘节点连接权限验证
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// 初始化
|
||||
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 := 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