package router

import (
	"github.com/gin-gonic/gin"
	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"

	"go-admin/app/admin/apis"
	"go-admin/app/admin/fronted"
	"go-admin/common/actions"
	"go-admin/common/middleware"
)

func init() {
	routerCheckRole = append(routerCheckRole, registerMemberWithdrawalLogRouter)
	routerFrontedCheckRole = append(routerFrontedCheckRole, registerMemberWidthdrawalLogFrontedRouter)
}

// registerMemberWithdrawalLogRouter
func registerMemberWithdrawalLogRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	api := apis.MemberWithdrawalLog{}
	r := v1.Group("/member-withdrawal-log").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
	{
		r.GET("", actions.PermissionAction(), api.GetPage)
		r.GET("/:id", actions.PermissionAction(), api.Get)
		r.POST("", api.Insert)
		r.PUT("/:id", actions.PermissionAction(), api.Update)
		r.DELETE("", api.Delete)

		r.PUT("/approve", actions.PermissionAction(), api.Process) //审核提现申请
		r.PUT("confirm", actions.PermissionAction(), api.Confirm)  //确认提现申请
	}
}

func registerMemberWidthdrawalLogFrontedRouter(v1 *gin.RouterGroup) {
	api := fronted.MemberWithdrawalLog{}

	r := v1.Group("/member-withdrawal", middleware.FrontedAuth)
	{
		r.GET("", api.GetPage)
		// r.GET("/:id", api.Get)
		r.POST("", api.Apply)
		r.PUT("/cancel", api.Cancel)
		// r.PUT("/:id", api.Update)
		// r.DELETE("", api.Delete)
	}
}
