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" "time" ) type OutCvController struct{} func (ov *OutCvController) List(c *gin.Context) { req := new(rcrt.OutCvListReq) 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.OutCv) condition := "1=1 AND ov.enabled = 1 " var pars []interface{} var total int64 var tmpList []*rcrt.OutCvListTmpItem list := make([]*rcrt.OutCvListItem, 0) if req.OutTime != "" { outTime, _ := time.Parse(utils.FormatDate, req.OutTime) nextTime := outTime.AddDate(0, 0, 1) condition += " and ov.out_time >= ? and ov.out_time < ?" pars = append(pars, req.OutTime, nextTime) } if req.AdminId > 0 { // adminIds := strings.Split(req.AdminIds,",") condition += " and ov.admin_id = ?" pars = append(pars, req.AdminId) } page.AddOrderItem(base.OrderItem{Column: "ov.create_time", Asc: false}) page.AddOrderItem(base.OrderItem{Column: "ov.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.OutCvListItem{ Id: v.Id, CvId: v.CvId, CvTitle: v.CvTitle, CvName: v.CvName, CvUrl: v.CvUrl, CvFileName: v.CvFileName, Position: v.Position, AdminId: v.AdminId, OutTime: utils.TimeTransferString(utils.FormatDateTime, v.OutTime), OutStage: v.OutStage, AdminName: v.AdminName, CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.ReceiveTime), ModifyTime: utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime), ProcessStage: v.ProcessStage, } list = append(list, tmp) } } page.SetTotal(total) baseData := new(base.BaseData) baseData.SetPage(page) baseData.SetList(list) resp.OkData("获取成功", baseData, c) } // Delete 简历 func (ov *OutCvController) Delete(c *gin.Context) { req := new(rcrt.OutCvDelReq) err := c.ShouldBind(&req) if err != nil { resp.FailData("参数解析失败", "Err:"+err.Error(), c) return } item := new(rcrt.OutCv) item.Id = req.Id err = item.Delete() if err != nil { resp.FailMsg("删除失败", "删除失败,Err:"+err.Error(), c) return } resp.Ok("删除成功", c) } func (ov *OutCvController) AdminList(c *gin.Context) { item := new(rcrt.OutCv) list, err := item.GetAdmins() if err != nil { resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c) return } baseData := new(base.BaseOnlyData) baseData.SetList(list) resp.OkData("获取成功", baseData, c) } func (p *OutCvController) Reset(c *gin.Context) { req := new(rcrt.OutCvResetReq) 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, req.CvId, 0, req.Stage) if err != nil { resp.FailMsg(errMsg, err.Error(), c) return } resp.Ok("重置成功", c) return }