package router

import (
	"go-admin/app/admin/fronted"

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

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

func init() {
	routerFrontedCheckRole = append(routerFrontedCheckRole, frontedRegisterLinUserRouter)
	routerCheckRole = append(routerCheckRole, registerLineUserRouter)
}

// registerLineUserRouter
func registerLineUserRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	api := apis.LineUser{}
	r := v1.Group("/line-user").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("property", api.ReloadProperty) //更新资产
	}
}

func frontedRegisterLinUserRouter(v1 *gin.RouterGroup) {
	api := fronted.LineUserApi{}
	r := v1.Group("/line")
	{
		r.POST("/register", api.Register)               //用户注册
		r.POST("/verifyEmail", api.VerifyEmail)         //验证邮箱
		r.POST("/sendVerifyEmail", api.SendVerifyEmail) //发送验证邮箱
		r.POST("/sendRegisterSms", api.SendRegisterSms) //发送注册短信
		r.POST("/login", api.Login)                     //登录
	}

	//需要token鉴权
	r.POST("/center", middleware.FrontedAuth, api.Info)                //用户中心
	r.POST("/getIp", middleware.FrontedAuth, api.GetWhiteIp)           //用户手动获取ApiKey白名单ip
	r.POST("/addApiAuth", middleware.FrontedAuth, api.AddApiKey)       //用户手动添加Apikey
	r.POST("/updateApiAuth", middleware.FrontedAuth, api.UpdateApiKey) //用户手动修改Apikey
	r.POST("/opStatus", middleware.FrontedAuth, api.OpenStatus)        //开启或者关闭状态
	r.DELETE("/logout", middleware.FrontedAuth, api.Logout)            //退出登录
	r.GET("user-info", middleware.FrontedAuth, api.GetUserInfo)        //用户详情
	r.PUT("order-set", middleware.FrontedAuth, api.UserOrderSet)       //用户下单设置
	r.PUT("reset-pwd", api.ResetPassword)                              //重置密码

	r.GET("/exchange-balance", middleware.FrontedAuth, api.GetProperty) //合约用户交易所u资产

	//充值
	r.POST("/notify", api.Notify)                                                         //uDun回调
	r.POST("/rechargeNetworkList", middleware.FrontedAuth, api.RechargeNetworkList)       //充值 通过充值币种选择主网络
	r.POST("/rechargeNetworkAddress", middleware.FrontedAuth, api.RechargeNetworkAddress) //充值 通过主网ID和用户ID获取交易地址
	r.POST("/fundingTrend", middleware.FrontedAuth, api.FundingTrend)                     //资金走势

	//coinGate 充值
	r.POST("/callback", api.CallBack)                         //coinGate 回调地址
	r.POST("/preorder", middleware.FrontedAuth, api.PreOrder) //coinGate 充值

	commonApi := fronted.Common{}
	r2 := v1.Group("common")
	{
		r2.GET("default-set", commonApi.GetDefaultSet) //默认设置
	}
}

func frontedUserCenterRouter(v1 *gin.RouterGroup) {
	//api := fronted.LineUserApi{}

}
