package routers import ( "learnsteam/cslms-api/internal/controllers" "learnsteam/cslms-api/internal/repositories" "learnsteam/cslms-api/internal/services" "github.com/gin-gonic/gin" "gorm.io/gorm" ) func InitTokenRouter(db *gorm.DB, router *gin.Engine) { r := NewTokenRouter(db, router) r.SetTokenRouter() } type TokenRouter interface { SetRouter(db *gorm.DB, router *gin.Engine) } type tokenRouter struct { db *gorm.DB repository repositories.TokenRepository service services.TokenService controller controllers.TokenController router *gin.Engine } func NewTokenRouter(db *gorm.DB, router *gin.Engine) *tokenRouter { repository := repositories.NewTokenRepository(db) service := services.NewTokenService(repository) controller := controllers.NewTokenController(service) return &tokenRouter{ db: db, repository: repository, service: service, controller: controller, router: router, } } func (r *tokenRouter) SetTokenRouter() { group := r.router.Group("/token") group.POST("refresh", r.controller.Refresh) }