web 服务框架

This commit is contained in:
2025-03-18 10:13:57 +08:00
parent 27e0ed2994
commit 19530d9d40
52 changed files with 8295 additions and 37 deletions

30
cmd/gen/main.go Normal file
View File

@@ -0,0 +1,30 @@
package main
import (
"gorm.io/driver/postgres"
"gorm.io/gen"
"gorm.io/gorm"
"gorm.io/gorm/schema"
)
func main() {
g := gen.NewGenerator(gen.Config{
OutPath: "web/queries",
ModelPkgPath: "models",
Mode: gen.WithDefaultQuery | gen.WithoutContext,
})
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.UseDB(db)
models := g.GenerateAllTable()
g.ApplyBasic(models...)
g.Execute()
}