package routers

import (
	"github.com/gin-gonic/gin"
	"hongze/hongze_yb/controller/user"
	"hongze/hongze_yb/middleware"
)

func InitUser(r *gin.Engine) {
	rGroup := r.Group("user").Use(middleware.TokenNoLogin())

	{
		rGroup.POST("/login", user.Login)
		rGroup.GET("/get_sms_code", user.GetSmsCode)
		rGroup.GET("/get_email_code", user.GetEmailCode)
	}

	rGroup2 := r.Group("user").Use(middleware.Token())
	{
		rGroup2.GET("/info", user.Info)
		rGroup2.GET("/get_last_apply_record", user.GetLastApplyRecord)
		rGroup2.POST("/apply", user.Apply)
		rGroup2.GET("/get_tab_bar", user.GetTabBar)
	}

	initUser(r)
}

func initUser(r *gin.Engine) {
	rGroup := r.Group("api/user").Use(middleware.TokenNoLogin())

	{
		rGroup.POST("/login", user.Login)
		rGroup.GET("/get_sms_code", user.GetSmsCode)
		rGroup.GET("/get_email_code", user.GetEmailCode)
	}

	rGroup2 := r.Group("api/user").Use(middleware.Token())
	{
		rGroup2.GET("/info", user.Info)
		rGroup2.GET("/get_last_apply_record", user.GetLastApplyRecord)
		rGroup2.POST("/apply", user.Apply)
		rGroup2.GET("/get_tab_bar", user.GetTabBar)
		rGroup2.GET("/get_top_tab", user.GetTopTab)
		rGroup2.POST("/set", user.SetUserInfo)
	}

}
