mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-08 11:05:59 +08:00
cache
This commit is contained in:
@@ -1,10 +1,44 @@
|
||||
package cms_api_struct
|
||||
|
||||
import (
|
||||
apiStruct "Open_IM/pkg/base_info"
|
||||
"mime/multipart"
|
||||
)
|
||||
|
||||
type AdminLoginRequest struct {
|
||||
AdminName string `json:"admin_name" binding:"required"`
|
||||
Secret string `json:"secret" binding:"required"`
|
||||
Secret string `json:"secret" binding:"required"`
|
||||
}
|
||||
|
||||
type AdminLoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
}
|
||||
|
||||
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" binding:"required"`
|
||||
ForceUpdate bool `form:"forceUpdate" binding:"required"`
|
||||
}
|
||||
|
||||
type UploadUpdateAppResp struct {
|
||||
apiStruct.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 {
|
||||
apiStruct.CommResp
|
||||
Data struct {
|
||||
HasNewVersion bool `json:"hasNewVersion"`
|
||||
ForceUpdate bool `json:"forceUpdate"`
|
||||
FileURL string `json:"fileURL"`
|
||||
YamlURL string `json:"yamlURL"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
@@ -37,3 +38,33 @@ func GetNewFileNameAndContentType(fileName string, fileType int) (string, string
|
||||
}
|
||||
return newName, contentType
|
||||
}
|
||||
|
||||
func GetUploadAppNewName(appType int, version string) (string, string, error) {
|
||||
var newFileName, newYamlName = version + "_app_", version + "_yaml_"
|
||||
switch appType {
|
||||
case constant.IOSPlatformID:
|
||||
newFileName += constant.IOSPlatformStr
|
||||
newYamlName += constant.IOSPlatformStr
|
||||
case constant.AndroidPlatformID:
|
||||
newFileName += constant.AndroidPlatformStr
|
||||
newYamlName += constant.AndroidPlatformStr
|
||||
case constant.WindowsPlatformID:
|
||||
newFileName += constant.WindowsPlatformStr
|
||||
newYamlName += constant.WindowsPlatformStr
|
||||
case constant.OSXPlatformID:
|
||||
newFileName += constant.OSXPlatformStr
|
||||
newYamlName += constant.OSXPlatformStr
|
||||
case constant.WebPlatformID:
|
||||
newFileName += constant.WebPlatformStr
|
||||
newYamlName += constant.WebPlatformStr
|
||||
case constant.MiniWebPlatformID:
|
||||
newFileName += constant.MiniWebPlatformStr
|
||||
newYamlName += constant.MiniWebPlatformStr
|
||||
case constant.LinuxPlatformID:
|
||||
newFileName += constant.LinuxPlatformStr
|
||||
newYamlName += constant.LinuxPlatformStr
|
||||
default:
|
||||
return "", "", errors.New("invalid app type")
|
||||
}
|
||||
return newFileName, newYamlName, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user