router.go 1.2 KB
package routers

import (
	"oppmg/controllers"

	"oppmg/middleware"

	"github.com/astaxie/beego"
)

func init() {
	nsV1 := beego.NewNamespace("v1",
		beego.NSBefore(middleware.LogRequestData, middleware.AuthToken),
		beego.NSNamespace("/company",
			beego.NSRouter("/department", &controllers.CompanyController{}, "post:DepartmentAdd"),
			beego.NSRouter("/department", &controllers.CompanyController{}, "put:DepartmentUpdate"),
			beego.NSRouter("/department", &controllers.CompanyController{}, "delete:DepartmentDelete"),
			beego.NSRouter("/position", &controllers.CompanyController{}, "post:PositionAdd"),
			beego.NSRouter("/position", &controllers.CompanyController{}, "put:PositionEdit"),
		),
		beego.NSNamespace("/rbac",
			beego.NSRouter("/role", &controllers.RbacController{}, "post:RoleAdd"),
			beego.NSRouter("/role", &controllers.RbacController{}, "put:RoleUpdate"),
			beego.NSRouter("/role", &controllers.RbacController{}, "delete:RoleDelete"),
		),
	)

	nsAuth := beego.NewNamespace("/auth",
		beego.NSBefore(middleware.LogRequestData, middleware.AuthToken),
		beego.NSRouter("/accessToken", &controllers.AuthController{}, "post:AccessToken"),
	)
	beego.AddNamespace(nsV1)
	beego.AddNamespace(nsAuth)

}