package user

import (
	"context"

	"github.com/gin-gonic/gin"
	"github.com/perfect-panel/server/internal/logic/public/user"
	"github.com/perfect-panel/server/internal/svc"
	"github.com/perfect-panel/server/pkg/constant"
	"github.com/perfect-panel/server/pkg/result"
)

// Query User Subscribe
func QueryUserSubscribeHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
	return func(c *gin.Context) {
		// 1. Get param from URL Query (?includeExpired=all)
		value := c.Query("includeExpired")

		// 2. Inject param into Request Context
		ctx := context.WithValue(c.Request.Context(), constant.CtxKeyIncludeExpired, value)

		l := user.NewQueryUserSubscribeLogic(ctx, svcCtx)
		resp, err := l.QueryUserSubscribe()
		result.HttpResult(c, resp, err)
	}
}
