Files
isp-admin-service/controller/session.go
T
2026-11-23 13:00:25 +03:00

62 lines
1.7 KiB
Go

package controller
import (
"context"
"isp-admin-service/domain"
)
type SessionService interface {
All(ctx context.Context, req domain.SessionPageRequest) (*domain.SessionResponse, error)
Revoke(ctx context.Context, id int) error
}
type Session struct {
service SessionService
}
func NewSession(service SessionService) Session {
return Session{
service: service,
}
}
// All
//
// @Tags session
// @Summary Получение списка сессий
// @Accept json
// @Produce json
// @Param X-AUTH-ADMIN header string true "Токен администратора"
// @Param body body domain.SessionPageRequest true "Тело запроса"
// @Success 200 {object} domain.SessionResponse
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
// @Failure 500 {object} apierrors.Error
// @Router /session/all [POST]
func (c Session) All(ctx context.Context, req domain.SessionPageRequest) (*domain.SessionResponse, error) {
if req.Order == nil {
req.Order = &domain.OrderParams{
Field: domain.DefaultOrderField,
Type: domain.DefaultOrderType,
}
}
return c.service.All(ctx, req)
}
// Revoke
//
// @Tags session
// @Summary Отзыв сессии
// @Accept json
// @Produce json
// @Param X-AUTH-ADMIN header string true "Токен администратора"
// @Param body body domain.RevokeRequest true "Тело запроса"
// @Success 200
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
// @Failure 500 {object} apierrors.Error
// @Router /session/revoke [POST]
func (c Session) Revoke(ctx context.Context, req domain.RevokeRequest) error {
return c.service.Revoke(ctx, req.Id)
}