mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 09:36:00 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package base_info
|
||||
|
||||
import "mime/multipart"
|
||||
|
||||
type MinioStorageCredentialReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
@@ -23,3 +25,35 @@ type MinioUploadFileResp struct {
|
||||
SnapshotURL string `json:"snapshotURL,omitempty"`
|
||||
SnapshotNewName string `json:"snapshotName,omitempty"`
|
||||
}
|
||||
|
||||
type UploadUpdateAppReq struct {
|
||||
OperationID string `form:"operationID" binding:"required"`
|
||||
Type int `form:"type" binding:"required"`
|
||||
Version string `form:"version" binding:"required"`
|
||||
File *multipart.FileHeader `form:"file" binding:"required"`
|
||||
Yaml *multipart.FileHeader `form:"yaml"`
|
||||
ForceUpdate bool `form:"forceUpdate"`
|
||||
UpdateLog string `form:"updateLog" binding:"required"`
|
||||
}
|
||||
|
||||
type UploadUpdateAppResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type GetDownloadURLReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Type int `json:"type" binding:"required"`
|
||||
Version string `json:"version" binding:"required"`
|
||||
}
|
||||
|
||||
type GetDownloadURLResp struct {
|
||||
CommResp
|
||||
Data struct {
|
||||
HasNewVersion bool `json:"hasNewVersion"`
|
||||
ForceUpdate bool `json:"forceUpdate"`
|
||||
FileURL string `json:"fileURL"`
|
||||
YamlURL string `json:"yamlURL"`
|
||||
Version string `json:"version"`
|
||||
UpdateLog string `json:"update_log"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
@@ -274,12 +274,13 @@ func (DepartmentMember) TableName() string {
|
||||
}
|
||||
|
||||
type AppVersion struct {
|
||||
Version string `gorm:"column:version;size:64"`
|
||||
Type int `gorm:"column:type;primary_key"`
|
||||
UpdateTime int `gorm:"column:update_time"`
|
||||
ForceUpdate bool `gorm:"column:force_update"`
|
||||
FileName string `gorm:"column:file_name"`
|
||||
YamlName string `gorm:"column:yaml_name"`
|
||||
Version string `gorm:"column:version;size:64" json:"version"`
|
||||
Type int `gorm:"column:type;primary_key" json:"type"`
|
||||
UpdateTime int `gorm:"column:update_time" json:"update_time"`
|
||||
ForceUpdate bool `gorm:"column:force_update" json:"force_update"`
|
||||
FileName string `gorm:"column:file_name" json:"file_name"`
|
||||
YamlName string `gorm:"column:yaml_name" json:"yaml_name"`
|
||||
UpdateLog string `gorm:"column:update_log" json:"update_log"`
|
||||
}
|
||||
|
||||
func (AppVersion) TableName() string {
|
||||
|
||||
@@ -59,7 +59,7 @@ func initMysqlDB() {
|
||||
&GroupMember{},
|
||||
&GroupRequest{},
|
||||
&User{},
|
||||
&Black{}, &ChatLog{}, &Register{}, &Conversation{})
|
||||
&Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{})
|
||||
db.Set("gorm:table_options", "CHARSET=utf8")
|
||||
db.Set("gorm:table_options", "collation=utf8_unicode_ci")
|
||||
|
||||
|
||||
@@ -5,20 +5,23 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func UpdateAppVersion(appType int, version string, forceUpdate bool, fileName, yamlName string) error {
|
||||
func UpdateAppVersion(appType int, version string, forceUpdate bool, fileName, yamlName, updateLog string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
updateTime := int(time.Now().Unix())
|
||||
app := db.AppVersion{
|
||||
Version: version,
|
||||
Type: appType,
|
||||
UpdateTime: int(time.Now().Unix()),
|
||||
ForceUpdate: forceUpdate,
|
||||
UpdateTime: updateTime,
|
||||
FileName: fileName,
|
||||
YamlName: yamlName,
|
||||
ForceUpdate: forceUpdate,
|
||||
UpdateLog: updateLog,
|
||||
}
|
||||
result := dbConn.Model(db.AppVersion{}).Where("app_type = ?", appType).Updates(&app)
|
||||
result := dbConn.Model(db.AppVersion{}).Where("type = ?", appType).Update(map[string]interface{}{"force_update": forceUpdate,
|
||||
"version": version, "update_time": int(time.Now().Unix()), "file_name": fileName, "yaml_name": yamlName, "type": appType, "update_log": updateLog})
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
@@ -31,10 +34,10 @@ func UpdateAppVersion(appType int, version string, forceUpdate bool, fileName, y
|
||||
|
||||
func GetNewestVersion(appType int) (*db.AppVersion, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
app := db.AppVersion{}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return &app, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
app := db.AppVersion{}
|
||||
return &app, dbConn.Model(db.AppVersion{}).First(&app, appType).Error
|
||||
}
|
||||
|
||||
@@ -70,5 +70,8 @@ func GetUploadAppNewName(appType int, version, fileName, yamlName string) (strin
|
||||
suffixYaml := path.Ext(yamlName)
|
||||
newFileName = fmt.Sprintf("%s%s", newFileName, suffixFile)
|
||||
newYamlName = fmt.Sprintf("%s%s", newYamlName, suffixYaml)
|
||||
if yamlName == "" {
|
||||
newYamlName = ""
|
||||
}
|
||||
return newFileName, newYamlName, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user