refactor: 拆分更新类型(全量/补丁)和更新方式(自动/手动),移除force_update字段
This commit is contained in:
@@ -42,6 +42,7 @@ func handleGetAllVersions(c *gin.Context) {
|
||||
pageSize := c.DefaultQuery("page_size", "20")
|
||||
applicationIDFilter := c.Query("application_id")
|
||||
updateStrategyFilter := c.Query("update_strategy")
|
||||
updateTypeFilter := c.Query("update_type")
|
||||
updateMethodFilter := c.Query("update_method")
|
||||
searchFilter := c.Query("search")
|
||||
|
||||
@@ -82,6 +83,9 @@ func handleGetAllVersions(c *gin.Context) {
|
||||
if updateStrategyFilter != "" {
|
||||
countQuery = countQuery.Where("update_strategy = ?", updateStrategyFilter)
|
||||
}
|
||||
if updateTypeFilter != "" {
|
||||
countQuery = countQuery.Where("update_type = ?", updateTypeFilter)
|
||||
}
|
||||
if updateMethodFilter != "" {
|
||||
countQuery = countQuery.Where("update_method = ?", updateMethodFilter)
|
||||
}
|
||||
@@ -98,6 +102,9 @@ func handleGetAllVersions(c *gin.Context) {
|
||||
if updateStrategyFilter != "" {
|
||||
query = query.Where("update_strategy = ?", updateStrategyFilter)
|
||||
}
|
||||
if updateTypeFilter != "" {
|
||||
query = query.Where("update_type = ?", updateTypeFilter)
|
||||
}
|
||||
if updateMethodFilter != "" {
|
||||
query = query.Where("update_method = ?", updateMethodFilter)
|
||||
}
|
||||
@@ -223,8 +230,8 @@ func handleGetVersionByID(c *gin.Context) {
|
||||
"file_path": version.FilePath,
|
||||
"file_size": version.FileSize,
|
||||
"file_hash": version.FileHash,
|
||||
"force_update": version.ForceUpdate,
|
||||
"update_strategy": version.UpdateStrategy,
|
||||
"update_type": version.UpdateType,
|
||||
"update_method": version.UpdateMethod,
|
||||
"changelog": version.Changelog,
|
||||
"status": computedStatus,
|
||||
@@ -242,8 +249,8 @@ type CreateVersionRequest struct {
|
||||
FileSize int64 `json:"file_size"`
|
||||
FileHash string `json:"file_hash"`
|
||||
EntryFile string `json:"entry_file"`
|
||||
ForceUpdate bool `json:"force_update"`
|
||||
UpdateStrategy string `json:"update_strategy"`
|
||||
UpdateType string `json:"update_type"`
|
||||
UpdateMethod string `json:"update_method"`
|
||||
Description string `json:"description"`
|
||||
Changelog string `json:"changelog"`
|
||||
@@ -282,8 +289,8 @@ func handleCreateVersionGlobal(c *gin.Context) {
|
||||
FileSize: req.FileSize,
|
||||
FileHash: req.FileHash,
|
||||
EntryFile: req.EntryFile,
|
||||
ForceUpdate: req.ForceUpdate,
|
||||
UpdateStrategy: req.UpdateStrategy,
|
||||
UpdateType: req.UpdateType,
|
||||
UpdateMethod: req.UpdateMethod,
|
||||
Description: req.Description,
|
||||
Changelog: req.Changelog,
|
||||
@@ -293,17 +300,16 @@ func handleCreateVersionGlobal(c *gin.Context) {
|
||||
if version.UpdateStrategy == "" {
|
||||
version.UpdateStrategy = "optional"
|
||||
}
|
||||
if version.UpdateType == "" {
|
||||
version.UpdateType = "full"
|
||||
}
|
||||
if version.UpdateMethod == "" {
|
||||
version.UpdateMethod = "manual"
|
||||
version.UpdateMethod = "auto"
|
||||
}
|
||||
|
||||
if version.UpdateStrategy == "forced" {
|
||||
version.ForceUpdate = true
|
||||
}
|
||||
|
||||
if version.UpdateMethod == "hot" {
|
||||
if version.UpdateType == "patch" {
|
||||
var lastFullVersion model.Version
|
||||
if err := database.DB.Where("application_id = ? AND update_method = ?", req.ApplicationID, "full").
|
||||
if err := database.DB.Where("application_id = ? AND update_type = ?", req.ApplicationID, "full").
|
||||
Order("id DESC").First(&lastFullVersion).Error; err == nil {
|
||||
version.BaseVersionID = &lastFullVersion.ID
|
||||
}
|
||||
@@ -333,6 +339,7 @@ func handleCreateVersionGlobal(c *gin.Context) {
|
||||
type UpdateVersionRequest struct {
|
||||
Version string `json:"version"`
|
||||
UpdateStrategy string `json:"update_strategy"`
|
||||
UpdateType string `json:"update_type"`
|
||||
UpdateMethod string `json:"update_method"`
|
||||
Description string `json:"description"`
|
||||
Changelog string `json:"changelog"`
|
||||
@@ -376,8 +383,8 @@ func handleUpdateVersionGlobal(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] handleUpdateVersionGlobal versionID=%s, req: version=%s, update_strategy=%s, update_method=%s, description=%s\n",
|
||||
versionID, req.Version, req.UpdateStrategy, req.UpdateMethod, req.Description)
|
||||
log.Printf("[DEBUG] handleUpdateVersionGlobal versionID=%s, req: version=%s, update_strategy=%s, update_type=%s, update_method=%s, description=%s\n",
|
||||
versionID, req.Version, req.UpdateStrategy, req.UpdateType, req.UpdateMethod, req.Description)
|
||||
|
||||
updates := map[string]interface{}{}
|
||||
if req.Version != "" {
|
||||
@@ -385,11 +392,9 @@ func handleUpdateVersionGlobal(c *gin.Context) {
|
||||
}
|
||||
if req.UpdateStrategy != "" {
|
||||
updates["update_strategy"] = req.UpdateStrategy
|
||||
if req.UpdateStrategy == "forced" {
|
||||
updates["force_update"] = true
|
||||
} else {
|
||||
updates["force_update"] = false
|
||||
}
|
||||
}
|
||||
if req.UpdateType != "" {
|
||||
updates["update_type"] = req.UpdateType
|
||||
}
|
||||
if req.UpdateMethod != "" {
|
||||
updates["update_method"] = req.UpdateMethod
|
||||
|
||||
Reference in New Issue
Block a user