Merge remote-tracking branch 'origin/tuoyun' into tuoyun

This commit is contained in:
wenxu12345
2022-05-11 12:13:43 +08:00
12 changed files with 253 additions and 159 deletions
+34
View File
@@ -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"`
}
+7 -6
View File
@@ -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 {
+1 -1
View File
@@ -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
}
+3
View File
@@ -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
}