report_approve.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package report_approve
  2. import (
  3. "encoding/json"
  4. "eta/eta_mobile/controllers"
  5. "eta/eta_mobile/models"
  6. "eta/eta_mobile/models/report_approve"
  7. "eta/eta_mobile/services"
  8. )
  9. // ReportApproveController 报告审批
  10. type ReportApproveController struct {
  11. controllers.BaseAuthController
  12. }
  13. // CheckApproveOpen
  14. // @Title 校验分类是否开启审批
  15. // @Description 校验分类是否开启审批
  16. // @Param request body report_approve.ReportApproveCheckApproveOpenReq true "type json string"
  17. // @Success 200 string "操作成功"
  18. // @router /classify/check_open [post]
  19. func (this *ReportApproveController) CheckApproveOpen() {
  20. br := new(models.BaseResponse).Init()
  21. defer func() {
  22. if br.ErrMsg == "" {
  23. br.IsSendEmail = false
  24. }
  25. this.Data["json"] = br
  26. this.ServeJSON()
  27. }()
  28. sysUser := this.SysUser
  29. if sysUser == nil {
  30. br.Msg = "请登录"
  31. br.ErrMsg = "请登录,SysUser Is Empty"
  32. br.Ret = 408
  33. return
  34. }
  35. var req report_approve.ReportApproveCheckApproveOpenReq
  36. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  37. br.Msg = "参数有误"
  38. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  39. return
  40. }
  41. // 校验是否开启了审批流
  42. opening, e := services.CheckReportOpenApprove(req.ReportType, req.ClassifyFirstId, req.ClassifySecondId, req.ClassifyThirdId)
  43. if e != nil {
  44. br.Msg = "操作失败"
  45. br.ErrMsg = "校验报告是否开启审批流失败, Err: " + e.Error()
  46. return
  47. }
  48. br.Data = opening
  49. br.Ret = 200
  50. br.Success = true
  51. br.Msg = "操作成功"
  52. }