package base_api import ( "context" "gd_management/apis" "gd_management/errors" "time" "github.com/astaxie/beego/orm" ) func ManagementUpdateTryApiTask(ctx context.Context, req *apis.ManagementUpdateTryApiTaskReq, reply *apis.ManagementUpdateTryApiTaskReply) (err error) { o := orm.NewOrm() if req.Status == 3 { // 当状态为进行中,修改状态为正在暂停 sql := "update t_gd_try_api_task set status=?, updated_at=? where id=? and status = ?" _, err = o.Raw(sql, req.Status, time.Now().Format("2006-01-02 15:04:05"), req.TaskId, 0).Exec() if err != nil { return errors.DataBaseError } return nil } if req.DownloadFile == "" { sql := "update t_gd_try_api_task set status=?, err_msg=?, updated_at=? where id=?" _, err = o.Raw(sql, req.Status, req.ErrMsg, time.Now().Format("2006-01-02 15:04:05"), req.TaskId).Exec() if err != nil { return errors.DataBaseError } } else { sql := "update t_gd_try_api_task set status=?, err_msg=?, download_file=?, updated_at=? where id=?" _, err = o.Raw(sql, req.Status, req.ErrMsg, req.DownloadFile, time.Now().Format("2006-01-02 15:04:05"), req.TaskId).Exec() if err != nil { return errors.DataBaseError } } return nil }