MSP-8974 add download flow, server migration to http
This commit is contained in:
1 parent
aa68f6028a
commit
71498785ea
46 files changed
+5102
-124
No files matched your search
@@ -0,0 +1,98 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"isp-admin-service/domain"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type DownloadService interface {
|
||||
DownloadUsers(ctx context.Context, req domain.UsersDownloadRequest, w http.ResponseWriter) error
|
||||
DownloadSessions(ctx context.Context, req domain.SessionDownloadRequest, w http.ResponseWriter) error
|
||||
DownloadAudit(ctx context.Context, req domain.AuditDownloadRequest, w http.ResponseWriter) error
|
||||
DownloadRoles(ctx context.Context, w http.ResponseWriter) error
|
||||
}
|
||||
|
||||
type Download struct {
|
||||
service DownloadService
|
||||
}
|
||||
|
||||
func NewDownload(service DownloadService) Download {
|
||||
return Download{
|
||||
service: service,
|
||||
}
|
||||
}
|
||||
|
||||
// Users
|
||||
// @Tags Download
|
||||
// @Summary Скачать список пользователей в csv
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.UsersDownloadRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} domain.BusinessError "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /user/download [POST]
|
||||
func (c Download) Users(ctx context.Context, req domain.UsersDownloadRequest, w http.ResponseWriter) error {
|
||||
err := c.service.DownloadUsers(ctx, req, w)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "download users")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sessions
|
||||
// @Tags Download
|
||||
// @Summary Скачать список сессий в csv
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.SessionDownloadRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} domain.BusinessError "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /session/download [POST]
|
||||
func (c Download) Sessions(ctx context.Context, req domain.SessionDownloadRequest, w http.ResponseWriter) error {
|
||||
err := c.service.DownloadSessions(ctx, req, w)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "download sessions")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Audit
|
||||
// @Tags Download
|
||||
// @Summary Скачать журнал аудита в csv
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.AuditDownloadRequest true "Тело запроса"
|
||||
// @Success 200
|
||||
// @Failure 500 {object} domain.BusinessError "Внутренняя ошибка сервиса ```{errorCode: -1}```"
|
||||
// @Router /log/download [POST]
|
||||
func (c Download) Audit(ctx context.Context, req domain.AuditDownloadRequest, w http.ResponseWriter) error {
|
||||
err := c.service.DownloadAudit(ctx, req, w)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "download audit")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Roles
|
||||
// @Tags Download
|
||||
// @Summary Скачать матрицу ролей в csv
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200
|
||||
// @Failure 500 {object} domain.BusinessError "Внутренняя ошибка сервиса ```{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 {
|
||||
return errors.WithMessage(err, "download roles")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user