MSP-1538 implement session api

This commit is contained in:
d1slike committed 2023-03-30 10:41:38 +03:00
1 parent 45810b4ec8
commit 4d1c17f9ae
4 files changed
+230

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
package controller
import (
"context"
"msp-admin-service/domain"
)
type SessionService interface {
All(ctx context.Context, limit int, offset int) (*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.SessionRequest true "Тело запроса"
// @Success 200 {object} domain.PageRequest
// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса"
// @Failure 500 {object} domain.GrpcError
// @Router /session/all [POST]
func (c Session) All(ctx context.Context, req domain.PageRequest) (*domain.SessionResponse, error) {
return c.service.All(ctx, req.Limit, req.Offset)
}
// 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} domain.GrpcError "Невалидное тело запроса"
// @Failure 500 {object} domain.GrpcError
// @Router /session/revoke [POST]
func (c Session) Revoke(ctx context.Context, req domain.RevokeRequest) error {
return c.service.Revoke(ctx, req.Id)
}