out_cv.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package rcrt
  2. import (
  3. "hongze/hrms_api/global"
  4. "hongze/hrms_api/models/base"
  5. "time"
  6. )
  7. type OutCv struct {
  8. Id int64 `gorm:"primaryKey;column:id" json:"id"`
  9. CvId int64 `gorm:"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. AdminId uint64 `gorm:"column:admin_id" json:"admin_id"` //设置淘汰的管理员账号
  14. OutTime time.Time `gorm:"column:out_time" json:"out_time"` //淘汰时间
  15. OutStage int8 `gorm:"column:out_stage" json:"out_stage"` //第几轮淘汰:1,2,3
  16. CvFileName string `gorm:"column:cv_file_name" json:"cv_file_name"` //简历文件名
  17. Position string `gorm:"column:position" json:"position"` //应聘职位
  18. ProcessId int64 `gorm:"column:process_id" json:"process_id"` //流程ID
  19. ProcessStage int8 `gorm:"column:process_stage" json:"process_stage"` //流程进行到第几轮:0:无, 1:第一轮面试;2:第二轮面试;3:第三轮面试
  20. Enabled int8 `gorm:"column:enabled" json:"enabled"` //是否启用,1:启用,0:禁用
  21. base.TimeBase
  22. }
  23. // TableName get sql table name.获取数据库表名
  24. func (c *OutCv) TableName() string {
  25. return "rcrt_out_cv"
  26. }
  27. type OutCvListTmpItem struct {
  28. OutCv
  29. AdminName string `json:"admin_name"`
  30. ReceiveTime time.Time `json:"receive_time"` //投递时间
  31. }
  32. type OutCvListItem struct {
  33. Id int64 `json:"id"`
  34. CvId int64 `json:"cv_id"` //简历ID
  35. CvTitle string `json:"cv_title"` //简历标题
  36. CvName string `json:"cv_name"` //求职者姓名
  37. CvUrl string `json:"cv_url"` //简历地址
  38. CvFileName string `json:"cv_file_name"` //简历文件名
  39. Position string `json:"position"` //应聘职位
  40. AdminId uint64 `json:"admin_id"` //设置淘汰的管理员账号
  41. OutTime string `json:"out_time"` //淘汰时间
  42. OutStage int8 `json:"out_stage"` //第几轮淘汰:0:(取消面试), 1,2,3,4,
  43. AdminName string `json:"admin_name"`
  44. CreateTime string `json:"create_time"` //创建时间
  45. ModifyTime string `json:"modify_time"` //最后更新时间
  46. ProcessStage int8 `json:"process_stage"` //流程进行到第几轮:0:无, 1:第一轮面试;2:第二轮面试;3:第三轮面试
  47. }
  48. type OutCvListReq struct {
  49. OutTime string `json:"out_time" form:"out_time" binding:"omitempty,datetime=2006-01-02"` //淘汰时间
  50. AdminId int64 `json:"admin_id" form:"admin_id"` //hr账号ID
  51. base.PageReq
  52. }
  53. type OutCvDelReq struct {
  54. Id int64 `json:"id" binding:"required,gte=1"`
  55. }
  56. func (c *OutCv) SelectPage(page base.IPage, condition string, pars []interface{}) (count int64, results []*OutCvListTmpItem, err error) {
  57. query := global.DEFAULT_MYSQL.
  58. Table("rcrt_out_cv as ov ").
  59. Select("ov.*, a.real_name as admin_name, cv.receive_time").
  60. Joins("Left JOIN rcrt_cv cv ON cv.cv_id = ov.cv_id").
  61. Joins("Left JOIN sys_admin a ON a.admin_id = ov.admin_id").
  62. Where(condition, pars...)
  63. query.Count(&count)
  64. if len(page.GetOrderItemsString()) > 0 {
  65. query = query.Order(page.GetOrderItemsString())
  66. }
  67. err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&results).Error
  68. return
  69. }
  70. type OutCvAdminItem struct {
  71. AdminId uint64 `json:"admin_id"` //账号id
  72. RealName string `json:"real_name"` //真实姓名
  73. }
  74. func (c *OutCv) GetAdmins() (list []*OutCvAdminItem, err error) {
  75. err = global.DEFAULT_MYSQL.Model(c).
  76. Table("rcrt_out_cv as oc ").
  77. Select("distinct a.admin_id, a.real_name").
  78. Joins("Left JOIN sys_admin a ON oc.admin_id = a.admin_id").
  79. Where("a.enabled = 1").
  80. Find(&list).Error
  81. return
  82. }
  83. // Add 新增
  84. func (c *OutCv) Add() (err error) {
  85. err = global.DEFAULT_MYSQL.Create(c).Error
  86. return
  87. }
  88. // 修改
  89. func (c *OutCv) Update(updateCols []string) (err error) {
  90. err = global.DEFAULT_MYSQL.Model(c).Select(updateCols).Updates(c).Error
  91. return
  92. }
  93. // 删除
  94. func (c *OutCv) Delete() (err error) {
  95. err = global.DEFAULT_MYSQL.Delete(c).Error
  96. return
  97. }
  98. func (c *OutCv) GetOutCvById(id int64) (item *OutCv, err error) {
  99. err = global.DEFAULT_MYSQL.Model(c).Where("id = ? AND enabled = 1 ", id).First(&item).Error
  100. return
  101. }
  102. func (c *OutCv) GetOutCvByCvId(cvId int64) (item *OutCv, err error) {
  103. err = global.DEFAULT_MYSQL.Model(c).Where("cv_id = ? AND enabled = 1 ", cvId).First(&item).Error
  104. return
  105. }
  106. // OutCvResetReq 重置流程请求
  107. type OutCvResetReq struct {
  108. CvId int64 `json:"cv_id"` //简历id
  109. Stage int8 `json:"stage" binding:"oneof=0 1 2 3"` //第几轮面试的确认操作:1,2,3
  110. }