You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

84 lines
2.0 KiB

package model
import (
"context"
"gorm.io/gorm"
)
type (
jobList1Model interface {
Insert(ctx context.Context, data *JobList1) error
Update(ctx context.Context, jobId string, updates map[string]any) error
Delete(ctx context.Context, jobId string) error
FindOne(ctx context.Context, jobId string) (*JobList1, error)
FindTitle(ctx context.Context, title string) (*JobList1, error)
}
JobList1 struct {
updates map[string]any
JobId string `gorm:"column:jobId"`
Title string `gorm:"column:title"`
}
defaultJobList1Model struct {
db *gorm.DB
}
)
func (s *JobList1) TableName() string {
return "job_list1"
}
func NewJobList1() *JobList1 {
return &JobList1{
updates: make(map[string]any),
}
}
func (s *JobList1) SetJobId(jobId string) *JobList1 {
s.JobId = jobId
s.set("jobId", jobId)
return s
}
func (s *JobList1) SetTitle(title string) *JobList1 {
s.Title = title
s.set("title", title)
return s
}
func (s *JobList1) set(key string, val any) {
s.updates[key] = val
}
func (s *JobList1) UpdateColumn() map[string]any {
return s.updates
}
func newJobList1DAO(db *gorm.DB) *defaultJobList1Model {
return &defaultJobList1Model{
db: db,
}
}
func (s *defaultJobList1Model) Insert(ctx context.Context, data *JobList1) error {
return s.db.Create(data).Error
}
func (s *defaultJobList1Model) Update(ctx context.Context, jobId string, updates map[string]any) error {
return s.db.Model(JobList1{}).Where("jobId=?", jobId).Updates(updates).Error
}
func (s *defaultJobList1Model) Delete(ctx context.Context, jobId string) error {
return s.db.Where("jobId=?", jobId).Delete(&JobList1{}).Error
}
func (s *defaultJobList1Model) FindOne(ctx context.Context, jobId string) (*JobList1, error) {
row := JobList1{}
err := s.db.Where("jobId=?", jobId).Find(&row).Error
return findResultWithError(&row, err)
}
func (s *defaultJobList1Model) FindTitle(ctx context.Context, title string) (*JobList1, error) {
row := JobList1{}
err := s.db.Where("title=?", title).Find(&row).Error
return findResultWithError(&row, err)
}