修复构建报错

This commit is contained in:
2025-11-05 16:12:56 +08:00
parent a7bde8bb72
commit ad8978617c
5 changed files with 35 additions and 2 deletions
+4 -1
View File
@@ -9,9 +9,12 @@ import (
"github.com/beego/beego/v2/server/web/context"
)
// 项目版本号
const Version = "1.0.0"
func main() {
// 初始化数据库
models.Init()
models.Init(Version)
// CORS配置已移至router.go中统一管理
// 确保请求体被正确读取(包括 POST、PUT、PATCH
+2 -1
View File
@@ -392,7 +392,7 @@ func DeleteUser(id int) error {
}
// Init 初始化数据库
func Init() {
func Init(version string) {
orm.RegisterModel(new(User))
orm.RegisterModel(new(Menu))
orm.RegisterModel(new(ProgramCategory))
@@ -430,5 +430,6 @@ func Init() {
// 注意:Beego v2 中不需要显式调用 Using,默认使用 "default"
fmt.Println("数据库连接成功!")
fmt.Printf("当前项目版本: %s\n", version)
}
}