sso

base_controller.go 581B

12345678910111213141516171819202122232425262728293031323334
  1. package controllers
  2. import (
  3. "github.com/astaxie/beego"
  4. )
  5. type BaseController struct {
  6. beego.Controller
  7. }
  8. // 设置模板
  9. // 第一个参数模板,第二个参数为layout
  10. func (c *BaseController) SetTpl(template ...string) {
  11. var tplName string
  12. layout := ""
  13. switch {
  14. case len(template) == 1:
  15. tplName = template[0]
  16. case len(template) == 2:
  17. tplName = template[0]
  18. layout = template[1]
  19. default:
  20. tplName = "index.tpl"
  21. }
  22. c.Layout = layout
  23. c.TplName = tplName
  24. }
  25. // 重定向
  26. func (c *BaseController) Redirect302(url string) {
  27. c.Redirect(url, 302)
  28. c.StopRun()
  29. }