scrm-go

error_controller.go 830B

12345678910111213141516171819202122232425262728293031323334353637
  1. package global
  2. import (
  3. base_ctl "SCRM/controllers"
  4. "SCRM/enums"
  5. "fmt"
  6. "github.com/astaxie/beego"
  7. )
  8. func ErrorCtlRegistRouters() {
  9. beego.Router("/error", &ErrorViewController{}, "get:HandleError")
  10. }
  11. type ErrorViewController struct {
  12. base_ctl.BaseViewController
  13. }
  14. // /handle_error [get]
  15. // @param code:int
  16. func (this *ErrorViewController) HandleError() {
  17. code, _ := this.GetInt("code")
  18. if code == enums.ErrorCodeNeverCreateTypeApp {
  19. ssoDomain := beego.AppConfig.String("sso_domain")
  20. createAppURL := fmt.Sprintf("%v/org/app/create", ssoDomain)
  21. this.Redirect302(createAppURL)
  22. } else if code == enums.ErrorCodeContactSuperAdminCreateTypeApp {
  23. ssoDomain := beego.AppConfig.String("sso_domain")
  24. hitURL := fmt.Sprintf("%v/create_app_hint", ssoDomain)
  25. this.Redirect302(hitURL)
  26. } else {
  27. this.Abort404()
  28. }
  29. }