feat: add custom download URL for manual update method
- Add custom_download_url field to Version model - Show custom download URL input when update method is 'manual' - Use platform default URL if custom URL is not set - Add i18n translations for new field Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -229,7 +229,8 @@ type Version struct {
|
||||
EntryFile string `gorm:"size:255" json:"entry_file"`
|
||||
UpdateStrategy string `gorm:"size:20;default:optional" json:"update_strategy"`
|
||||
UpdateType string `gorm:"size:20;default:full" json:"update_type"`
|
||||
UpdateMethod string `gorm:"size:20;default:auto" json:"update_method"`
|
||||
UpdateMethod string `gorm:"size:20;default:auto" json:"update_method"`
|
||||
CustomDownloadURL string `gorm:"size:500" json:"custom_download_url"`
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
Changelog string `gorm:"type:text" json:"changelog"`
|
||||
Status string `gorm:"size:20;default:active" json:"status"`
|
||||
|
||||
@@ -226,38 +226,40 @@ func handleGetVersionByID(c *gin.Context) {
|
||||
}
|
||||
|
||||
response.Success(c, gin.H{
|
||||
"id": version.ID,
|
||||
"application_id": version.ApplicationID,
|
||||
"application_name": appNameMap[version.ApplicationID],
|
||||
"version": version.Version,
|
||||
"description": version.Description,
|
||||
"file_path": version.FilePath,
|
||||
"file_size": version.FileSize,
|
||||
"file_hash": version.FileHash,
|
||||
"update_strategy": version.UpdateStrategy,
|
||||
"update_type": version.UpdateType,
|
||||
"update_method": version.UpdateMethod,
|
||||
"changelog": version.Changelog,
|
||||
"status": computedStatus,
|
||||
"base_version_id": version.BaseVersionID,
|
||||
"files": version.Files,
|
||||
"created_at": version.CreatedAt,
|
||||
"updated_at": version.UpdatedAt,
|
||||
"id": version.ID,
|
||||
"application_id": version.ApplicationID,
|
||||
"application_name": appNameMap[version.ApplicationID],
|
||||
"version": version.Version,
|
||||
"description": version.Description,
|
||||
"file_path": version.FilePath,
|
||||
"file_size": version.FileSize,
|
||||
"file_hash": version.FileHash,
|
||||
"update_strategy": version.UpdateStrategy,
|
||||
"update_type": version.UpdateType,
|
||||
"update_method": version.UpdateMethod,
|
||||
"custom_download_url": version.CustomDownloadURL,
|
||||
"changelog": version.Changelog,
|
||||
"status": computedStatus,
|
||||
"base_version_id": version.BaseVersionID,
|
||||
"files": version.Files,
|
||||
"created_at": version.CreatedAt,
|
||||
"updated_at": version.UpdatedAt,
|
||||
})
|
||||
}
|
||||
|
||||
type CreateVersionRequest struct {
|
||||
ApplicationID uint `json:"application_id"`
|
||||
Version string `json:"version"`
|
||||
FilePath string `json:"file_path"`
|
||||
FileSize int64 `json:"file_size"`
|
||||
FileHash string `json:"file_hash"`
|
||||
EntryFile string `json:"entry_file"`
|
||||
UpdateStrategy string `json:"update_strategy"`
|
||||
UpdateType string `json:"update_type"`
|
||||
UpdateMethod string `json:"update_method"`
|
||||
Description string `json:"description"`
|
||||
Changelog string `json:"changelog"`
|
||||
ApplicationID uint `json:"application_id"`
|
||||
Version string `json:"version"`
|
||||
FilePath string `json:"file_path"`
|
||||
FileSize int64 `json:"file_size"`
|
||||
FileHash string `json:"file_hash"`
|
||||
EntryFile string `json:"entry_file"`
|
||||
UpdateStrategy string `json:"update_strategy"`
|
||||
UpdateType string `json:"update_type"`
|
||||
UpdateMethod string `json:"update_method"`
|
||||
CustomDownloadURL string `json:"custom_download_url"`
|
||||
Description string `json:"description"`
|
||||
Changelog string `json:"changelog"`
|
||||
}
|
||||
|
||||
func handleCreateVersionGlobal(c *gin.Context) {
|
||||
@@ -287,18 +289,19 @@ func handleCreateVersionGlobal(c *gin.Context) {
|
||||
}
|
||||
|
||||
version := model.Version{
|
||||
ApplicationID: req.ApplicationID,
|
||||
Version: req.Version,
|
||||
FilePath: req.FilePath,
|
||||
FileSize: req.FileSize,
|
||||
FileHash: req.FileHash,
|
||||
EntryFile: req.EntryFile,
|
||||
UpdateStrategy: req.UpdateStrategy,
|
||||
UpdateType: req.UpdateType,
|
||||
UpdateMethod: req.UpdateMethod,
|
||||
Description: req.Description,
|
||||
Changelog: req.Changelog,
|
||||
Status: "active",
|
||||
ApplicationID: req.ApplicationID,
|
||||
Version: req.Version,
|
||||
FilePath: req.FilePath,
|
||||
FileSize: req.FileSize,
|
||||
FileHash: req.FileHash,
|
||||
EntryFile: req.EntryFile,
|
||||
UpdateStrategy: req.UpdateStrategy,
|
||||
UpdateType: req.UpdateType,
|
||||
UpdateMethod: req.UpdateMethod,
|
||||
CustomDownloadURL: req.CustomDownloadURL,
|
||||
Description: req.Description,
|
||||
Changelog: req.Changelog,
|
||||
Status: "active",
|
||||
}
|
||||
|
||||
if version.UpdateStrategy == "" {
|
||||
@@ -341,12 +344,13 @@ 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"`
|
||||
Version string `json:"version"`
|
||||
UpdateStrategy string `json:"update_strategy"`
|
||||
UpdateType string `json:"update_type"`
|
||||
UpdateMethod string `json:"update_method"`
|
||||
CustomDownloadURL string `json:"custom_download_url"`
|
||||
Description string `json:"description"`
|
||||
Changelog string `json:"changelog"`
|
||||
}
|
||||
|
||||
func handleUpdateVersionGlobal(c *gin.Context) {
|
||||
@@ -403,6 +407,7 @@ func handleUpdateVersionGlobal(c *gin.Context) {
|
||||
if req.UpdateMethod != "" {
|
||||
updates["update_method"] = req.UpdateMethod
|
||||
}
|
||||
updates["custom_download_url"] = req.CustomDownloadURL
|
||||
if req.Description != "" {
|
||||
updates["description"] = req.Description
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user