@@ -0,0 +1,57 @@
|
||||
package officialWebsitemod
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
// RecruitForm 招募页面表单
|
||||
// 表: official_website_recruit_form
|
||||
type RecruitForm struct {
|
||||
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
|
||||
Name string `json:"name" bson:"name"`
|
||||
Sex int `json:"sex" bson:"sex"`
|
||||
Age int `json:"age" bson:"age"`
|
||||
Country string `json:"country" bson:"country"`
|
||||
Address string `json:"address" bson:"address"`
|
||||
Contact []ContactInfo `json:"contact" bson:"contact"`
|
||||
Description string `json:"description" bson:"description"`
|
||||
BaseModel `bson:",inline"`
|
||||
}
|
||||
|
||||
func (r *RecruitForm) tableName() string { return tableRecruitForm }
|
||||
|
||||
func (r *RecruitForm) FindOne(filter M) error {
|
||||
return findOneByTable(r.tableName(), &r, filter)
|
||||
}
|
||||
|
||||
func (r *RecruitForm) FindMany(filter M, opts ...*options.FindOptions) ([]RecruitForm, error) {
|
||||
out := make([]RecruitForm, 0)
|
||||
err := findManyByTable(r.tableName(), &out, filter, opts...)
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (r *RecruitForm) Count(filter M) (int64, error) {
|
||||
return countByTable(r.tableName(), filter)
|
||||
}
|
||||
|
||||
func (r *RecruitForm) Create() error {
|
||||
r.CreatedAt = time.Now().UTC()
|
||||
r.UpdatedAt = r.CreatedAt
|
||||
id, err := createByTable(r.tableName(), r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.ID = id
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RecruitForm) Update(filter M, update M) (int64, error) {
|
||||
return updateByTable(r.tableName(), filter, update)
|
||||
}
|
||||
|
||||
func (r *RecruitForm) Delete(filter M) (int64, error) {
|
||||
return deleteByTable(r.tableName(), filter)
|
||||
}
|
||||
Reference in New Issue
Block a user