@@ -0,0 +1,56 @@
|
||||
package officialWebsitemod
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
// JobList 招聘页岗位列表
|
||||
// 表: official_website_job_list
|
||||
type Job struct {
|
||||
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
|
||||
Title string `json:"title" bson:"title"`
|
||||
Description string `json:"description" bson:"description"`
|
||||
Requirements string `json:"requirements" bson:"requirements"`
|
||||
Benefits string `json:"benefits" bson:"benefits"`
|
||||
JDUrl string `json:"jdUrl" bson:"jdUrl"`
|
||||
SortModel `bson:",inline"`
|
||||
BaseModel `bson:",inline"`
|
||||
}
|
||||
|
||||
func (j *Job) tableName() string { return tableJobList }
|
||||
|
||||
func (j *Job) FindOne(filter M) error {
|
||||
return findOneByTable(j.tableName(), &j, filter)
|
||||
}
|
||||
|
||||
func (j *Job) FindMany(filter M, opts ...*options.FindOptions) ([]Job, error) {
|
||||
out := make([]Job, 0)
|
||||
err := findManyByTable(j.tableName(), &out, filter, opts...)
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (j *Job) Count(filter M) (int64, error) {
|
||||
return countByTable(j.tableName(), filter)
|
||||
}
|
||||
|
||||
func (j *Job) Create() error {
|
||||
j.CreatedAt = time.Now().UTC()
|
||||
j.UpdatedAt = j.CreatedAt
|
||||
id, err := createByTable(j.tableName(), j)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
j.ID = id
|
||||
return nil
|
||||
}
|
||||
|
||||
func (j *Job) Update(filter M, update M) (int64, error) {
|
||||
return updateByTable(j.tableName(), filter, update)
|
||||
}
|
||||
|
||||
func (j *Job) Delete(filter M) (int64, error) {
|
||||
return deleteByTable(j.tableName(), filter)
|
||||
}
|
||||
Reference in New Issue
Block a user