package routers

import (
	"SCRM/controllers/admin_user"
	"SCRM/controllers/article"
	"SCRM/controllers/global"
	"SCRM/controllers/kefu"
	"SCRM/controllers/login"
	"SCRM/controllers/marketing_tool"
	"SCRM/controllers/members"
	"SCRM/controllers/mpwechat"
	"SCRM/controllers/role"
	"SCRM/controllers/sms"
	"SCRM/controllers/staff"

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

func init() {
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowOrigins:     []string{"http://jk.kuyicloud.com", "http://localhost:8090", "http://test1.sgjyun.com", "https://www.ucpaas.com"},
		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		AllowCredentials: true,
	}))

	global.RegisterRouters()
	admin_user.RegisterRouters()
	login.RegisterRouters()
	role.RegisterRouters()
	members.RegisterRouters()
	marketing_tool.RegisterRouters()
	article.RegisterRouters()
	mpwechat.RegisterRouters()
	sms.RegisterRouters()
	staff.RegisterRouters()
	kefu.RegisterRouters()
}