package routers

import (
	"SSO/controllers"
	"SSO/service"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
)

func init() {
	// var filter = func(ctx *context.Context) {
	// 	utils.TraceLog("current session id: %v", ctx.Input.CruSession.SessionID())
	// }
	// beego.InsertFilter("/*", beego.BeforeExec, filter)

	beego.ErrorController(&controllers.ErrorController{})

	beego.Router("/", &controllers.IndexController{}, "get:Index")
	beego.Router("/scrm", &controllers.IndexController{}, "get:SCRMIndex")
	beego.Router("/mmall", &controllers.IndexController{}, "get:MircoMallIndex")
	beego.Router("/xt", &controllers.IndexController{}, "get:XTIndex")
	beego.Router("/cdm", &controllers.IndexController{}, "get:CDMIndex")

	beego.Router("/login", &controllers.LoginController{}, "get:PwdLogin")
	beego.Router("/login/submit", &controllers.LoginController{}, "post:PwdLoginSubmit")
	beego.Router("/login/code", &controllers.LoginController{}, "get:CodeLogin")
	beego.Router("/login/code/submit", &controllers.LoginController{}, "post:CodeLoginSubmit")
	beego.Router("/verifytoken", &controllers.VerifyTokenController{}, "post:VerifyToken")

	beego.Router("/logout", &controllers.LoginController{}, "get:Logout")

	beego.Router("/register", &controllers.RegisterController{}, "get:Register")
	beego.Router("/register/submit", &controllers.RegisterController{}, "post:RegisterSubmit")

	beego.Router("/password/forget", &controllers.ForgetPwdController{}, "get:ForgetPassword")
	beego.Router("/password/modify", &controllers.ForgetPwdController{}, "post:ModifyPassword")

	beego.Router("/getcode", &controllers.CodeController{}, "*:Post")
	beego.Router("/getregistcode", &controllers.CodeController{}, "*:RegistCode")

	beego.Router("/org/create", &controllers.OrgController{}, "get:Create")
	beego.Router("/org/create/submit", &controllers.OrgController{}, "post:CreateSubmit")
	beego.Router("/org/admin/apps", &controllers.OrgController{}, "get:ViewApps")
	beego.Router("/org/app/create", &controllers.OrgController{}, "get:CreateApp")
	// beego.Router("/org/app/create/submit", &controllers.OrgController{}, "post:CreateAppSubmit")
	beego.Router("/get_org_cat", &controllers.OrgCategoryController{}, "get:GetOrgCategories")
	beego.Router("/create_app_hint", &controllers.OrgController{}, "get:CreateAppHint")

	beego.Router("/province", &controllers.DistrictController{}, "get:GetProvinces")
	beego.Router("/city", &controllers.DistrictController{}, "get:GetCities")
	beego.Router("/district", &controllers.DistrictController{}, "get:GetDistricts")

	beego.Router("/ueditor_config", &controllers.UeditorController{}, "*:GetUeditorConfig")
	beego.Router("/application/qntoken", &controllers.UeditorController{}, "get:GetQNToken")

	beego.Get("/down/kuyicloud", func(ctx *context.Context) {
		url := service.GetDownUrl()
		ctx.Redirect(302, url)
	})

	beego.Router("/m/login/pwd", &controllers.MobileLoginController{}, "post:LoginByPwd")

}
