mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
feat: add release date field to resource models and parameters
This commit is contained in:
@@ -44,6 +44,7 @@ export interface CreateResourceParams {
|
|||||||
title: string;
|
title: string;
|
||||||
alternative_titles: string[];
|
alternative_titles: string[];
|
||||||
links: RLink[];
|
links: RLink[];
|
||||||
|
release_date?: string;
|
||||||
tags: number[];
|
tags: number[];
|
||||||
article: string;
|
article: string;
|
||||||
images: number[];
|
images: number[];
|
||||||
@@ -77,6 +78,7 @@ export interface Resource {
|
|||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
|
release_date?: string;
|
||||||
tags: Tag[];
|
tags: Tag[];
|
||||||
image?: Image;
|
image?: Image;
|
||||||
author: User;
|
author: User;
|
||||||
@@ -89,6 +91,7 @@ export interface ResourceDetails {
|
|||||||
links: RLink[];
|
links: RLink[];
|
||||||
article: string;
|
article: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
releaseDate?: string;
|
||||||
tags: Tag[];
|
tags: Tag[];
|
||||||
images: Image[];
|
images: Image[];
|
||||||
files: RFile[];
|
files: RFile[];
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type Resource struct {
|
|||||||
Title string
|
Title string
|
||||||
AlternativeTitles []string `gorm:"serializer:json"`
|
AlternativeTitles []string `gorm:"serializer:json"`
|
||||||
Links []Link `gorm:"serializer:json"`
|
Links []Link `gorm:"serializer:json"`
|
||||||
|
ReleaseDate *time.Time
|
||||||
Article string
|
Article string
|
||||||
Images []Image `gorm:"many2many:resource_images;"`
|
Images []Image `gorm:"many2many:resource_images;"`
|
||||||
Tags []Tag `gorm:"many2many:resource_tags;"`
|
Tags []Tag `gorm:"many2many:resource_tags;"`
|
||||||
@@ -35,6 +36,7 @@ type ResourceView struct {
|
|||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
ReleaseDate *time.Time `json:"release_date,omitempty"`
|
||||||
Tags []TagView `json:"tags"`
|
Tags []TagView `json:"tags"`
|
||||||
Image *ImageView `json:"image"`
|
Image *ImageView `json:"image"`
|
||||||
Author UserView `json:"author"`
|
Author UserView `json:"author"`
|
||||||
@@ -47,6 +49,7 @@ type ResourceDetailView struct {
|
|||||||
Links []Link `json:"links"`
|
Links []Link `json:"links"`
|
||||||
Article string `json:"article"`
|
Article string `json:"article"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
ReleaseDate *time.Time `json:"releaseDate,omitempty"`
|
||||||
Tags []TagView `json:"tags"`
|
Tags []TagView `json:"tags"`
|
||||||
Images []ImageView `json:"images"`
|
Images []ImageView `json:"images"`
|
||||||
Files []FileView `json:"files"`
|
Files []FileView `json:"files"`
|
||||||
@@ -84,6 +87,7 @@ func (r *Resource) ToView() ResourceView {
|
|||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
Title: r.Title,
|
Title: r.Title,
|
||||||
CreatedAt: r.CreatedAt,
|
CreatedAt: r.CreatedAt,
|
||||||
|
ReleaseDate: r.ReleaseDate,
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Image: image,
|
Image: image,
|
||||||
Author: r.User.ToView(),
|
Author: r.User.ToView(),
|
||||||
@@ -115,6 +119,7 @@ func (r *Resource) ToDetailView() ResourceDetailView {
|
|||||||
Links: r.Links,
|
Links: r.Links,
|
||||||
Article: r.Article,
|
Article: r.Article,
|
||||||
CreatedAt: r.CreatedAt,
|
CreatedAt: r.CreatedAt,
|
||||||
|
ReleaseDate: r.ReleaseDate,
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Images: images,
|
Images: images,
|
||||||
Files: files,
|
Files: files,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type ResourceParams struct {
|
|||||||
Title string `json:"title" binding:"required"`
|
Title string `json:"title" binding:"required"`
|
||||||
AlternativeTitles []string `json:"alternative_titles"`
|
AlternativeTitles []string `json:"alternative_titles"`
|
||||||
Links []model.Link `json:"links"`
|
Links []model.Link `json:"links"`
|
||||||
|
ReleaseDate *time.Time `json:"release_date"`
|
||||||
Tags []uint `json:"tags"`
|
Tags []uint `json:"tags"`
|
||||||
Article string `json:"article"`
|
Article string `json:"article"`
|
||||||
Images []uint `json:"images"`
|
Images []uint `json:"images"`
|
||||||
@@ -106,6 +107,7 @@ func CreateResource(uid uint, params *ResourceParams) (uint, error) {
|
|||||||
AlternativeTitles: params.AlternativeTitles,
|
AlternativeTitles: params.AlternativeTitles,
|
||||||
Article: params.Article,
|
Article: params.Article,
|
||||||
Links: params.Links,
|
Links: params.Links,
|
||||||
|
ReleaseDate: params.ReleaseDate,
|
||||||
Images: images,
|
Images: images,
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
UserID: uid,
|
UserID: uid,
|
||||||
@@ -533,6 +535,7 @@ func UpdateResource(uid, rid uint, params *ResourceParams) error {
|
|||||||
r.AlternativeTitles = params.AlternativeTitles
|
r.AlternativeTitles = params.AlternativeTitles
|
||||||
r.Article = params.Article
|
r.Article = params.Article
|
||||||
r.Links = params.Links
|
r.Links = params.Links
|
||||||
|
r.ReleaseDate = params.ReleaseDate
|
||||||
r.Gallery = gallery
|
r.Gallery = gallery
|
||||||
r.GalleryNsfw = nsfw
|
r.GalleryNsfw = nsfw
|
||||||
r.Characters = characters
|
r.Characters = characters
|
||||||
|
|||||||
Reference in New Issue
Block a user