mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 02:26:00 +08:00
cache
This commit is contained in:
@@ -63,6 +63,7 @@ type config struct {
|
||||
}
|
||||
Minio struct {
|
||||
Bucket string `yaml:"bucket"`
|
||||
AppBucket string `yaml:"appBucket"`
|
||||
Location string `yaml:"location"`
|
||||
Endpoint string `yaml:"endpoint"`
|
||||
AccessKeyID string `yaml:"accessKeyID"`
|
||||
|
||||
@@ -272,3 +272,14 @@ type DepartmentMember struct {
|
||||
func (DepartmentMember) TableName() string {
|
||||
return "department_members"
|
||||
}
|
||||
|
||||
type AppVersion struct {
|
||||
Version string `gorm:"column:user_id;size:64"`
|
||||
Type int `gorm:"column:user_id;primary_key"`
|
||||
UpdateTime int `gorm:"column:update_time"`
|
||||
ForceUpdate bool `gorm:"column:force_update"`
|
||||
}
|
||||
|
||||
func (AppVersion) TableName() string {
|
||||
return "app_version"
|
||||
}
|
||||
|
||||
@@ -119,7 +119,10 @@ func initMysqlDB() {
|
||||
fmt.Println("CreateTable DepartmentMember")
|
||||
db.CreateTable(&DepartmentMember{})
|
||||
}
|
||||
|
||||
if !db.HasTable(&AppVersion{}) {
|
||||
fmt.Println("CreateTable DepartmentMember")
|
||||
db.CreateTable(&AppVersion{})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
func UpdateAppVersion(appType int, version string, forceUpdate bool) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
app := db.AppVersion{
|
||||
Version: version,
|
||||
Type: appType,
|
||||
UpdateTime: int(time.Now().Unix()),
|
||||
ForceUpdate: forceUpdate,
|
||||
}
|
||||
result := dbConn.Model(db.AppVersion{}).Where("app_type = ?", appType).Updates(&app)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
if result.RowsAffected == 0 {
|
||||
err := dbConn.Create(&app).Error
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetNewestVersion(appType int) (*db.AppVersion, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
app := db.AppVersion{}
|
||||
return &app, dbConn.Model(db.AppVersion{}).First(&app, appType).Error
|
||||
}
|
||||
Reference in New Issue
Block a user