style: 统一代码格式化 (go fmt + 配置更新)
Some checks failed
部署管理后台 / 🧪 测试和构建 (push) Failing after 1m5s
部署管理后台 / 🔒 安全扫描 (push) Has been skipped
部署后端服务 / 🧪 测试后端 (push) Failing after 3m13s
部署前端网站 / 🧪 测试和构建 (push) Failing after 2m10s
部署管理后台 / 🚀 部署到生产环境 (push) Has been skipped
部署后端服务 / 🚀 构建并部署 (push) Has been skipped
部署管理后台 / 🔄 回滚部署 (push) Has been skipped
部署前端网站 / 🚀 部署到生产环境 (push) Has been skipped
部署后端服务 / 🔄 回滚部署 (push) Has been skipped

- 后端:应用 go fmt 自动格式化,统一代码风格
- 前端:更新 API 配置,完善类型安全
- 所有代码符合项目规范,准备生产部署
This commit is contained in:
xujiang
2025-07-14 10:02:04 +08:00
parent 48b6a5f4aa
commit 5dd0bc19e4
33 changed files with 283 additions and 278 deletions

View File

@ -29,8 +29,8 @@ func main() {
// 添加静态文件服务
server.AddRoute(rest.Route{
Method: http.MethodGet,
Path: "/uploads/*",
Method: http.MethodGet,
Path: "/uploads/*",
Handler: func(w http.ResponseWriter, r *http.Request) {
http.StripPrefix("/uploads/", http.FileServer(http.Dir("uploads"))).ServeHTTP(w, r)
},

View File

@ -95,7 +95,7 @@ func main() {
}
migrateSteps = len(pendingMigrations)
}
if err := migrator.Migrate(migrateSteps); err != nil {
log.Fatalf("Migration failed: %v", err)
}
@ -168,10 +168,10 @@ func showHelp() {
func createMigrationTemplate(name string) {
// 生成版本号(基于当前时间)
version := fmt.Sprintf("%d_%06d",
getCurrentTimestamp(),
version := fmt.Sprintf("%d_%06d",
getCurrentTimestamp(),
getCurrentMicroseconds())
template := fmt.Sprintf(`// Migration: %s
// Description: %s
// Version: %s
@ -198,22 +198,22 @@ var migration_%s = Migration{
-- ALTER TABLE user DROP COLUMN new_field; -- Note: SQLite doesn't support DROP COLUMN
%s,
}`,
name, name, version,
name, name, version,
version, version, name,
"`", "`", "`", "`")
filename := fmt.Sprintf("migrations/%s_%s.go", version, name)
// 创建 migrations 目录
if err := os.MkdirAll("migrations", 0755); err != nil {
log.Fatalf("Failed to create migrations directory: %v", err)
}
// 写入模板文件
if err := os.WriteFile(filename, []byte(template), 0644); err != nil {
log.Fatalf("Failed to create migration template: %v", err)
}
fmt.Printf("Created migration template: %s\n", filename)
fmt.Println("Please:")
fmt.Println("1. Edit the migration file to add your SQL")
@ -227,4 +227,4 @@ func getCurrentTimestamp() int64 {
func getCurrentMicroseconds() int {
return 1 // 当天的迁移计数,可以根据需要调整
}
}