123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- 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)
- }
|