package controllers import ( "encoding/json" "hongze/hongze_api/models" "hongze/hongze_api/services" ) //报告 type YbApplyController struct { BaseAuthController } // @Title 申请 // @Description 发起申请接口 // @Success 200 // @router /ybApply [post] func (this *YbApplyController) YbApply() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req models.YbApplyReq err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } if req.CompanyName == "" { br.Msg = "公司名称不能为空" return } if req.RealName == "" { req.RealName = user.RealName } if req.RealName == "" { br.Msg = "姓名不能为空" return } err, brMsg, brErrMsg := services.AddYbApply(user.UserId, user.CompanyId, user.Mobile, user.Email, req) if err != nil || brMsg != ""{ if brMsg != ""{ br.Msg = brMsg br.ErrMsg = brErrMsg return }else{ br.Msg = "申请失败" br.ErrMsg = "申请失败" + err.Error() return } } br.Ret = 200 br.Success = true br.Msg = "操作成功" br.Data = nil }