/*
 * @description: 路由配置
 * @Author: CP
 * @Date: 2020-08-23 21:32:54
 * @FilePath: \design_quantity\web\routes\routes.go
 */
package routes

import (
	"github.com/kataras/iris/v12/mvc"
	"go.mod/bootstrap"
	"go.mod/services"
	"go.mod/web/api"
)

func Configure(b *bootstrap.Bootstrapper) {
	//service加载
	ProjectAccountService := services.NewProjectAccountService()
	LoginService := services.NewLoginService()
	ProjectService := services.NewProjectService()
	TreeService := services.NewTreeService()
	BidsectionService := services.NewBidsectionService()
	BidAccountService := services.NewBidAccountService()
	ContractService := services.NewContractService()

	//CSRF相关
	// b.Use(middleware.SetCsrf)

	//b.Party("/", protect)
	//protect := NewCsrf()

	// apiTree.Router.Use(middleware.JwtAuth().Serve)
	// 接口相关
	// 登陆接口
	apiLogin := mvc.New(b.Party("/api/login"))
	apiLogin.Register(LoginService)
	apiLogin.Handle(new(api.LoginApi))

	// 项目账号相关接口
	apiProjectAccount := mvc.New(b.Party("/api/projectAccount"))
	apiProjectAccount.Register(ProjectAccountService)
	apiProjectAccount.Handle(new(api.ProjectAccountApi))

	// 标段相关接口
	apiBidsection := mvc.New(b.Party("/api/bidsection"))
	apiBidsection.Register(BidsectionService)
	apiBidsection.Handle(new(api.BidsectionApi))

	// 项目设置接口
	apiSetting := mvc.New(b.Party("/api/projectSetting"))
	apiSetting.Register(ProjectAccountService)
	apiSetting.Register(ProjectService)
	apiSetting.Register(BidAccountService)
	apiSetting.Handle(new(api.ProjectSettingApi))

	// TreeNode相关接口
	apiTree := mvc.New(b.Party("/api/tree"))
	apiTree.Register(TreeService)
	apiTree.Handle(new(api.TreeApi))

	// 合同管理
	apiContract := mvc.New(b.Party("/api/contract"))
	apiContract.Register(TreeService)
	apiContract.Register(ContractService)
	// 中间件
	apiContract.Handle(new(api.ContractApi))

	// oss相关
	apiOss := mvc.New(b.Party("/api/oss"))
	apiOss.Handle(new(api.OssApi))

}
