:card_box: Add detailed release model
This commit is contained in:
parent
c13c1f57a4
commit
79e03e74f3
@ -18,7 +18,8 @@ type ProductRelease struct {
|
||||
Version string `json:"version"`
|
||||
Type ProductReleaseType `json:"type"`
|
||||
Channel string `json:"channel"`
|
||||
Assets datatypes.JSONType[map[string]any] `json:"assets"`
|
||||
Assets datatypes.JSONType[map[string]ReleaseAsset] `json:"assets"`
|
||||
Installers datatypes.JSONType[map[string]ReleaseInstaller] `json:"installers"`
|
||||
|
||||
ProductID uint `json:"product_id"`
|
||||
Meta ProductReleaseMeta `json:"meta" gorm:"foreignKey:ReleaseID"`
|
||||
@ -33,3 +34,19 @@ type ProductReleaseMeta struct {
|
||||
Attachments datatypes.JSONSlice[string] `json:"attachments"`
|
||||
ReleaseID uint `json:"release_id"`
|
||||
}
|
||||
|
||||
type ReleaseAsset struct {
|
||||
URI string `json:"uri" validate:"required"`
|
||||
ContentType string `json:"content_type" validate:"required"`
|
||||
}
|
||||
|
||||
type ReleaseInstaller struct {
|
||||
Workdir string `json:"workdir"`
|
||||
Script string `json:"script"`
|
||||
Patches []ReleaseInstallerPatch `json:"patches"`
|
||||
}
|
||||
|
||||
type ReleaseInstallerPatch struct {
|
||||
Action string `json:"action" validate:"required"`
|
||||
Glob string `json:"glob" validate:"required"`
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ func createRelease(c *fiber.Ctx) error {
|
||||
Title string `json:"title" validate:"required,max=1024"`
|
||||
Description string `json:"description" validate:"required,max=4096"`
|
||||
Content string `json:"content" validate:"required"`
|
||||
Assets map[string]any `json:"assets" validate:"required"`
|
||||
Assets map[string]models.ReleaseAsset `json:"assets" validate:"required"`
|
||||
Installers map[string]models.ReleaseInstaller `json:"installers" validate:"required"`
|
||||
Attachments []string `json:"attachments"`
|
||||
}
|
||||
|
||||
@ -74,6 +75,7 @@ func createRelease(c *fiber.Ctx) error {
|
||||
Type: models.ProductReleaseType(data.Type),
|
||||
Channel: data.Channel,
|
||||
Assets: datatypes.NewJSONType(data.Assets),
|
||||
Installers: datatypes.NewJSONType(data.Installers),
|
||||
ProductID: product.ID,
|
||||
Meta: models.ProductReleaseMeta{
|
||||
Title: data.Title,
|
||||
@ -106,7 +108,8 @@ func updateRelease(c *fiber.Ctx) error {
|
||||
Title string `json:"title" validate:"required,max=1024"`
|
||||
Description string `json:"description" validate:"required,max=4096"`
|
||||
Content string `json:"content" validate:"required"`
|
||||
Assets map[string]any `json:"assets" validate:"required"`
|
||||
Assets map[string]models.ReleaseAsset `json:"assets" validate:"required"`
|
||||
Installers map[string]models.ReleaseInstaller `json:"installers" validate:"required"`
|
||||
Attachments []string `json:"attachments"`
|
||||
}
|
||||
|
||||
@ -128,6 +131,7 @@ func updateRelease(c *fiber.Ctx) error {
|
||||
release.Type = models.ProductReleaseType(data.Type)
|
||||
release.Channel = data.Channel
|
||||
release.Assets = datatypes.NewJSONType(data.Assets)
|
||||
release.Installers = datatypes.NewJSONType(data.Installers)
|
||||
release.Meta.Title = data.Title
|
||||
release.Meta.Description = data.Description
|
||||
release.Meta.Content = data.Content
|
||||
|
Loading…
x
Reference in New Issue
Block a user