版本管理全面增强:状态、补丁更新、热更新
1. 自动状态管理 - 新增版本自动标记状态:最新版本为'有效',旧版本自动标记为'已失效' - 前端列表页新增状态列和状态筛选 2. 更新方式升级 - 更新方式从手动/自动改为:手动更新/热更新/完整更新 - 热更新:运行时增量替换文件,无需重启 - 完整更新:下载完整包替换,需重启 3. 补丁更新支持 - 新增 base_version_id 字段支持增量补丁 - 创建版本时可选择基础版本,自动识别为补丁模式 - 补丁模式仅上传变更文件 4. ZIP解析上传(已有功能完善) - 上传ZIP自动解析文件列表 - 支持选择入口文件 5. 国际化完善 - 中英文新增状态、更新方式等翻译
This commit is contained in:
@@ -232,12 +232,14 @@ type Version struct {
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
Changelog string `gorm:"type:text" json:"changelog"`
|
||||
Status string `gorm:"size:20;default:active" json:"status"`
|
||||
BaseVersionID *uint `json:"base_version_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Application Application `gorm:"foreignKey:ApplicationID" json:"application,omitempty"`
|
||||
Files []VersionFile `gorm:"foreignKey:VersionID" json:"files,omitempty"`
|
||||
BaseVersion *Version `gorm:"foreignKey:BaseVersionID" json:"base_version,omitempty"`
|
||||
}
|
||||
|
||||
// VersionFile 版本文件模型
|
||||
|
||||
@@ -43,6 +43,7 @@ func handleGetAllVersions(c *gin.Context) {
|
||||
applicationIDFilter := c.Query("application_id")
|
||||
updateStrategyFilter := c.Query("update_strategy")
|
||||
updateMethodFilter := c.Query("update_method")
|
||||
statusFilter := c.Query("status")
|
||||
searchFilter := c.Query("search")
|
||||
|
||||
var total int64
|
||||
@@ -85,6 +86,9 @@ func handleGetAllVersions(c *gin.Context) {
|
||||
if updateMethodFilter != "" {
|
||||
countQuery = countQuery.Where("update_method = ?", updateMethodFilter)
|
||||
}
|
||||
if statusFilter != "" {
|
||||
countQuery = countQuery.Where("status = ?", statusFilter)
|
||||
}
|
||||
if searchFilter != "" {
|
||||
searchLower := strings.ToLower(searchFilter)
|
||||
countQuery = countQuery.Where("LOWER(version) LIKE ? OR LOWER(description) LIKE ?", "%"+searchLower+"%", "%"+searchLower+"%")
|
||||
@@ -101,6 +105,9 @@ func handleGetAllVersions(c *gin.Context) {
|
||||
if updateMethodFilter != "" {
|
||||
query = query.Where("update_method = ?", updateMethodFilter)
|
||||
}
|
||||
if statusFilter != "" {
|
||||
query = query.Where("status = ?", statusFilter)
|
||||
}
|
||||
if searchFilter != "" {
|
||||
searchLower := strings.ToLower(searchFilter)
|
||||
query = query.Where("LOWER(version) LIKE ? OR LOWER(description) LIKE ?", "%"+searchLower+"%", "%"+searchLower+"%")
|
||||
@@ -186,6 +193,7 @@ func handleGetVersionByID(c *gin.Context) {
|
||||
"min_version": version.MinVersion,
|
||||
"changelog": version.Changelog,
|
||||
"status": version.Status,
|
||||
"base_version_id": version.BaseVersionID,
|
||||
"files": version.Files,
|
||||
"created_at": version.CreatedAt,
|
||||
"updated_at": version.UpdatedAt,
|
||||
@@ -205,6 +213,7 @@ type CreateVersionRequest struct {
|
||||
MinVersion string `json:"min_version"`
|
||||
Description string `json:"description"`
|
||||
Changelog string `json:"changelog"`
|
||||
BaseVersionID *uint `json:"base_version_id"`
|
||||
}
|
||||
|
||||
func handleCreateVersionGlobal(c *gin.Context) {
|
||||
@@ -247,6 +256,7 @@ func handleCreateVersionGlobal(c *gin.Context) {
|
||||
Description: req.Description,
|
||||
Changelog: req.Changelog,
|
||||
Status: "active",
|
||||
BaseVersionID: req.BaseVersionID,
|
||||
}
|
||||
|
||||
if version.UpdateStrategy == "" {
|
||||
@@ -261,6 +271,10 @@ func handleCreateVersionGlobal(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
database.DB.Model(&model.Version{}).
|
||||
Where("application_id = ? AND id != ? AND status = ?", req.ApplicationID, version.ID, "active").
|
||||
Update("status", "superseded")
|
||||
|
||||
userIDPtr := &userID
|
||||
versionIDPtr := &version.ID
|
||||
service.CreateLog(service.LogParams{
|
||||
|
||||
Reference in New Issue
Block a user