package rcrt import ( "hongze/hrms_api/global" "hongze/hrms_api/models/base" "time" ) // 简历表 type Cv struct { CvId int64 `gorm:"primaryKey;column:cv_id" json:"cv_id"` //简历ID CvTitle string `gorm:"column:cv_title" json:"cv_title"` //简历标题 CvName string `gorm:"column:cv_name" json:"cv_name"` //求职者姓名 CvUrl string `gorm:"column:cv_url" json:"cv_url"` //简历地址 ReceiveTime time.Time `gorm:"column:receive_time" json:"receive_time"` //投递时间 HrEmailId int `gorm:"column:hr_email_id" json:"hr_email_id"` //关联的hr邮箱序号 Status int8 `gorm:"column:status" json:"status"` //筛选状态:0未处理,1通过,2淘汰 ResultAdminId uint64 `gorm:"column:result_admin_id" json:"result_admin_id"` //设置初筛的管理员账号 HrEmail string `gorm:"column:hr_email" json:"hr_email"` //关联的hr邮箱地址 Position string `gorm:"column:position" json:"position"` //应聘职位 FromEmail string `gorm:"column:from_email" json:"from_email"` //邮件发送者 CvFileName string `gorm:"column:cv_file_name" json:"cv_file_name"` //简历文件名 base.TimeBase } // TableName get sql table name.获取数据库表名 func (c *Cv) TableName() string { return "rcrt_cv" } type CvListTmpItem struct { Cv HrName string `json:"hr_name"` HrAdminId int64 `json:"hr_admin_id"` } type CvListItem struct { CvId int64 `json:"cv_id"` //简历ID CvTitle string `json:"cv_title"` //简历标题 CvName string `json:"cv_name"` //求职者姓名 CvUrl string `json:"cv_url"` //简历地址 HrEmailId int `json:"hr_email_id"` //关联的hr邮箱序号 Status int8 `json:"status"` //筛选状态:0未处理,1通过,2淘汰 ResultAdminId uint64 `json:"result_admin_id"` //设置初筛的管理员账号 HrEmail string `json:"hr_email"` //关联的hr邮箱地址 HrName string `json:"hr_name"` HrAdminId int64 `json:"hr_admin_id"` Position string `json:"position"` //应聘职位 CvFileName string `json:"cv_file_name"` //简历文件名 CreateTime string `json:"create_time"` //创建时间 ModifyTime string `json:"modify_time"` //最后更新时间 } type CvListReq struct { CreateTime string `json:"create_time" form:"create_time" binding:"omitempty,datetime=2006-01-02"` //投递时间 HrAdminIds string `json:"hr_admin_ids" form:"hr_admin_ids"` //hr账号ID数组 base.PageReq } type CvResultReq struct { CvId int64 `json:"cv_id"` Status int8 `json:"status" binding:"oneof=1 2"` //筛选状态:0未处理,1通过,2淘汰 } type CvDelReq struct { CvId int64 `json:"cv_id" binding:"required,gte=1"` //简历ID } func (c *Cv) SelectPage(page base.IPage, condition string, pars []interface{}) (count int64, results []*CvListTmpItem, err error) { results = make([]*CvListTmpItem, 0) query := global.DEFAULT_MYSQL. Table("rcrt_cv as cv "). Select("cv.*, a.real_name as hr_name, a.admin_id as hr_admin_id"). Joins("Left JOIN rcrt_hr_email e ON e.hr_email_id = cv.hr_email_id"). Joins("Left JOIN sys_admin a ON a.admin_id = e.admin_id"). Where(condition, pars...) query.Count(&count) if len(page.GetOrderItemsString()) > 0 { query = query.Order(page.GetOrderItemsString()) } err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&results).Error return } // Add 新增 func (c *Cv) Add() (err error) { err = global.DEFAULT_MYSQL.Create(c).Error return } func (c *Cv) AddInBatches(list []*Cv) (err error) { err = global.DEFAULT_MYSQL.CreateInBatches(list, len(list)).Error return } // 修改 func (c *Cv) Update(updateCols []string) (err error) { err = global.DEFAULT_MYSQL.Model(c).Select(updateCols).Updates(c).Error return } // 删除 func (c *Cv) Delete() (err error) { err = global.DEFAULT_MYSQL.Delete(c).Error return } func (c *Cv) GetCvByCvId(cvId int64) (item *Cv, err error) { err = global.DEFAULT_MYSQL.Model(c).Where("cv_id = ? ", cvId).First(&item).Error return } func (c *Cv) GetCvListByCondition(condition string, pars []interface{}) (results []*Cv, err error) { results = make([]*Cv, 0) err = global.DEFAULT_MYSQL.Model(c). Where(condition, pars...).Find(&results).Error return }