package routers

import (
	"github.com/gin-gonic/gin"

	"bwallet/middleware/auth"
	"bwallet/pkg/upload"
	"bwallet/routers/api"
	"bwallet/routers/api/v1"
	"net/http"
)

func InitRouter() *gin.Engine {
	r := gin.New()

	r.Use(gin.Logger())

	r.Use(gin.Recovery())

	r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath()))
	//r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath()))

	r.POST("/auth", api.GetAuth)
	//r.POST("/upload", api.UploadImage)

	api := r.Group("/api")
	api.Use(auth.AUTH())

	{
		//api.POST("/upload",v1.Upload)

		api.GET("/coins", v1.GetCoins)
		api.POST("/coin", v1.AddCoin)
		api.GET("/coin", v1.GetCoin)
		api.PUT("/coin", v1.EditCoin)
		api.DELETE("/coin", v1.DeleteCoin)
		api.GET("/primary-chains", v1.GetPrimaryChains)
		api.GET("/types", v1.GetTypes)

		api.GET("/coin-relation", v1.GetWalletCoinRelationCoinRelations)
		api.POST("/coin-relation", v1.AddWalletCoinRelationCoinRelation)
		api.DELETE("/coin-relation", v1.DeleteWalletCoinRelationCoinRelation)
		//api.GET("/get-platform", v1.GetCoinsPlatform)

		api.GET("/wallets", v1.GetWallets)
		api.POST("/wallet", v1.AddWallet)
		api.GET("/wallet", v1.GetWallet)
		api.PUT("/wallet", v1.EditWallet)
		api.DELETE("/wallet", v1.DeleteWallet)

		api.GET("/chains", v1.GetChains)
		api.POST("/chain", v1.AddChain)
		api.GET("/chain", v1.GetChain)
		api.PUT("/chain", v1.EditChain)
		api.DELETE("/chain", v1.DeleteChain)

		api.GET("/recommend-categories", v1.GetWalletRecommendCategories)
		api.POST("/recommend-category", v1.AddWalletRecommendCategory)
		api.GET("/recommend-category", v1.GetWalletRecommendCategory)
		api.DELETE("/recommend-category", v1.DeleteWalletRecommendCategory)
		api.PUT("/recommend-category", v1.EditWalletRecommendCategory)

		api.GET("/recommend-coins", v1.GetRecommendCoins)
		api.POST("/recommend-coin", v1.AddRecommendCoin)
		api.PUT("/recommend-coin", v1.EditRecommendCoin)
		api.DELETE("/recommend-coin", v1.DeleteRecommendCoin)

		api.GET("/supported-currencies", v1.GetSupportedCurrencies)
		api.POST("/supported-currency", v1.AddSupportedCurrency)
		api.GET("/supported-currency", v1.GetSupportedCurrency)
		api.PUT("/supported-currency", v1.EditSupportedCurrency)
		api.DELETE("/supported-currency", v1.DeleteSupportedCurrency)
		api.GET("/currencies", v1.GetCurrencies)

		api.GET("/supported-chains", v1.GetSupportedChains)
		api.POST("/supported-chain", v1.AddSupportedChain)
		api.DELETE("/supported-chain", v1.DeleteSupportedChain)
	}

	return r
}
