package controllers import ( "server/services" beego "github.com/beego/beego/v2/server/web" ) type StorageMigrationController struct { beego.Controller } func (c *StorageMigrationController) MigrateToQiniu() { tid := uint64(1) progress, err := services.MigrateLocalToQiniu(tid) if err != nil { c.Data["json"] = map[string]interface{}{ "code": 500, "msg": "迁移失败: " + err.Error(), "data": progress, } _ = c.ServeJSON() return } c.Data["json"] = map[string]interface{}{ "code": 200, "msg": "迁移完成", "data": map[string]interface{}{ "total": progress.Total, "success": progress.Success, "failed": progress.Failed, "errors": progress.Errors, }, } _ = c.ServeJSON() } func (c *StorageMigrationController) GetMigrationProgress() { c.Data["json"] = map[string]interface{}{ "code": 200, "msg": "success", "data": map[string]interface{}{ "total": 0, "success": 0, "failed": 0, "current": "", }, } _ = c.ServeJSON() }