mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 10:48:15 +08:00
[REV] add ErrRecordAlreadyExist for creating version info
This commit is contained in:
parent
f5204be141
commit
222076588b
@ -20,6 +20,7 @@ package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/goodrain/rainbond/db/errors"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -38,7 +39,7 @@ import (
|
||||
"github.com/goodrain/rainbond/worker/discover/model"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pquerna/ffjson/ffjson"
|
||||
validator "github.com/thedevsaddam/govalidator"
|
||||
"github.com/thedevsaddam/govalidator"
|
||||
)
|
||||
|
||||
//TIMELAYOUT timelayout
|
||||
@ -512,6 +513,11 @@ func (t *TenantStruct) BuildService(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err = db.GetManager().VersionInfoDao().AddModel(&version)
|
||||
if err != nil {
|
||||
if err == errors.ErrRecordAlreadyExist {
|
||||
httputil.ReturnError(r, w, 400,
|
||||
fmt.Sprintf("service id: %s; build version: %s; version already exists", serviceID, build.Body.DeployVersion))
|
||||
return
|
||||
}
|
||||
logrus.Infof("error add version %v ,details %s", version, err.Error())
|
||||
httputil.ReturnError(r, w, 500, "create service version error.")
|
||||
return
|
||||
|
@ -19,10 +19,9 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/goodrain/rainbond/db/errors"
|
||||
"github.com/goodrain/rainbond/db/model"
|
||||
|
||||
"fmt"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
@ -58,7 +57,7 @@ func (c *VersionInfoDaoImpl) AddModel(mo model.Interface) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("service %s build version %s is exist", result.ServiceID, result.BuildVersion)
|
||||
return errors.ErrRecordAlreadyExist
|
||||
}
|
||||
|
||||
//UpdateModel UpdateModel
|
||||
|
Loading…
Reference in New Issue
Block a user