feat: auto-generate full package when uploading patch

- Add FullPackagePath, FullPackageSize, FullPackageHash to Version model
- When uploading patch, merge with base full package to create new full package
- Check update API returns full package info for download
- Add package_util.go with merge functions

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 11:43:58 +08:00
parent fd98c0dcc4
commit 551f4f1576
4 changed files with 217 additions and 22 deletions
+21 -18
View File
@@ -220,24 +220,27 @@ type Application struct {
// Version 版本模型
type Version struct {
ID uint `gorm:"primaryKey" json:"id"`
ApplicationID uint `json:"application_id"`
Version string `gorm:"size:50" json:"version"`
FilePath string `gorm:"size:255" json:"file_path"`
FileSize int64 `json:"file_size"`
FileHash string `gorm:"size:64" json:"file_hash"`
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"`
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"`
BaseVersionID *uint `json:"base_version_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
ID uint `gorm:"primaryKey" json:"id"`
ApplicationID uint `json:"application_id"`
Version string `gorm:"size:50" json:"version"`
FilePath string `gorm:"size:255" json:"file_path"`
FileSize int64 `json:"file_size"`
FileHash string `gorm:"size:64" json:"file_hash"`
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"`
CustomDownloadURL string `gorm:"size:500" json:"custom_download_url"`
FullPackagePath string `gorm:"size:255" json:"full_package_path"`
FullPackageSize int64 `json:"full_package_size"`
FullPackageHash string `gorm:"size:64" json:"full_package_hash"`
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"`