nsfw images

This commit is contained in:
2025-11-02 19:51:33 +08:00
parent a7f1bcb365
commit 853647edbc
6 changed files with 91 additions and 9 deletions

View File

@@ -22,6 +22,7 @@ type Resource struct {
Comments uint
ModifiedTime time.Time
Gallery []uint `gorm:"serializer:json"`
GalleryNsfw []uint `gorm:"serializer:json"`
}
type Link struct {
@@ -54,6 +55,7 @@ type ResourceDetailView struct {
Comments uint `json:"comments"`
Related []ResourceView `json:"related"`
Gallery []uint `json:"gallery"`
GalleryNsfw []uint `json:"galleryNsfw"`
}
func (r *Resource) ToView() ResourceView {
@@ -107,5 +109,6 @@ func (r *Resource) ToDetailView() ResourceDetailView {
Downloads: r.Downloads,
Comments: r.Comments,
Gallery: r.Gallery,
GalleryNsfw: r.GalleryNsfw,
}
}

View File

@@ -28,6 +28,7 @@ type ResourceParams struct {
Article string `json:"article"`
Images []uint `json:"images"`
Gallery []uint `json:"gallery"`
GalleryNsfw []uint `json:"gallery_nsfw"`
}
func CreateResource(uid uint, params *ResourceParams) (uint, error) {
@@ -64,6 +65,7 @@ func CreateResource(uid uint, params *ResourceParams) (uint, error) {
Tags: tags,
UserID: uid,
Gallery: params.Gallery,
GalleryNsfw: params.GalleryNsfw,
}
if r, err = dao.CreateResource(r); err != nil {
return 0, err
@@ -455,6 +457,7 @@ func EditResource(uid, rid uint, params *ResourceParams) error {
r.Article = params.Article
r.Links = params.Links
r.Gallery = params.Gallery
r.GalleryNsfw = params.GalleryNsfw
images := make([]model.Image, len(params.Images))
for i, id := range params.Images {