package routers

import (
	"eta/eta_mini_crm_ht/controllers"
	beego "github.com/beego/beego/v2/server/web"
	"github.com/beego/beego/v2/server/web/filter/cors"
)

func init() {
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins:  true,
		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
		AllowHeaders:     []string{"Origin", "Authorization", "Uuid", "Accesstoken", "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,
	}))
	ns := beego.NewNamespace("/adminapi",
		beego.NSNamespace("/sys_user",
			beego.NSInclude(
				&controllers.UserLoginController{},
				&controllers.SysUserController{},
			),
		),
		beego.NSNamespace("/department",
			beego.NSInclude(
				&controllers.SysDepartmentController{},
			),
		),
		beego.NSNamespace("/role",
			beego.NSInclude(
				&controllers.SysRoleController{},
			),
		),
		beego.NSNamespace("/chart_permission",
			beego.NSInclude(
				&controllers.ChartPermissionController{},
			),
		),
		beego.NSNamespace("/user",
			beego.NSInclude(
				&controllers.UserController{},
			),
		),
		beego.NSNamespace("/sys_message",
			beego.NSInclude(
				&controllers.SysMessageReportController{},
			),
		),

		beego.NSNamespace("/classify",
			beego.NSInclude(
				&controllers.ClassifyController{},
			),
		),
		beego.NSNamespace("/read",
			beego.NSInclude(
				&controllers.UserReadRecordController{},
			),
		),
		beego.NSNamespace("/feedBack",
			beego.NSInclude(
				&controllers.FeedBackController{},
			),
		),
		beego.NSNamespace("/analyst",
			beego.NSInclude(
				&controllers.AnalystController{},
			),
		),
		beego.NSNamespace("/media",
			beego.NSInclude(
				//&controllers.ImagePDFController{},
				&controllers.AudioController{},
				&controllers.VideoController{},
			),
		),
		beego.NSNamespace("/source",
			beego.NSInclude(
				&controllers.ImageController{},
			),
		),
		beego.NSNamespace("/message",
			beego.NSInclude(
				&controllers.MessageController{},
			),
		),
	)
	beego.AddNamespace(ns)
}
