// @APIVersion 1.0.0
// @Title sws xcx api doc
// @Description 圣卫士小程序API接口文档
// @License 领透科技
package routers

import (
	"sws_xcx/controllers"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/plugins/cors"
)

func init() {
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		// AllowAllOrigins:  true,
		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://sws.kuyicloud.com", "http://localhost:9539", "http://127.0.0.1:9539", "http://xcx.sgjyun.com"},
		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission"},
		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		AllowCredentials: true,
	}))

	ns :=
		beego.NewNamespace("/xcx",
			beego.NSNamespace("/api/user",
				beego.NSInclude(
					&controllers.LoginApiController{},
					&controllers.UserApiController{},
				),
			),
			beego.NSNamespace("/api/device",
				beego.NSInclude(
					&controllers.MessageApiControllor{},
				)),
			beego.NSNamespace("/api/sysdic",
				beego.NSInclude(
					&controllers.SysDicApiController{},
				)),
		)
	beego.AddNamespace(ns)
	controllers.ApiControllersRegisterRouters()
}
