mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
Add gallery
This commit is contained in:
@@ -21,6 +21,7 @@ type Resource struct {
|
||||
Downloads uint
|
||||
Comments uint
|
||||
ModifiedTime time.Time
|
||||
Gallery []uint `gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
@@ -52,6 +53,7 @@ type ResourceDetailView struct {
|
||||
Downloads uint `json:"downloads"`
|
||||
Comments uint `json:"comments"`
|
||||
Related []ResourceView `json:"related"`
|
||||
Gallery []uint `json:"gallery"`
|
||||
}
|
||||
|
||||
func (r *Resource) ToView() ResourceView {
|
||||
@@ -104,5 +106,6 @@ func (r *Resource) ToDetailView() ResourceDetailView {
|
||||
Views: r.Views,
|
||||
Downloads: r.Downloads,
|
||||
Comments: r.Comments,
|
||||
Gallery: r.Gallery,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ type ResourceParams struct {
|
||||
Tags []uint `json:"tags"`
|
||||
Article string `json:"article"`
|
||||
Images []uint `json:"images"`
|
||||
Gallery []uint `json:"gallery"`
|
||||
}
|
||||
|
||||
func CreateResource(uid uint, params *ResourceParams) (uint, error) {
|
||||
@@ -62,6 +63,7 @@ func CreateResource(uid uint, params *ResourceParams) (uint, error) {
|
||||
Images: images,
|
||||
Tags: tags,
|
||||
UserID: uid,
|
||||
Gallery: params.Gallery,
|
||||
}
|
||||
if r, err = dao.CreateResource(r); err != nil {
|
||||
return 0, err
|
||||
@@ -452,6 +454,7 @@ func EditResource(uid, rid uint, params *ResourceParams) error {
|
||||
r.AlternativeTitles = params.AlternativeTitles
|
||||
r.Article = params.Article
|
||||
r.Links = params.Links
|
||||
r.Gallery = params.Gallery
|
||||
|
||||
images := make([]model.Image, len(params.Images))
|
||||
for i, id := range params.Images {
|
||||
|
||||
Reference in New Issue
Block a user