package rcrt import ( "errors" "hongze/hrms_api/models/rcrt" "hongze/hrms_api/utils" ) func HrEmailAdd(req *rcrt.HrEmailAddReq) (err error, errMsg string) { item := new(rcrt.HrEmail) //判断邮箱是否已绑定 _, err = item.GetHrEmailByEmail(req.Email) if err != nil { if err ==utils.ErrNoRow { err = nil }else{ errMsg = "查询hr邮箱出错" err = errors.New(errMsg+"Err:" + err.Error()) return } }else{ //该流程已存在 errMsg = "该邮箱已存在" err = errors.New(errMsg) return } // todo 校验邮箱密码是否正确 //添加邮箱 item.Email = req.Email item.AdminId = req.AdminId item.EmailPwd = req.EmailPwd err = item.Add() if err !=nil { errMsg = "添加邮箱出错" err = errors.New(errMsg+"Err:" + err.Error()) return } return } func HrEmailEdit(req *rcrt.HrEmailEditReq) (err error, errMsg string) { item := new(rcrt.HrEmail) //判断邮箱是否存在 info, err := item.GetHrEmailById(req.HrEmailId) if err != nil { if err == utils.ErrNoRow { errMsg = "该邮箱不存在或者已经被删除" err = errors.New(errMsg+"Err:" + err.Error()) return } errMsg = "查询邮箱出错" err = errors.New(errMsg+"Err:" + err.Error()) return } //判断邮箱是否已绑定 var updateStr []string if info.Email != req.Email { _, err = item.GetHrEmailByEmail(req.Email) if err != nil { if err ==utils.ErrNoRow { err = nil }else{ errMsg = "查询hr邮箱出错" err = errors.New(errMsg+"Err:" + err.Error()) return } }else{ //该流程已存在 errMsg = "该邮箱已存在" err = errors.New(errMsg) return } // todo 校验邮箱密码是否正确 updateStr = append(updateStr, "email") } if info.EmailPwd != req.EmailPwd { updateStr = append(updateStr, "email_pwd") } if info.AdminId != req.AdminId { updateStr = append(updateStr, "admin_id") } if len(updateStr) == 0 { return } //添加邮箱 info.Email = req.Email info.AdminId = req.AdminId info.EmailPwd = req.EmailPwd err = info.Update(updateStr) if err !=nil { errMsg = "更新邮箱出错" err = errors.New(errMsg+"Err:" + err.Error()) return } return }