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" "strings" "time" ) type CvController struct {} func (cv *CvController) List(c *gin.Context) { req := new(rcrt.CvListReq) 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.Cv) condition := "cv.status=0" var pars []interface{} var total int64 var tmpList []*rcrt.CvListTmpItem var list []*rcrt.CvListItem if req.CreateTime != "" { createTime, _ := time.Parse(utils.FormatDate, req.CreateTime) nextTime := createTime.AddDate(0,0,1) condition += " and cv.receive_time >= ? and cv.receive_time < ?" pars = append(pars, req.CreateTime, nextTime) } if req.HrAdminIds != "" { adminIds := strings.Split(req.HrAdminIds,",") condition += " and a.admin_id in ?" pars = append(pars, adminIds) } page.AddOrderItem(base.OrderItem{Column: "cv.receive_time", Asc: false}) page.AddOrderItem(base.OrderItem{Column: "cv.cv_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.CvListItem{ CvId: v.CvId, CvTitle: v.CvTitle, CvName: v.CvName, CvFileName: v.CvFileName, CvUrl: v.CvUrl, HrEmailId: v.HrEmailId, Status: v.Status, ResultAdminId: v.ResultAdminId, HrEmail: v.HrEmail, HrName: v.HrName, HrAdminId: v.HrAdminId, Position: v.Position, CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.ReceiveTime), ModifyTime: utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime), } list = append(list, tmp) } } page.SetTotal(total) baseData := new(base.BaseData) baseData.SetPage(page) baseData.SetList(list) resp.OkData("获取成功", baseData, c) } // SetResult 设置初筛结果 func (cv *CvController) SetResult(c *gin.Context) { req := new(rcrt.CvResultReq) 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.SetCvResult(adminInfo, req) if err != nil { resp.FailMsg(errMsg, err.Error(), c) return } resp.Ok("设置成功", c) return } // Delete 简历 func (cv *CvController) Delete(c *gin.Context) { req := new(rcrt.CvDelReq) err := c.ShouldBind(&req) if err != nil { resp.FailData("参数解析失败", "Err:"+err.Error(), c) return } item := new(rcrt.Cv) //判断简历是否存在 cvInfo, err := item.GetCvByCvId(req.CvId) if err != nil { if err == utils.ErrNoRow { resp.Fail("简历不存在或者已经被删除", c) return } resp.FailMsg("查询简历出错", "Err:"+err.Error(), c) return } if cvInfo.Status != 0 { //resp.Fail("简历状态已更新,请刷新", c) resp.Ok("删除成功", c) return } err = cvInfo.Delete() if err != nil { resp.FailMsg("删除失败", "删除失败,Err:"+err.Error(), c) return } resp.Ok("删除成功", c) }