mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
update app
This commit is contained in:
parent
608b166b32
commit
f5d4397f0b
@ -228,19 +228,20 @@ func GetDownloadURL(c *gin.Context) {
|
|||||||
app, err := imdb.GetNewestVersion(req.Type)
|
app, err := imdb.GetNewestVersion(req.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "getNewestVersion failed" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if app.Version != req.Version {
|
if app != nil {
|
||||||
resp.Data.HasNewVersion = true
|
if app.Version != req.Version && app.Version != "" {
|
||||||
if app.ForceUpdate == true {
|
resp.Data.HasNewVersion = true
|
||||||
resp.Data.ForceUpdate = true
|
if app.ForceUpdate == true {
|
||||||
|
resp.Data.ForceUpdate = true
|
||||||
|
}
|
||||||
|
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
|
||||||
|
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
} else {
|
||||||
|
resp.Data.HasNewVersion = false
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
|
|
||||||
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
} else {
|
|
||||||
resp.Data.HasNewVersion = false
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
}
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 0, "errMsg": "not found app version"})
|
||||||
}
|
}
|
||||||
|
@ -153,30 +153,25 @@ func GetDownloadURL(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
//fileName, yamlName, err := utils.GetUploadAppNewName(req.Type, req.Version, req.)
|
|
||||||
//if err != nil {
|
|
||||||
// log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUploadAppNewName failed", err.Error())
|
|
||||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file type" + err.Error()})
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
app, err := imdb.GetNewestVersion(req.Type)
|
app, err := imdb.GetNewestVersion(req.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "getNewestVersion failed" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if app.Version != req.Version {
|
if app != nil {
|
||||||
resp.Data.HasNewVersion = true
|
if app.Version != req.Version {
|
||||||
if app.ForceUpdate == true {
|
resp.Data.HasNewVersion = true
|
||||||
resp.Data.ForceUpdate = true
|
if app.ForceUpdate == true {
|
||||||
|
resp.Data.ForceUpdate = true
|
||||||
|
}
|
||||||
|
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
|
||||||
|
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
} else {
|
||||||
|
resp.Data.HasNewVersion = false
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
|
|
||||||
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
} else {
|
|
||||||
resp.Data.HasNewVersion = false
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
}
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 0, "errMsg": "not found app version"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func MinioUploadFile(c *gin.Context) {
|
func MinioUploadFile(c *gin.Context) {
|
||||||
|
@ -32,7 +32,7 @@ type UploadUpdateAppReq struct {
|
|||||||
Version string `form:"version" binding:"required"`
|
Version string `form:"version" binding:"required"`
|
||||||
File *multipart.FileHeader `form:"file" binding:"required"`
|
File *multipart.FileHeader `form:"file" binding:"required"`
|
||||||
Yaml *multipart.FileHeader `form:"yaml" binding:"required"`
|
Yaml *multipart.FileHeader `form:"yaml" binding:"required"`
|
||||||
ForceUpdate bool `form:"forceUpdate" binding:"required"`
|
ForceUpdate bool `form:"forceUpdate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadUpdateAppResp struct {
|
type UploadUpdateAppResp struct {
|
||||||
|
@ -31,10 +31,10 @@ func UpdateAppVersion(appType int, version string, forceUpdate bool, fileName, y
|
|||||||
|
|
||||||
func GetNewestVersion(appType int) (*db.AppVersion, error) {
|
func GetNewestVersion(appType int) (*db.AppVersion, error) {
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
app := db.AppVersion{}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return &app, err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
dbConn.LogMode(true)
|
||||||
app := db.AppVersion{}
|
|
||||||
return &app, dbConn.Model(db.AppVersion{}).First(&app, appType).Error
|
return &app, dbConn.Model(db.AppVersion{}).First(&app, appType).Error
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user