package officialWebsitemod import ( "time" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo/options" ) // Album 创作者专辑 // 表: official_website_album type Album struct { ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` HeroID primitive.ObjectID `json:"heroID" bson:"heroID"` //创作者ID Title string `json:"title" bson:"title"` SeoSlug string `json:"seoSlug" bson:"seoSlug,omitempty"` // SEO 语义化唯一标识(纯小写字母) Description string `json:"description" bson:"description"` Cover string `json:"cover" bson:"cover"` IsHot bool `json:"isHot" bson:"isHot"` Tags []Tag `json:"tags" bson:"tags"` SortModel `bson:",inline"` BaseModel `bson:",inline"` } func (a *Album) tableName() string { return tableAlbum } func (a *Album) FindOne(filter M) error { return findOneByTable(a.tableName(), a, filter) } func (a *Album) FindMany(filter M, opts ...*options.FindOptions) ([]Album, error) { out := make([]Album, 0) err := findManyByTable(a.tableName(), &out, filter, opts...) return out, err } func (a *Album) Count(filter M) (int64, error) { return countByTable(a.tableName(), filter) } func (a *Album) Create() error { a.CreatedAt = time.Now().UTC() a.UpdatedAt = a.CreatedAt id, err := createByTable(a.tableName(), a) if err != nil { return err } a.ID = id return nil } func (a Album) Update(filter M, update M) (int64, error) { return updateByTable(a.tableName(), filter, update) } func (a Album) Delete(filter M) (int64, error) { return deleteByTable(a.tableName(), filter) }