This commit is contained in:
2025-11-16 18:46:22 +08:00
parent 9d9a2545f9
commit 46a19c12fa
12 changed files with 101 additions and 101 deletions

View File

@@ -1,6 +1,6 @@
package model
type Charactor struct {
type Character struct {
ID uint `gorm:"primaryKey;autoIncrement"`
Name string `gorm:"type:varchar(100);not null"`
Alias []string `gorm:"serializer:json"`
@@ -11,7 +11,7 @@ type Charactor struct {
Image *Image `gorm:"foreignKey:ImageID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}
type CharactorView struct {
type CharacterView struct {
Id uint `json:"id"`
Name string `json:"name"`
Alias []string `json:"alias"`
@@ -20,8 +20,8 @@ type CharactorView struct {
Image uint `json:"image"`
}
func (c *Charactor) ToView() *CharactorView {
return &CharactorView{
func (c *Character) ToView() *CharacterView {
return &CharacterView{
Id: c.ID,
Name: c.Name,
Alias: c.Alias,
@@ -31,7 +31,7 @@ func (c *Charactor) ToView() *CharactorView {
}
}
func (c *Charactor) Equal(other *Charactor) bool {
func (c *Character) Equal(other *Character) bool {
if c.Name != other.Name || c.CV != other.CV || c.Role != other.Role || c.ImageID != other.ImageID {
return false
}

View File

@@ -23,7 +23,7 @@ type Resource struct {
ModifiedTime time.Time
Gallery []uint `gorm:"serializer:json"`
GalleryNsfw []uint `gorm:"serializer:json"`
Charactors []Charactor `gorm:"foreignKey:ResourceID"`
Characters []Character `gorm:"foreignKey:ResourceID"`
}
type Link struct {
@@ -57,7 +57,7 @@ type ResourceDetailView struct {
Related []ResourceView `json:"related"`
Gallery []uint `json:"gallery"`
GalleryNsfw []uint `json:"galleryNsfw"`
Charactors []CharactorView `json:"charactors"`
Characters []CharacterView `json:"characters"`
}
func (r *Resource) ToView() ResourceView {
@@ -96,9 +96,9 @@ func (r *Resource) ToDetailView() ResourceDetailView {
for i, file := range r.Files {
files[i] = *file.ToView()
}
charactors := make([]CharactorView, len(r.Charactors))
for i, charactor := range r.Charactors {
charactors[i] = *charactor.ToView()
characters := make([]CharacterView, len(r.Characters))
for i, character := range r.Characters {
characters[i] = *character.ToView()
}
return ResourceDetailView{
ID: r.ID,
@@ -116,6 +116,6 @@ func (r *Resource) ToDetailView() ResourceDetailView {
Comments: r.Comments,
Gallery: r.Gallery,
GalleryNsfw: r.GalleryNsfw,
Charactors: charactors,
Characters: characters,
}
}