out_cv.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package rcrt
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/go-playground/validator/v10"
  5. "hongze/hrms_api/controller/resp"
  6. "hongze/hrms_api/global"
  7. "hongze/hrms_api/models/base"
  8. "hongze/hrms_api/models/rcrt"
  9. "hongze/hrms_api/models/system"
  10. rcrtService "hongze/hrms_api/services/rcrt"
  11. "hongze/hrms_api/utils"
  12. "time"
  13. )
  14. type OutCvController struct{}
  15. func (ov *OutCvController) List(c *gin.Context) {
  16. req := new(rcrt.OutCvListReq)
  17. err := c.BindQuery(&req)
  18. if err != nil {
  19. errs, ok := err.(validator.ValidationErrors)
  20. if !ok {
  21. resp.FailData("参数解析失败", "Err:"+err.Error(), c)
  22. return
  23. }
  24. resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
  25. return
  26. }
  27. page := new(base.Page)
  28. page.SetPageSize(req.PageSize)
  29. page.SetCurrent(req.Current)
  30. item := new(rcrt.OutCv)
  31. condition := "1=1 AND ov.enabled = 1 "
  32. var pars []interface{}
  33. var total int64
  34. var tmpList []*rcrt.OutCvListTmpItem
  35. list := make([]*rcrt.OutCvListItem, 0)
  36. if req.OutTime != "" {
  37. outTime, _ := time.Parse(utils.FormatDate, req.OutTime)
  38. nextTime := outTime.AddDate(0, 0, 1)
  39. condition += " and ov.out_time >= ? and ov.out_time < ?"
  40. pars = append(pars, req.OutTime, nextTime)
  41. }
  42. if req.AdminId > 0 {
  43. // adminIds := strings.Split(req.AdminIds,",")
  44. condition += " and ov.admin_id = ?"
  45. pars = append(pars, req.AdminId)
  46. }
  47. page.AddOrderItem(base.OrderItem{Column: "ov.create_time", Asc: false})
  48. page.AddOrderItem(base.OrderItem{Column: "ov.id", Asc: false})
  49. total, tmpList, err = item.SelectPage(page, condition, pars)
  50. if err != nil {
  51. resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
  52. return
  53. }
  54. if len(tmpList) > 0 {
  55. for _, v := range tmpList {
  56. tmp := &rcrt.OutCvListItem{
  57. Id: v.Id,
  58. CvId: v.CvId,
  59. CvTitle: v.CvTitle,
  60. CvName: v.CvName,
  61. CvUrl: v.CvUrl,
  62. CvFileName: v.CvFileName,
  63. Position: v.Position,
  64. AdminId: v.AdminId,
  65. OutTime: utils.TimeTransferString(utils.FormatDateTime, v.OutTime),
  66. OutStage: v.OutStage,
  67. AdminName: v.AdminName,
  68. CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.ReceiveTime),
  69. ModifyTime: utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime),
  70. ProcessStage: v.ProcessStage,
  71. }
  72. list = append(list, tmp)
  73. }
  74. }
  75. page.SetTotal(total)
  76. baseData := new(base.BaseData)
  77. baseData.SetPage(page)
  78. baseData.SetList(list)
  79. resp.OkData("获取成功", baseData, c)
  80. }
  81. // Delete 简历
  82. func (ov *OutCvController) Delete(c *gin.Context) {
  83. req := new(rcrt.OutCvDelReq)
  84. err := c.ShouldBind(&req)
  85. if err != nil {
  86. resp.FailData("参数解析失败", "Err:"+err.Error(), c)
  87. return
  88. }
  89. item := new(rcrt.OutCv)
  90. item.Id = req.Id
  91. err = item.Delete()
  92. if err != nil {
  93. resp.FailMsg("删除失败", "删除失败,Err:"+err.Error(), c)
  94. return
  95. }
  96. resp.Ok("删除成功", c)
  97. }
  98. func (ov *OutCvController) AdminList(c *gin.Context) {
  99. item := new(rcrt.OutCv)
  100. list, err := item.GetAdmins()
  101. if err != nil {
  102. resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
  103. return
  104. }
  105. baseData := new(base.BaseOnlyData)
  106. baseData.SetList(list)
  107. resp.OkData("获取成功", baseData, c)
  108. }
  109. func (p *OutCvController) Reset(c *gin.Context) {
  110. req := new(rcrt.OutCvResetReq)
  111. err := c.ShouldBind(&req)
  112. if err != nil {
  113. errs, ok := err.(validator.ValidationErrors)
  114. if !ok {
  115. resp.FailData("参数解析失败", "Err:"+err.Error(), c)
  116. return
  117. }
  118. resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
  119. return
  120. }
  121. claims, _ := c.Get("adminInfo")
  122. adminInfo := claims.(*system.SysAdmin)
  123. err, errMsg := rcrtService.ResetProcess(adminInfo, req.CvId, 0, req.Stage)
  124. if err != nil {
  125. resp.FailMsg(errMsg, err.Error(), c)
  126. return
  127. }
  128. resp.Ok("重置成功", c)
  129. return
  130. }