MSP-8974 fix
This commit is contained in:
1 parent
ebc99c6ae4
commit
24a8ea2578
15 files changed
+362
-333
No files matched your search
+33
-30
@@ -27,16 +27,17 @@ func NewAudit(service AuditService) Audit {
|
||||
}
|
||||
|
||||
// All
|
||||
// @Tags log
|
||||
// @Summary Получение списка логов
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.AuditPageRequest true "Тело запроса (пагинация, сортировка, фильтры)"
|
||||
// @Success 200 {object} domain.AuditResponse
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /log/all [POST]
|
||||
//
|
||||
// @Tags log
|
||||
// @Summary Получение списка логов
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.AuditPageRequest true "Тело запроса (пагинация, сортировка, фильтры)"
|
||||
// @Success 200 {object} domain.AuditResponse
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /log/all [POST]
|
||||
func (c Audit) All(ctx context.Context, req domain.AuditPageRequest) (*domain.AuditResponse, error) {
|
||||
if req.Order == nil {
|
||||
req.Order = &domain.OrderParams{
|
||||
@@ -49,31 +50,33 @@ func (c Audit) All(ctx context.Context, req domain.AuditPageRequest) (*domain.Au
|
||||
}
|
||||
|
||||
// Events
|
||||
// @Tags log
|
||||
// @Summary Получение списка событий аудита
|
||||
// @Description Возвращает полный список доступных событий аудита
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {array} domain.AuditEvent
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /log/events [POST]
|
||||
//
|
||||
// @Tags log
|
||||
// @Summary Получение списка событий аудита
|
||||
// @Description Возвращает полный список доступных событий аудита
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {array} domain.AuditEvent
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /log/events [POST]
|
||||
func (c Audit) Events(ctx context.Context) ([]domain.AuditEvent, error) {
|
||||
return c.service.Events(ctx)
|
||||
}
|
||||
|
||||
// SetEvents
|
||||
// @Tags log
|
||||
// @Summary Установить события аудита
|
||||
// @Description Устанавливает (обновляет) набор активных событий аудита.
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body []domain.SetAuditEvent true "Список событий аудита для установки"
|
||||
// @Success 200 {object} map[string]interface{} "События успешно установлены"
|
||||
// @Failure 400 {object} apierrors.Error "Неизвестное событие аудита"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /log/set_events [POST]
|
||||
//
|
||||
// @Tags log
|
||||
// @Summary Установить события аудита
|
||||
// @Description Устанавливает (обновляет) набор активных событий аудита.
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body []domain.SetAuditEvent true "Список событий аудита для установки"
|
||||
// @Success 200 {object} map[string]interface{} "События успешно установлены"
|
||||
// @Failure 400 {object} apierrors.Error "Неизвестное событие аудита"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /log/set_events [POST]
|
||||
func (c Audit) SetEvents(ctx context.Context, req []domain.SetAuditEvent) error {
|
||||
err := c.service.SetEvents(ctx, req)
|
||||
switch {
|
||||
|
||||
+48
-44
@@ -32,16 +32,17 @@ func NewAuth(authService authService, logger log.Logger) Auth {
|
||||
}
|
||||
|
||||
// Logout
|
||||
// @Tags auth
|
||||
// @Summary Выход из авторизованной сессии
|
||||
// @Description Выход из авторизованной сессии администрирования
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {object} map[string]interface{} "Успешный выход"
|
||||
// @Failure 400 {object} apierrors.Error "Невалидный токен"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /auth/logout [POST]
|
||||
//
|
||||
// @Tags auth
|
||||
// @Summary Выход из авторизованной сессии
|
||||
// @Description Выход из авторизованной сессии администрирования
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {object} map[string]interface{} "Успешный выход"
|
||||
// @Failure 400 {object} apierrors.Error "Невалидный токен"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /auth/logout [POST]
|
||||
func (a Auth) Logout(ctx context.Context, r *http.Request) error {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -57,17 +58,18 @@ func (a Auth) Logout(ctx context.Context, r *http.Request) error {
|
||||
}
|
||||
|
||||
// LogoutWithReason
|
||||
// @Tags auth
|
||||
// @Summary Выход по бездействию из авторизованной сессии
|
||||
// @Description Выход по бездействию из авторизованной сессии администрирования
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.LogoutRequest true "Тело запроса"
|
||||
// @Success 200 {object} map[string]interface{} "Успешный выход"
|
||||
// @Failure 400 {object} apierrors.Error "Невалидный токен"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /auth/logout_with_reason [POST]
|
||||
//
|
||||
// @Tags auth
|
||||
// @Summary Выход по бездействию из авторизованной сессии
|
||||
// @Description Выход по бездействию из авторизованной сессии администрирования
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.LogoutRequest true "Тело запроса"
|
||||
// @Success 200 {object} map[string]interface{} "Успешный выход"
|
||||
// @Failure 400 {object} apierrors.Error "Невалидный токен"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /auth/logout_with_reason [POST]
|
||||
func (a Auth) LogoutWithReason(ctx context.Context, logoutRequest domain.LogoutRequest, r *http.Request) error {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -83,18 +85,19 @@ func (a Auth) LogoutWithReason(ctx context.Context, logoutRequest domain.LogoutR
|
||||
}
|
||||
|
||||
// Login
|
||||
// @Tags auth
|
||||
// @Summary Авторизация по логину и паролю
|
||||
// @Description Авторизация с получением токена администратора
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.LoginRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.LoginResponse
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 401 {object} apierrors.Error "Данные для авторизации не верны"
|
||||
// @Failure 429 {object} apierrors.Error "Слишком много запросов на авторизацию"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /auth/login [POST]
|
||||
//
|
||||
// @Tags auth
|
||||
// @Summary Авторизация по логину и паролю
|
||||
// @Description Авторизация с получением токена администратора
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.LoginRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.LoginResponse
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 401 {object} apierrors.Error "Данные для авторизации не верны"
|
||||
// @Failure 429 {object} apierrors.Error "Слишком много запросов на авторизацию"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /auth/login [POST]
|
||||
func (a Auth) Login(ctx context.Context, authRequest domain.LoginRequest) (*domain.LoginResponse, error) {
|
||||
auth, err := a.authService.Login(ctx, authRequest)
|
||||
|
||||
@@ -114,17 +117,18 @@ func (a Auth) Login(ctx context.Context, authRequest domain.LoginRequest) (*doma
|
||||
}
|
||||
|
||||
// LoginWithOauth
|
||||
// @Tags auth
|
||||
// @Summary Авторизация по авторизационному коду от OAuth
|
||||
// @Description Авторизация с получением токена администратора.
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.LoginOauthRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.LoginResponse
|
||||
// @Failure 400 {object} apierrors.Error "Авторизация OAuth не настроена на сервере"
|
||||
// @Failure 401 {object} apierrors.Error "Некорректный код для авторизации или неизвестное название клиента"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /auth/login_with_oauth [POST]
|
||||
//
|
||||
// @Tags auth
|
||||
// @Summary Авторизация по авторизационному коду от OAuth
|
||||
// @Description Авторизация с получением токена администратора.
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.LoginOauthRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.LoginResponse
|
||||
// @Failure 400 {object} apierrors.Error "Авторизация OAuth не настроена на сервере"
|
||||
// @Failure 401 {object} apierrors.Error "Некорректный код для авторизации или неизвестное название клиента"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /auth/login_with_oauth [POST]
|
||||
func (a Auth) LoginWithOauth(ctx context.Context, request domain.LoginOauthRequest) (*domain.LoginResponse, error) {
|
||||
auth, err := a.authService.LoginWithOauth(ctx, request)
|
||||
|
||||
|
||||
+11
-10
@@ -19,16 +19,17 @@ func NewCustomization(uiCfg conf.UIDesign) Customization {
|
||||
}
|
||||
|
||||
// GetUIDesign
|
||||
// @Tags user
|
||||
// @Summary Получение внешнего вида
|
||||
// @Description Получение внешнего вида (палитра и наименование) админ-интерфейса
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {object} domain.UIDesign
|
||||
// @Failure 400 {object} apierrors.Error "Невалидный токен"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_design [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Получение внешнего вида
|
||||
// @Description Получение внешнего вида (палитра и наименование) админ-интерфейса
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {object} domain.UIDesign
|
||||
// @Failure 400 {object} apierrors.Error "Невалидный токен"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_design [POST]
|
||||
func (c Customization) GetUIDesign() (domain.UIDesign, error) {
|
||||
return c.uiCfg, nil
|
||||
}
|
||||
+35
-31
@@ -27,14 +27,15 @@ func NewDownload(service DownloadService) Download {
|
||||
}
|
||||
|
||||
// Users
|
||||
// @Tags Download
|
||||
// @Summary Скачать список пользователей в csv
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.UsersPageRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /user/download [POST]
|
||||
//
|
||||
// @Tags Download
|
||||
// @Summary Скачать список пользователей в csv
|
||||
// @Accept json
|
||||
// @Produce text/csv
|
||||
// @Param body body domain.UsersPageRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /user/download [POST]
|
||||
func (c Download) Users(ctx context.Context, req domain.UsersPageRequest, w http.ResponseWriter) error {
|
||||
err := c.service.DownloadUsers(ctx, req, w)
|
||||
if err != nil {
|
||||
@@ -45,14 +46,15 @@ func (c Download) Users(ctx context.Context, req domain.UsersPageRequest, w http
|
||||
}
|
||||
|
||||
// Sessions
|
||||
// @Tags Download
|
||||
// @Summary Скачать список сессий в csv
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.SessionPageRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /session/download [POST]
|
||||
//
|
||||
// @Tags Download
|
||||
// @Summary Скачать список сессий в csv
|
||||
// @Accept json
|
||||
// @Produce text/csv
|
||||
// @Param body body domain.SessionPageRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /session/download [POST]
|
||||
func (c Download) Sessions(ctx context.Context, req domain.SessionPageRequest, w http.ResponseWriter) error {
|
||||
err := c.service.DownloadSessions(ctx, req, w)
|
||||
if err != nil {
|
||||
@@ -63,14 +65,15 @@ func (c Download) Sessions(ctx context.Context, req domain.SessionPageRequest, w
|
||||
}
|
||||
|
||||
// Audit
|
||||
// @Tags Download
|
||||
// @Summary Скачать журнал аудита в csv
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.AuditPageRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /log/download [POST]
|
||||
//
|
||||
// @Tags Download
|
||||
// @Summary Скачать журнал аудита в csv
|
||||
// @Accept json
|
||||
// @Produce text/csv
|
||||
// @Param body body domain.AuditPageRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /log/download [POST]
|
||||
func (c Download) Audit(ctx context.Context, req domain.AuditPageRequest, w http.ResponseWriter) error {
|
||||
err := c.service.DownloadAudit(ctx, req, w)
|
||||
if err != nil {
|
||||
@@ -81,13 +84,14 @@ func (c Download) Audit(ctx context.Context, req domain.AuditPageRequest, w http
|
||||
}
|
||||
|
||||
// Roles
|
||||
// @Tags Download
|
||||
// @Summary Скачать матрицу ролей в csv
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /role/download [POST]
|
||||
//
|
||||
// @Tags Download
|
||||
// @Summary Скачать матрицу ролей в csv
|
||||
// @Accept json
|
||||
// @Produce text/csv
|
||||
// @Success 200
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /role/download [POST]
|
||||
func (c Download) Roles(ctx context.Context, w http.ResponseWriter) error {
|
||||
err := c.service.DownloadRoles(ctx, w)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,14 +21,15 @@ func NewPermissions(permissionsService permissionsService) Permissions {
|
||||
}
|
||||
|
||||
// GetPermissions
|
||||
// @Tags user
|
||||
// @Summary Получить все разрешения
|
||||
// @Description Получить все разрешения
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} domain.Permission
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_permissions [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Получить все разрешения
|
||||
// @Description Получить все разрешения
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} domain.Permission
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_permissions [POST]
|
||||
func (u Permissions) GetPermissions(ctx context.Context) []domain.Permission {
|
||||
return u.permissionsService.All(ctx)
|
||||
}
|
||||
+51
-48
@@ -28,19 +28,19 @@ func NewRole(roleService roleService) Role {
|
||||
}
|
||||
|
||||
// All
|
||||
// @Tags role
|
||||
// @Summary Список ролей
|
||||
// @Description Получить список ролей
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.RoleAllRequest true "Тело запроса"
|
||||
// @Success 200 {array} domain.Role
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /role/all [POST]
|
||||
func (u Role) All(ctx context.Context, req domain.RoleAllRequest) ([]domain.Role, error) {
|
||||
users, err := u.roleService.All(ctx, req)
|
||||
//
|
||||
// @Tags role
|
||||
// @Summary Список ролей
|
||||
// @Description Получить список ролей
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {array} domain.Role
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /role/all [POST]
|
||||
func (u Role) All(ctx context.Context) ([]domain.Role, error) {
|
||||
users, err := u.roleService.All(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get roles")
|
||||
}
|
||||
@@ -49,18 +49,19 @@ func (u Role) All(ctx context.Context, req domain.RoleAllRequest) ([]domain.Role
|
||||
}
|
||||
|
||||
// CreateRole
|
||||
// @Tags role
|
||||
// @Summary Создать роль
|
||||
// @Description Создать роль
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.CreateRoleRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.Role
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 409 {object} apierrors.Error "Роль с указанным именем уже существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /role/create [POST]
|
||||
//
|
||||
// @Tags role
|
||||
// @Summary Создать роль
|
||||
// @Description Создать роль
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.CreateRoleRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.Role
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 409 {object} apierrors.Error "Роль с указанным именем уже существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /role/create [POST]
|
||||
func (u Role) CreateRole(ctx context.Context, req domain.CreateRoleRequest, r *http.Request) (*domain.Role, error) {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -79,18 +80,19 @@ func (u Role) CreateRole(ctx context.Context, req domain.CreateRoleRequest, r *h
|
||||
}
|
||||
|
||||
// UpdateRole
|
||||
// @Tags role
|
||||
// @Summary Обновить роль
|
||||
// @Description Обновить данные существующую роль
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.UpdateRoleRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.Role
|
||||
// @Failure 404 {object} apierrors.Error "Роль с указанным id не существует"
|
||||
// @Failure 409 {object} apierrors.Error "Роль с указанным именем уже существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /role/update [POST]
|
||||
//
|
||||
// @Tags role
|
||||
// @Summary Обновить роль
|
||||
// @Description Обновить данные существующую роль
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.UpdateRoleRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.Role
|
||||
// @Failure 404 {object} apierrors.Error "Роль с указанным id не существует"
|
||||
// @Failure 409 {object} apierrors.Error "Роль с указанным именем уже существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /role/update [POST]
|
||||
func (u Role) UpdateRole(ctx context.Context, req domain.UpdateRoleRequest, r *http.Request) (*domain.Role, error) {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -111,17 +113,18 @@ func (u Role) UpdateRole(ctx context.Context, req domain.UpdateRoleRequest, r *h
|
||||
}
|
||||
|
||||
// DeleteRole
|
||||
// @Tags role
|
||||
// @Summary Удалить роль
|
||||
// @Description Удалить существующую роль
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.DeleteRoleRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /role/delete [POST]
|
||||
//
|
||||
// @Tags role
|
||||
// @Summary Удалить роль
|
||||
// @Description Удалить существующую роль
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.DeleteRoleRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /role/delete [POST]
|
||||
func (u Role) DeleteRole(ctx context.Context, req domain.DeleteRoleRequest, r *http.Request) error {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
|
||||
+20
-18
@@ -25,15 +25,16 @@ func NewSecure(service SecureService) Secure {
|
||||
}
|
||||
|
||||
// Authenticate
|
||||
// @Tags secure
|
||||
// @Summary Метод аутентификации токена
|
||||
// @Description Проверяет токен и возвращает идентификатор администратора
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.SecureAuthRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.SecureAuthResponse
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /secure/authenticate [POST]
|
||||
//
|
||||
// @Tags secure
|
||||
// @Summary Метод аутентификации токена
|
||||
// @Description Проверяет токен и возвращает идентификатор администратора
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.SecureAuthRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.SecureAuthResponse
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /secure/authenticate [POST]
|
||||
func (s Secure) Authenticate(ctx context.Context, req domain.SecureAuthRequest) (*domain.SecureAuthResponse, error) {
|
||||
adminId, err := s.service.Authenticate(ctx, req.Token)
|
||||
switch {
|
||||
@@ -61,15 +62,16 @@ func (s Secure) Authenticate(ctx context.Context, req domain.SecureAuthRequest)
|
||||
}
|
||||
|
||||
// Authorize
|
||||
// @Tags secure
|
||||
// @Summary Метод авторизации для администратора
|
||||
// @Description Проверяет наличие у администратора необходимого разрешения
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.SecureAuthzRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.SecureAuthzResponse
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /secure/authorize [POST]
|
||||
//
|
||||
// @Tags secure
|
||||
// @Summary Метод авторизации для администратора
|
||||
// @Description Проверяет наличие у администратора необходимого разрешения
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.SecureAuthzRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.SecureAuthzResponse
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /secure/authorize [POST]
|
||||
func (s Secure) Authorize(ctx context.Context, req domain.SecureAuthzRequest) (*domain.SecureAuthzResponse, error) {
|
||||
ok, err := s.service.Authorize(ctx, req.AdminId, req.Permission)
|
||||
if err != nil {
|
||||
|
||||
+22
-20
@@ -22,16 +22,17 @@ func NewSession(service SessionService) Session {
|
||||
}
|
||||
|
||||
// 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]
|
||||
//
|
||||
// @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{
|
||||
@@ -44,16 +45,17 @@ func (c Session) All(ctx context.Context, req domain.SessionPageRequest) (*domai
|
||||
}
|
||||
|
||||
// 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]
|
||||
//
|
||||
// @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)
|
||||
}
|
||||
+12
-11
@@ -24,17 +24,18 @@ func NewUiSettings(service UiSettingsService) UiSettings {
|
||||
}
|
||||
|
||||
// UiOauthSettings
|
||||
// @Tags ui_settings
|
||||
// @Summary Получение настроек для ui для авторизации через OAuth
|
||||
// @Description Получение настроек для ui для авторизации через OAuth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.ClientNameRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.UiOauthSetting
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 401 {object} apierrors.Error "Неизвестное название клиента"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /ui_settings/oauth [POST]
|
||||
//
|
||||
// @Tags ui_settings
|
||||
// @Summary Получение настроек для ui для авторизации через OAuth
|
||||
// @Description Получение настроек для ui для авторизации через OAuth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.ClientNameRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.UiOauthSetting
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 401 {object} apierrors.Error "Неизвестное название клиента"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /ui_settings/oauth [POST]
|
||||
func (c UiSettings) OauthSettings(ctx context.Context, req domain.ClientNameRequest) (*domain.UiOauthSetting, error) {
|
||||
resp, err := c.service.OauthSettings(ctx, req)
|
||||
switch {
|
||||
|
||||
+106
-97
@@ -34,17 +34,18 @@ func NewUser(userService userService) User {
|
||||
}
|
||||
|
||||
// GetProfile
|
||||
// @Tags user
|
||||
// @Summary Получить профиль
|
||||
// @Description Получить данные профиля
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {object} domain.AdminUserShort
|
||||
// @Failure 401 {object} apierrors.Error "Невалидный токен"
|
||||
// @Failure 404 {object} apierrors.Error "Пользователя не существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_profile [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Получить профиль
|
||||
// @Description Получить данные профиля
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {object} domain.AdminUserShort
|
||||
// @Failure 401 {object} apierrors.Error "Невалидный токен"
|
||||
// @Failure 404 {object} apierrors.Error "Пользователя не существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_profile [POST]
|
||||
func (u User) GetProfile(ctx context.Context, r *http.Request) (*domain.AdminUserShort, error) {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -65,17 +66,18 @@ func (u User) GetProfile(ctx context.Context, r *http.Request) (*domain.AdminUse
|
||||
}
|
||||
|
||||
// GetUsers
|
||||
// @Tags user
|
||||
// @Summary Список пользователей
|
||||
// @Description Получить список пользователей
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.UsersPageRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.UsersResponse
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_users [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Список пользователей
|
||||
// @Description Получить список пользователей
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.UsersPageRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.UsersResponse
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_users [POST]
|
||||
func (u User) GetUsers(ctx context.Context, req domain.UsersPageRequest) (*domain.UsersResponse, error) {
|
||||
if req.Order == nil {
|
||||
req.Order = &domain.OrderParams{
|
||||
@@ -93,16 +95,17 @@ func (u User) GetUsers(ctx context.Context, req domain.UsersPageRequest) (*domai
|
||||
}
|
||||
|
||||
// GetAllUsers
|
||||
// @Tags user
|
||||
// @Summary Список пользователей
|
||||
// @Description Получить список пользователей
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {object} domain.UsersResponse
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_all_users [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Список пользователей
|
||||
// @Description Получить список пользователей
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Success 200 {object} domain.UsersResponse
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_all_users [POST]
|
||||
func (u User) GetAllUsers(ctx context.Context) (*domain.UsersResponse, error) {
|
||||
users, err := u.userService.GetAllUsers(ctx)
|
||||
if err != nil {
|
||||
@@ -113,18 +116,19 @@ func (u User) GetAllUsers(ctx context.Context) (*domain.UsersResponse, error) {
|
||||
}
|
||||
|
||||
// CreateUser
|
||||
// @Tags user
|
||||
// @Summary Создать пользователя
|
||||
// @Description Создать пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.CreateUserRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.User
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 409 {object} apierrors.Error "Пользователь с указанным email уже существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/create_user [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Создать пользователя
|
||||
// @Description Создать пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.CreateUserRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.User
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 409 {object} apierrors.Error "Пользователь с указанным email уже существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/create_user [POST]
|
||||
func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, r *http.Request) (*domain.User, error) {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -143,19 +147,20 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, r *h
|
||||
}
|
||||
|
||||
// UpdateUser
|
||||
// @Tags user
|
||||
// @Summary Обновить пользователя
|
||||
// @Description Обновить данные существующего пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.UpdateUserRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.User
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 404 {object} apierrors.Error "Пользователь с указанным id не существует"
|
||||
// @Failure 409 {object} apierrors.Error "Пользователь с указанным email уже существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/update_user [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Обновить пользователя
|
||||
// @Description Обновить данные существующего пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.UpdateUserRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.User
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 404 {object} apierrors.Error "Пользователь с указанным id не существует"
|
||||
// @Failure 409 {object} apierrors.Error "Пользователь с указанным email уже существует"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/update_user [POST]
|
||||
func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, r *http.Request) (*domain.User, error) {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -178,17 +183,18 @@ func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, r *h
|
||||
}
|
||||
|
||||
// DeleteUser
|
||||
// @Tags user
|
||||
// @Summary Удалить пользователя
|
||||
// @Description Удалить существующего пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.IdentitiesRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.DeleteResponse
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/delete_user [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Удалить пользователя
|
||||
// @Description Удалить существующего пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.IdentitiesRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.DeleteResponse
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/delete_user [POST]
|
||||
func (u User) DeleteUser(ctx context.Context, identities domain.IdentitiesRequest, r *http.Request) (*domain.DeleteResponse, error) {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -204,16 +210,17 @@ func (u User) DeleteUser(ctx context.Context, identities domain.IdentitiesReques
|
||||
}
|
||||
|
||||
// Block
|
||||
// @Tags user
|
||||
// @Summary Метод блокировки/разблокировки пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.IdRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/block_user [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Метод блокировки/разблокировки пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.IdRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/block_user [POST]
|
||||
func (u User) Block(ctx context.Context, identities domain.IdRequest, r *http.Request) error {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
@@ -228,30 +235,32 @@ func (u User) Block(ctx context.Context, identities domain.IdRequest, r *http.Re
|
||||
}
|
||||
|
||||
// GetById
|
||||
// @Tags user
|
||||
// @Summary Метод получения данных по пользователю
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.IdRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.User
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_by_id [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Метод получения данных по пользователю
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.IdRequest true "Тело запроса"
|
||||
// @Success 200 {object} domain.User
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /user/get_by_id [POST]
|
||||
func (u User) GetById(ctx context.Context, identities domain.IdRequest) (*domain.User, error) {
|
||||
return u.userService.GetById(ctx, identities.UserId)
|
||||
}
|
||||
|
||||
// ChangePassword
|
||||
// @Tags user
|
||||
// @Summary Метод изменения пароля пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.ChangePasswordRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса или неверный старый пароль"
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка"
|
||||
// @Router /user/change_password [POST]
|
||||
//
|
||||
// @Tags user
|
||||
// @Summary Метод изменения пароля пользователя
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||
// @Param body body domain.ChangePasswordRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 400 {object} apierrors.Error "Невалидное тело запроса или неверный старый пароль"
|
||||
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка"
|
||||
// @Router /user/change_password [POST]
|
||||
func (u User) ChangePassword(ctx context.Context, req domain.ChangePasswordRequest, r *http.Request) error {
|
||||
adminId, err := getAdminId(r)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user