Files
huangguo_server/models/v/officialWebsitemod/business.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

55 lines
1.7 KiB
Go

package officialWebsitemod
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options"
)
type BusinessData struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
Title string `json:"title" bson:"title"`
Description string `json:"description" bson:"description"`
Type string `json:"type" bson:"type"` // 业务类型,如"adPlacement", "contentProduction", "subRevenue"
ServiceOverview string `json:"serviceOverview" bson:"serviceOverview"`
CollaborationProcess string `json:"collaborationProcess" bson:"collaborationProcess"`
CaseStudies string `json:"caseStudies" bson:"caseStudies"`
BaseModel `bson:",inline"`
}
func (b *BusinessData) tableName() string { return tableBusiness }
func (b *BusinessData) FindOne(filter M) error {
return findOneByTable(b.tableName(), &b, filter)
}
func (b *BusinessData) FindMany(filter M, opts ...*options.FindOptions) ([]BusinessData, error) {
out := make([]BusinessData, 0)
err := findManyByTable(b.tableName(), &out, filter, opts...)
return out, err
}
func (b *BusinessData) Count(filter M) (int64, error) {
return countByTable(b.tableName(), filter)
}
func (b BusinessData) Create() error {
b.CreatedAt = time.Now().UTC()
b.UpdatedAt = b.CreatedAt
id, err := createByTable(b.tableName(), b)
if err != nil {
return err
}
b.ID = id
return nil
}
func (b *BusinessData) Update(filter M, update M) (int64, error) {
return updateByTable(b.tableName(), filter, update)
}
func (b *BusinessData) Delete(filter M) (int64, error) {
return deleteByTable(b.tableName(), filter)
}