123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- package rcrt
- import (
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- "hongze/hrms_api/controller/resp"
- "hongze/hrms_api/global"
- "hongze/hrms_api/models/base"
- "hongze/hrms_api/models/rcrt"
- "hongze/hrms_api/models/system"
- rcrtService "hongze/hrms_api/services/rcrt"
- "hongze/hrms_api/utils"
- "strconv"
- "time"
- )
- type ProcessController struct{}
- func (p *ProcessController) List(c *gin.Context) {
- req := new(rcrt.ProcessListReq)
- err := c.BindQuery(&req)
- if err != nil {
- errs, ok := err.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- return
- }
- page := new(base.Page)
- page.SetPageSize(req.PageSize)
- page.SetCurrent(req.Current)
- item := new(rcrt.Process)
- condition := "1=1"
- var pars []interface{}
- var total int64
- var tmpList []*rcrt.ProcessListTmpItem
- list := make([]*rcrt.ProcessListItem, 0)
- if req.Status == "" {
- condition += " and p.status != " + strconv.Itoa(utils.RcrtProcessStatusOut) + " and p.status != " + strconv.Itoa(utils.RcrtProcessStatusWPass)
- } else {
- condition += " and p.status =?"
- pars = append(pars, req.Status)
- }
- if req.FirstTime != "" {
- condition += " and p.first_time >= ?"
- pars = append(pars, req.FirstTime)
- }
- if req.SecondTime != "" {
- condition += " and p.second_time >= ?"
- pars = append(pars, req.SecondTime)
- }
- page.AddOrderItem(base.OrderItem{Column: "p.create_time", Asc: false})
- page.AddOrderItem(base.OrderItem{Column: "p.process_id", Asc: false})
- total, tmpList, err = item.SelectPage(page, condition, pars)
- if err != nil {
- resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- tmp := &rcrt.ProcessListItem{
- ProcessId: v.ProcessId,
- CvId: v.CvId,
- CvName: v.CvName,
- CvUrl: v.CvUrl,
- Status: v.Status,
- FirstTime: utils.TimeTransferString(utils.FormatDateTime, v.FirstTime),
- FirstDetail: v.FirstDetail,
- FirstRemark: v.FirstRemark,
- FirstAdminId: v.FirstAdminId,
- FirstResultTime: utils.TimeTransferString(utils.FormatDateTime, v.FirstResultTime),
- FirstResult: v.FirstResult,
- FirstRecommend: v.FirstRecommend,
- FirstResultAdminId: v.FirstResultAdminId,
- SecondTime: utils.TimeTransferString(utils.FormatDateTime, v.SecondTime),
- SecondVideoUrl: v.SecondVideoUrl,
- SecondRemark: v.SecondRemark,
- SecondAdminId: v.SecondAdminId,
- SecondResultTime: utils.TimeTransferString(utils.FormatDateTime, v.SecondResultTime),
- SecondResult: v.SecondResult,
- SecondRecommend: v.SecondRecommend,
- SecondResultAdminId: v.SecondAdminId,
- ThirdResult: v.ThirdResult,
- ThirdResultTime: utils.TimeTransferString(utils.FormatDateTime, v.ThirdResultTime),
- ThirdResultAdminId: v.ThirdResultAdminId,
- CvFileName: v.CvFileName,
- CvTitle: v.CvTitle,
- PersonTest: v.PersonTest,
- CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.ReceiveTime),
- ModifyTime: utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime),
- }
- list = append(list, tmp)
- }
- }
- go rcrtService.DealPersonTest()
- page.SetTotal(total)
- baseData := new(base.BaseData)
- baseData.SetPage(page)
- baseData.SetList(list)
- resp.OkData("获取成功", baseData, c)
- }
- // SetFirstRecommend 设置一面信息
- func (p *ProcessController) SetFirstRecommend(c *gin.Context) {
- req := new(rcrt.ProcessFirstRecommendReq)
- err := c.ShouldBind(&req)
- if err != nil {
- errs, ok := err.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- return
- }
- claims, _ := c.Get("adminInfo")
- adminInfo := claims.(*system.SysAdmin)
- err, errMsg := rcrtService.SetProcessFirstRecommend(adminInfo, req)
- if err != nil {
- resp.FailMsg(errMsg, err.Error(), c)
- return
- }
- resp.Ok("设置成功", c)
- return
- }
- // SetFirstRecommend 设置二面信息
- func (p *ProcessController) SetSecondRecommend(c *gin.Context) {
- req := new(rcrt.ProcessSecondRecommendReq)
- err := c.ShouldBind(&req)
- if err != nil {
- errs, ok := err.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- return
- }
- claims, _ := c.Get("adminInfo")
- adminInfo := claims.(*system.SysAdmin)
- err, errMsg := rcrtService.SetProcessSecondRecommend(adminInfo, req)
- if err != nil {
- resp.FailMsg(errMsg, err.Error(), c)
- return
- }
- resp.Ok("设置成功", c)
- return
- }
- // SetResult 一面确认/二面确认/三面确认
- func (p *ProcessController) SetResult(c *gin.Context) {
- req := new(rcrt.ProcessResultReq)
- err := c.ShouldBind(&req)
- if err != nil {
- errs, ok := err.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- return
- }
- claims, _ := c.Get("adminInfo")
- adminInfo := claims.(*system.SysAdmin)
- err, errMsg := rcrtService.SetProcessResult(adminInfo, req)
- if err != nil {
- resp.FailMsg(errMsg, err.Error(), c)
- return
- }
- resp.Ok("确认成功", c)
- return
- }
- // Delete 简历
- func (p *ProcessController) Delete(c *gin.Context) {
- req := new(rcrt.ProcessDelReq)
- err := c.ShouldBind(&req)
- if err != nil {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- item := new(rcrt.Process)
- processInfo, err := item.GetProcessByProcessId(req.ProcessId)
- if err != nil {
- if err == utils.ErrNoRow {
- resp.Fail("该流程不存在或者已经被删除", c)
- return
- }
- resp.FailData("查询流程出错", "Err:"+err.Error(), c)
- return
- }
- if processInfo.Status == utils.RcrtProcessStatusOut {
- //resp.Fail("该流程状态已更新,请刷新", c)
- resp.Ok("删除成功", c)
- return
- }
- item.ProcessId = req.ProcessId
- err = item.Delete()
- if err != nil {
- resp.FailMsg("删除失败", "删除失败,Err:"+err.Error(), c)
- return
- }
- resp.Ok("删除成功", c)
- }
- // Cancel 取消面试
- func (p *ProcessController) Cancel(c *gin.Context) {
- req := new(rcrt.ProcessDelReq)
- err := c.ShouldBind(&req)
- if err != nil {
- errs, ok := err.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- return
- }
- claims, _ := c.Get("adminInfo")
- adminInfo := claims.(*system.SysAdmin)
- err, errMsg := rcrtService.SetProcessCancel(adminInfo, req)
- if err != nil {
- resp.FailMsg(errMsg, err.Error(), c)
- return
- }
- resp.Ok("取消成功", c)
- }
- // PassList 通过简历列表
- func (p *ProcessController) PassList(c *gin.Context) {
- req := new(rcrt.ProcessPassListReq)
- err := c.BindQuery(&req)
- if err != nil {
- errs, ok := err.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- return
- }
- page := new(base.Page)
- page.SetPageSize(req.PageSize)
- page.SetCurrent(req.Current)
- item := new(rcrt.Process)
- condition := "1=1"
- var pars []interface{}
- var total int64
- var tmpList []*rcrt.ProcessListTmpItem
- list := make([]*rcrt.ProcessPassListItem, 0)
- condition += " and p.status =?"
- pars = append(pars, utils.RcrtProcessStatusWPass)
- if req.PassTime != "" {
- outTime, _ := time.Parse(utils.FormatDate, req.PassTime)
- nextTime := outTime.AddDate(0, 0, 1)
- condition += " and p.third_result_time >= ? and p.third_result_time < ?"
- pars = append(pars, req.PassTime, nextTime)
- }
- if req.AdminId > 0 {
- condition += " and p.third_result_admin_id = ?"
- pars = append(pars, req.AdminId)
- }
- page.AddOrderItem(base.OrderItem{Column: "p.create_time", Asc: false})
- page.AddOrderItem(base.OrderItem{Column: "p.process_id", Asc: false})
- total, tmpList, err = item.PassSelectPage(page, condition, pars)
- if err != nil {
- resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- tmp := &rcrt.ProcessPassListItem{
- ProcessId: v.ProcessId,
- CvId: v.CvId,
- CvName: v.CvName,
- CvUrl: v.CvUrl,
- PassTime: utils.TimeTransferString(utils.FormatDateTime, v.ThirdResultTime),
- AdminId: v.ThirdResultAdminId,
- AdminName: v.AdminName,
- CvFileName: v.CvFileName,
- CvTitle: v.CvTitle,
- Position: v.Position,
- CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.ReceiveTime),
- }
- list = append(list, tmp)
- }
- }
- page.SetTotal(total)
- baseData := new(base.BaseData)
- baseData.SetPage(page)
- baseData.SetList(list)
- resp.OkData("获取成功", baseData, c)
- }
- func (ov *ProcessController) PassAdminList(c *gin.Context) {
- item := new(rcrt.Process)
- list, err := item.GetThirdAdmins()
- if err != nil {
- resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
- return
- }
- baseData := new(base.BaseOnlyData)
- baseData.SetList(list)
- resp.OkData("获取成功", baseData, c)
- }
- func (p *ProcessController) Reset(c *gin.Context) {
- req := new(rcrt.ProcessResetReq)
- err := c.ShouldBind(&req)
- if err != nil {
- errs, ok := err.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- return
- }
- claims, _ := c.Get("adminInfo")
- adminInfo := claims.(*system.SysAdmin)
- err, errMsg := rcrtService.ResetProcess(adminInfo, 0, req.ProcessId, req.Stage)
- if err != nil {
- resp.FailMsg(errMsg, err.Error(), c)
- return
- }
- resp.Ok("确认成功", c)
- return
- }
|