Skip to content

Commit

Permalink
feat(release): add front, banner and logo asset
Browse files Browse the repository at this point in the history
  • Loading branch information
catouberos authored and momo-p committed Nov 2, 2024
1 parent d6761ac commit 338cf7f
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions models/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ type Release struct {
PartnerId string `db:"partner" json:"partnerId"`
Partner *Publisher `db:"-" json:"partner,omitempty"`
Status ReleaseStatus `db:"status" json:"status"`
FrontId string `db:"front" json:"frontId"`
Front *Asset `db:"-" json:"front,omitempty"`
BannerId string `db:"banner" json:"bannerId"`
Banner *Asset `db:"-" json:"banner,omitempty"`
LogoId string `db:"logo" json:"logoId"`
Logo *Asset `db:"-" json:"logo,omitempty"`
}

func (m *Release) TableName() string {
Expand Down Expand Up @@ -105,5 +111,44 @@ func (m *Release) Expand(dao *daos.Dao, e ExpandMap) error {
}
}

if _, exist := e["front"]; exist {
front, err := FindAssetById(dao, m.FrontId)
if err != nil {
return err
}
if front != nil {
if err := front.Expand(dao, e["front"]); err != nil {
return err
}
m.Front = front
}
}

if _, exist := e["banner"]; exist {
banner, err := FindAssetById(dao, m.BannerId)
if err != nil {
return err
}
if banner != nil {
if err := banner.Expand(dao, e["banner"]); err != nil {
return err
}
m.Banner = banner
}
}

if _, exist := e["logo"]; exist {
logo, err := FindAssetById(dao, m.LogoId)
if err != nil {
return err
}
if logo != nil {
if err := logo.Expand(dao, e["logo"]); err != nil {
return err
}
m.Logo = logo
}
}

return nil
}

0 comments on commit 338cf7f

Please sign in to comment.