update app

This commit is contained in:
wangchuxiao 2022-05-10 17:50:22 +08:00
parent 7137924baa
commit 7a423eb6e1
2 changed files with 15 additions and 12 deletions

View File

@ -274,12 +274,12 @@ func (DepartmentMember) TableName() string {
} }
type AppVersion struct { type AppVersion struct {
Version string `gorm:"column:version;size:64"` Version string `gorm:"column:version;size:64" json:"version"`
Type int `gorm:"column:type;primary_key"` Type int `gorm:"column:type;primary_key" json:"type"`
UpdateTime int `gorm:"column:update_time"` UpdateTime int `gorm:"column:update_time" json:"update_time"`
ForceUpdate bool `gorm:"column:force_update"` ForceUpdate bool `gorm:"column:force_update" json:"force_update"`
FileName string `gorm:"column:file_name"` FileName string `gorm:"column:file_name" json:"file_name"`
YamlName string `gorm:"column:yaml_name"` YamlName string `gorm:"column:yaml_name" json:"yaml_name"`
} }
func (AppVersion) TableName() string { func (AppVersion) TableName() string {

View File

@ -10,14 +10,17 @@ func UpdateAppVersion(appType int, version string, forceUpdate bool, fileName, y
if err != nil { if err != nil {
return err return err
} }
updateTime := int(time.Now().Unix())
app := db.AppVersion{ app := db.AppVersion{
Version: version, Version: version,
Type: appType, Type: appType,
UpdateTime: int(time.Now().Unix()), UpdateTime: updateTime,
FileName: fileName, FileName: fileName,
YamlName: yamlName, 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 { if result.Error != nil {
return result.Error return result.Error
} }