cv.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package rcrt
  2. import (
  3. "hongze/hrms_api/global"
  4. "hongze/hrms_api/models/base"
  5. "time"
  6. )
  7. // 简历表
  8. type Cv struct {
  9. CvId int64 `gorm:"primaryKey;column:cv_id" json:"cv_id"` //简历ID
  10. CvTitle string `gorm:"column:cv_title" json:"cv_title"` //简历标题
  11. CvName string `gorm:"column:cv_name" json:"cv_name"` //求职者姓名
  12. CvUrl string `gorm:"column:cv_url" json:"cv_url"` //简历地址
  13. ReceiveTime time.Time `gorm:"column:receive_time" json:"receive_time"` //投递时间
  14. HrEmailId int `gorm:"column:hr_email_id" json:"hr_email_id"` //关联的hr邮箱序号
  15. Status int8 `gorm:"column:status" json:"status"` //筛选状态:0未处理,1通过,2淘汰
  16. ResultAdminId uint64 `gorm:"column:result_admin_id" json:"result_admin_id"` //设置初筛的管理员账号
  17. HrEmail string `gorm:"column:hr_email" json:"hr_email"` //关联的hr邮箱地址
  18. Position string `gorm:"column:position" json:"position"` //应聘职位
  19. FromEmail string `gorm:"column:from_email" json:"from_email"` //邮件发送者
  20. CvFileName string `gorm:"column:cv_file_name" json:"cv_file_name"` //简历文件名
  21. base.TimeBase
  22. }
  23. // TableName get sql table name.获取数据库表名
  24. func (c *Cv) TableName() string {
  25. return "rcrt_cv"
  26. }
  27. type CvListTmpItem struct {
  28. Cv
  29. HrName string `json:"hr_name"`
  30. HrAdminId int64 `json:"hr_admin_id"`
  31. }
  32. type CvListItem struct {
  33. CvId int64 `json:"cv_id"` //简历ID
  34. CvTitle string `json:"cv_title"` //简历标题
  35. CvName string `json:"cv_name"` //求职者姓名
  36. CvUrl string `json:"cv_url"` //简历地址
  37. HrEmailId int `json:"hr_email_id"` //关联的hr邮箱序号
  38. Status int8 `json:"status"` //筛选状态:0未处理,1通过,2淘汰
  39. ResultAdminId uint64 `json:"result_admin_id"` //设置初筛的管理员账号
  40. HrEmail string `json:"hr_email"` //关联的hr邮箱地址
  41. HrName string `json:"hr_name"`
  42. HrAdminId int64 `json:"hr_admin_id"`
  43. Position string `json:"position"` //应聘职位
  44. CvFileName string `json:"cv_file_name"` //简历文件名
  45. CreateTime string `json:"create_time"` //创建时间
  46. ModifyTime string `json:"modify_time"` //最后更新时间
  47. }
  48. type CvListReq struct {
  49. CreateTime string `json:"create_time" form:"create_time" binding:"omitempty,datetime=2006-01-02"` //投递时间
  50. HrAdminIds string `json:"hr_admin_ids" form:"hr_admin_ids"` //hr账号ID数组
  51. base.PageReq
  52. }
  53. type CvResultReq struct {
  54. CvId int64 `json:"cv_id"`
  55. Status int8 `json:"status" binding:"oneof=1 2"` //筛选状态:0未处理,1通过,2淘汰
  56. }
  57. type CvDelReq struct {
  58. CvId int64 `json:"cv_id" binding:"required,gte=1"` //简历ID
  59. }
  60. func (c *Cv) SelectPage(page base.IPage, condition string, pars []interface{}) (count int64, results []*CvListTmpItem, err error) {
  61. results = make([]*CvListTmpItem, 0)
  62. query := global.DEFAULT_MYSQL.
  63. Table("rcrt_cv as cv ").
  64. Select("cv.*, a.real_name as hr_name, a.admin_id as hr_admin_id").
  65. Joins("Left JOIN rcrt_hr_email e ON e.hr_email_id = cv.hr_email_id").
  66. Joins("Left JOIN sys_admin a ON a.admin_id = e.admin_id").
  67. Where(condition, pars...)
  68. query.Count(&count)
  69. if len(page.GetOrderItemsString()) > 0 {
  70. query = query.Order(page.GetOrderItemsString())
  71. }
  72. err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&results).Error
  73. return
  74. }
  75. // Add 新增
  76. func (c *Cv) Add() (err error) {
  77. err = global.DEFAULT_MYSQL.Create(c).Error
  78. return
  79. }
  80. func (c *Cv) AddInBatches(list []*Cv) (err error) {
  81. err = global.DEFAULT_MYSQL.CreateInBatches(list, len(list)).Error
  82. return
  83. }
  84. // 修改
  85. func (c *Cv) Update(updateCols []string) (err error) {
  86. err = global.DEFAULT_MYSQL.Model(c).Select(updateCols).Updates(c).Error
  87. return
  88. }
  89. // 删除
  90. func (c *Cv) Delete() (err error) {
  91. err = global.DEFAULT_MYSQL.Delete(c).Error
  92. return
  93. }
  94. func (c *Cv) GetCvByCvId(cvId int64) (item *Cv, err error) {
  95. err = global.DEFAULT_MYSQL.Model(c).Where("cv_id = ? ", cvId).First(&item).Error
  96. return
  97. }
  98. func (c *Cv) GetCvListByCondition(condition string, pars []interface{}) (results []*Cv, err error) {
  99. results = make([]*Cv, 0)
  100. err = global.DEFAULT_MYSQL.Model(c).
  101. Where(condition, pars...).Find(&results).Error
  102. return
  103. }