From 7a423eb6e1d766164e28bbc67f2414ae60ab5be0 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Tue, 10 May 2022 17:50:22 +0800 Subject: [PATCH] update app --- pkg/common/db/model_struct.go | 12 ++++++------ .../db/mysql_model/im_mysql_model/file_model.go | 15 +++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pkg/common/db/model_struct.go b/pkg/common/db/model_struct.go index 6eb18630d..03709a67d 100644 --- a/pkg/common/db/model_struct.go +++ b/pkg/common/db/model_struct.go @@ -274,12 +274,12 @@ 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"` } func (AppVersion) TableName() string { diff --git a/pkg/common/db/mysql_model/im_mysql_model/file_model.go b/pkg/common/db/mysql_model/im_mysql_model/file_model.go index 9a72b1ad0..983dec328 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/file_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/file_model.go @@ -10,14 +10,17 @@ func UpdateAppVersion(appType int, version string, forceUpdate bool, fileName, y if err != nil { return err } + updateTime := int(time.Now().Unix()) app := db.AppVersion{ - Version: version, - Type: appType, - UpdateTime: int(time.Now().Unix()), - FileName: fileName, - YamlName: yamlName, + Version: version, + Type: appType, + UpdateTime: updateTime, + FileName: fileName, + YamlName: yamlName, + ForceUpdate: forceUpdate, } - result := dbConn.Model(db.AppVersion{}).Where("type = ?", appType).Updates(&app).Update(map[string]interface{}{"force_update": forceUpdate}) + 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}) if result.Error != nil { return result.Error }