Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
package officialWebsitemod
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options"
)
type Photograph struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
HeroID primitive.ObjectID `json:"heroId" bson:"heroId"`
Name string `json:"name" bson:"name"`
SeoSlug string `json:"seoSlug" bson:"seoSlug,omitempty"` // SEO 语义化唯一标识(纯小写字母)
Description string `json:"description" bson:"description"`
Cover string `json:"cover" bson:"cover"`
Photos []string `json:"photos" bson:"photos"`
Tags []Tag `json:"tags" bson:"tags"`
SortModel `bson:",inline"`
BaseModel `bson:",inline"`
}
func (p *Photograph) tableName() string {
return tablePhotograph
}
func (p *Photograph) FindOne(filter M) error {
return findOneByTable(p.tableName(), p, filter)
}
func (p *Photograph) FindMany(filter M, opts ...*options.FindOptions) ([]Photograph, error) {
out := make([]Photograph, 0)
err := findManyByTable(p.tableName(), &out, filter, opts...)
return out, err
}
func (p *Photograph) Count(filter M) (int64, error) {
return countByTable(p.tableName(), filter)
}
func (p *Photograph) Create() error {
p.CreatedAt = time.Now().UTC()
p.UpdatedAt = p.CreatedAt
id, err := createByTable(p.tableName(), p)
if err != nil {
return err
}
p.ID = id
return nil
}
func (p *Photograph) Update(filter M, update M) (int64, error) {
return updateByTable(p.tableName(), filter, update)
}
func (p *Photograph) Delete(filter M) (int64, error) {
return deleteByTable(p.tableName(), filter)
}