package router

import (
	"cold-delivery/app/admin/controller"
	"cold-delivery/common/actions"
	"github.com/gin-gonic/gin"
	jwt "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth"
)

func init() {
	routerCheckRole = append(routerCheckRole, registerIceRaftRouter)
}

// 需认证的路由代码
func registerIceRaftRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	cont := controller.IceRaftController{}
	r := v1.Group("/ice-raft").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction())
	{
		r.GET("", cont.GetPage)
		r.GET("/newest-record", cont.GetNewestRecordPage)
		r.GET("/:id", cont.Get)
		r.GET("/code/:code", cont.GetByCode)
		r.POST("", cont.Insert)
		r.PUT("", cont.Update)
		r.DELETE("", cont.Delete)
		r.POST("/in-storage", cont.InStorage)
		r.POST("/out-storage", cont.OutStorage)
		r.GET("/newest-record-sse", cont.GetNewestRecordPageSSE)
		r.GET("/cooler-box", cont.GetPageByCoolerBoxId)
		r.POST("/isoutstorage", cont.IsOutStorage)
		r.POST("/bindCoolerBox", cont.BindCoolerBox)
		r.POST("/UnbindCoolerBox", cont.UnBindCoolerBox)
		r.POST("/GetCoolerBoxBindCieRaft", cont.GetCoolerBoxBindCieRaft)
		r.GET("/GetCoolerIceRaft", cont.GetIceRaft)
	}

	cont2 := controller.IceRaftRecordController{}
	r2 := v1.Group("/ice-raft-record").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction())
	{
		r2.GET("", cont2.GetPage)
		r2.PUT("", cont2.Update)
		r2.DELETE("", cont2.Delete)
		r2.POST("/end-for-cold", cont2.EndForCold)
		r2.POST("/start-for-cold", cont2.StartForCold)
		r2.GET("/recording", cont2.IceRaftRecordRecording)
		r2.GET("/export-execl", cont2.ExportExecl)
	}
}
