Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be5ce45d17 | ||
|
|
53fc40efe4 | ||
|
|
e4445eca46 | ||
|
|
1651a1fc3c | ||
|
|
882e5c67a7 | ||
|
|
d7a7e4ee0d | ||
|
|
ec0f1a02d1 | ||
|
|
65cfb65f8e | ||
|
|
c0687a264e | ||
|
|
c5b82152e0 | ||
|
|
a648f4f9a7 | ||
|
|
454526d047 | ||
|
|
6d3e1cbccd | ||
|
|
b9dcfec926 | ||
|
|
dff580b252 | ||
|
|
24e21beee2 | ||
|
|
c11d09b992 | ||
|
|
02df1a6546 | ||
|
|
6f45b1861f | ||
|
|
22a34dbb86 |
No files matched your search
@@ -1,10 +1,3 @@
|
||||
### v6.0.0
|
||||
* Удалены таблицы `domain` и `system`
|
||||
* Удалены `deprecated` endpoint'ы
|
||||
* Изменены контракты для `application` endpoint'ов
|
||||
* Добавлены `admin` permission к endpoint'ам
|
||||
### v5.7.3
|
||||
* обновлены зависимости
|
||||
### v5.7.2
|
||||
* Обновлен isp-kit
|
||||
### v5.7.1
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
|
||||
"isp-system-service/conf"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/app"
|
||||
"github.com/txix-open/isp-kit/bootstrap"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/dbrx"
|
||||
"github.com/txix-open/isp-kit/dbx"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
+10
-7
@@ -43,25 +43,26 @@ func (l Locator) Config(cfg conf.Remote) Config {
|
||||
txManager := transaction.NewManager(l.db)
|
||||
accessListRep := repository.NewAccessList(l.db)
|
||||
applicationRep := repository.NewApplication(l.db)
|
||||
domainRep := repository.NewDomain(l.db)
|
||||
appGroupRep := repository.NewAppGroup(l.db)
|
||||
tokenRep := repository.NewToken(l.db)
|
||||
|
||||
secureService := secure.NewService(tokenRep, accessListRep)
|
||||
accessListService := service.NewAccessList(txManager, accessListRep, applicationRep)
|
||||
applicationService := service.NewApplication(txManager, applicationRep, appGroupRep, tokenRep)
|
||||
applicationService := service.NewApplication(txManager, applicationRep, domainRep, appGroupRep, tokenRep)
|
||||
domainService := service.NewDomain(domainRep)
|
||||
serviceService := service.NewService(domainRep, appGroupRep)
|
||||
|
||||
jwtService := service.NewTokenSource()
|
||||
tokenService := service.NewToken(
|
||||
jwtService,
|
||||
applicationService,
|
||||
txManager,
|
||||
applicationRep,
|
||||
tokenRep,
|
||||
tokenService := service.NewToken(jwtService, applicationService, txManager,
|
||||
applicationRep, domainRep, appGroupRep, tokenRep,
|
||||
)
|
||||
|
||||
secureController := controller.NewSecure(secureService)
|
||||
accessListController := controller.NewAccessList(accessListService)
|
||||
applicationController := controller.NewApplication(applicationService)
|
||||
domainController := controller.NewDomain(domainService)
|
||||
serviceController := controller.NewService(serviceService)
|
||||
tokenController := controller.NewToken(tokenService)
|
||||
|
||||
appGroupService := service.NewAppGroup(appGroupRep)
|
||||
@@ -69,6 +70,8 @@ func (l Locator) Config(cfg conf.Remote) Config {
|
||||
c := routes.Controllers{
|
||||
Secure: secureController,
|
||||
AccessList: accessListController,
|
||||
Domain: domainController,
|
||||
Service: serviceController,
|
||||
Application: applicationController,
|
||||
Token: tokenController,
|
||||
AppGroup: appGroupController,
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"isp-system-service/domain"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"isp-system-service/domain"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
+42
-28
@@ -6,23 +6,24 @@ import (
|
||||
|
||||
"isp-system-service/domain"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
//nolint:interfacebloat
|
||||
type ApplicationService interface {
|
||||
GetById(ctx context.Context, appId int) (*domain.Application, error)
|
||||
GetById(ctx context.Context, appId int) (*domain.ApplicationWithTokens, error)
|
||||
GetByToken(ctx context.Context, token string) (*domain.GetApplicationByTokenResponse, error)
|
||||
GetByIdList(ctx context.Context, idList []int) ([]domain.Application, error)
|
||||
GetByAppGroup(ctx context.Context, appGroupId int) ([]domain.Application, error)
|
||||
CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.Application, error)
|
||||
GetByIdList(ctx context.Context, idList []int) ([]*domain.ApplicationWithTokens, error)
|
||||
GetByServiceId(ctx context.Context, id int) ([]*domain.ApplicationWithTokens, error)
|
||||
SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithService, error)
|
||||
CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error)
|
||||
Delete(ctx context.Context, idList []int) (int, error)
|
||||
NextId(ctx context.Context) (int, error)
|
||||
GetAll(ctx context.Context) ([]domain.Application, error)
|
||||
Create(ctx context.Context, req domain.CreateApplicationRequest) (*domain.Application, error)
|
||||
Update(ctx context.Context, req domain.UpdateApplicationRequest) (*domain.Application, error)
|
||||
Create(ctx context.Context, req domain.CreateApplicationRequest) (*domain.ApplicationWithTokens, error)
|
||||
Update(ctx context.Context, req domain.UpdateApplicationRequest) (*domain.ApplicationWithTokens, error)
|
||||
}
|
||||
|
||||
type Application struct {
|
||||
@@ -43,12 +44,12 @@ func NewApplication(service ApplicationService) Application {
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.Identity true "Идентификатор приложения"
|
||||
// @Success 200 {object} domain.Application
|
||||
// @Success 200 {object} domain.ApplicationWithTokens
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 404 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /application/get_application_by_id [POST]
|
||||
func (c Application) GetById(ctx context.Context, req domain.Identity) (*domain.Application, error) {
|
||||
func (c Application) GetById(ctx context.Context, req domain.Identity) (*domain.ApplicationWithTokens, error) {
|
||||
result, err := c.service.GetById(ctx, req.Id)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrApplicationNotFound):
|
||||
@@ -99,31 +100,44 @@ func (c Application) GetByToken(ctx context.Context, req domain.GetApplicationBy
|
||||
//
|
||||
// @Tags application
|
||||
// @Summary Получить список приложений
|
||||
// @Description Возвращает массив приложений их идентификаторам
|
||||
// @Description Возвращает массив приложений с токенами по их идентификаторам
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов приложений"
|
||||
// @Success 200 {array} domain.Application
|
||||
// @Success 200 {array} domain.ApplicationWithTokens
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /application/get_applications [POST]
|
||||
func (c Application) GetByIdList(ctx context.Context, req []int) ([]domain.Application, error) {
|
||||
func (c Application) GetByIdList(ctx context.Context, req []int) ([]*domain.ApplicationWithTokens, error) {
|
||||
return c.service.GetByIdList(ctx, req)
|
||||
}
|
||||
|
||||
// GetByAppGroup godoc
|
||||
// GetByServiceId godoc
|
||||
//
|
||||
// @Tags application
|
||||
// @Summary Получить список приложений по идентификатору группы
|
||||
// @Description Возвращает список приложений по идентификатору группы
|
||||
// @Summary Получить список приложений по идентификатору сервиса
|
||||
// @Description Возвращает список приложений по запрошенному идентификатору сервиса
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.Identity true "Тело запроса"
|
||||
// @Success 200 {array} domain.Application
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Param body body domain.Identity true "Идентификатор сервиса"
|
||||
// @Success 200 {array} domain.ApplicationWithTokens
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /application/get_by_app_group [POST]
|
||||
func (c Application) GetByAppGroup(ctx context.Context, req domain.Identity) ([]domain.Application, error) {
|
||||
return c.service.GetByAppGroup(ctx, req.Id)
|
||||
// @Router /application/get_applications_by_service_id [POST]
|
||||
func (c Application) GetByServiceId(ctx context.Context, req domain.Identity) ([]*domain.ApplicationWithTokens, error) {
|
||||
return c.service.GetByServiceId(ctx, req.Id)
|
||||
}
|
||||
|
||||
// GetSystemTree godoc
|
||||
//
|
||||
// @Tags application
|
||||
// @Summary Метод получения системного дерева
|
||||
// @Description Возвращает описание взаимосвязей сервисов и приложений
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} domain.DomainWithService
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /application/get_system_tree [POST]
|
||||
func (c Application) GetSystemTree(ctx context.Context) ([]*domain.DomainWithService, error) {
|
||||
return c.service.SystemTree(ctx, domain.DefaultSystemId)
|
||||
}
|
||||
|
||||
// CreateUpdate godoc
|
||||
@@ -134,19 +148,19 @@ func (c Application) GetByAppGroup(ctx context.Context, req domain.Identity) ([]
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.ApplicationCreateUpdateRequest true "Объект приложения"
|
||||
// @Success 200 {object} domain.Application
|
||||
// @Success 200 {object} domain.ApplicationWithTokens
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 404 {object} apierrors.Error
|
||||
// @Failure 409 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /application/create_update_application [POST]
|
||||
func (c Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.Application, error) {
|
||||
func (c Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error) {
|
||||
result, err := c.service.CreateUpdate(ctx, req)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrAppGroupNotFound):
|
||||
return nil, apierrors.NewBusinessError(
|
||||
domain.ErrCodeAppGroupNotFound,
|
||||
fmt.Sprintf("service with id %d not found", req.ApplicationGroupId),
|
||||
fmt.Sprintf("service with id %d not found", req.ServiceId),
|
||||
err,
|
||||
)
|
||||
case errors.Is(err, domain.ErrApplicationDuplicateName):
|
||||
@@ -234,12 +248,12 @@ func (c Application) GetAll(ctx context.Context) ([]domain.Application, error) {
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.CreateApplicationRequest true "Объект приложения"
|
||||
// @Success 200 {object} domain.Application
|
||||
// @Success 200 {object} domain.ApplicationWithTokens
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 409 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /application/create_application [POST]
|
||||
func (c Application) Create(ctx context.Context, req domain.CreateApplicationRequest) (*domain.Application, error) {
|
||||
func (c Application) Create(ctx context.Context, req domain.CreateApplicationRequest) (*domain.ApplicationWithTokens, error) {
|
||||
result, err := c.service.Create(ctx, req)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrAppGroupNotFound):
|
||||
@@ -275,13 +289,13 @@ func (c Application) Create(ctx context.Context, req domain.CreateApplicationReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.UpdateApplicationRequest true "Объект приложения"
|
||||
// @Success 200 {object} domain.Application
|
||||
// @Success 200 {object} domain.ApplicationWithTokens
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 404 {object} apierrors.Error
|
||||
// @Failure 409 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /application/update_application [POST]
|
||||
func (c Application) Update(ctx context.Context, req domain.UpdateApplicationRequest) (*domain.Application, error) {
|
||||
func (c Application) Update(ctx context.Context, req domain.UpdateApplicationRequest) (*domain.ApplicationWithTokens, error) {
|
||||
result, err := c.service.Update(ctx, req)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrApplicationNotFound):
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"isp-system-service/domain"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
type DomainService interface {
|
||||
GetById(ctx context.Context, id int) (*domain.Domain, error)
|
||||
GetBySystemId(ctx context.Context, systemId int) ([]domain.Domain, error)
|
||||
CreateUpdate(ctx context.Context, req domain.DomainCreateUpdateRequest, systemId int) (*domain.Domain, error)
|
||||
Delete(ctx context.Context, idList []int) (int, error)
|
||||
}
|
||||
|
||||
type Domain struct {
|
||||
service DomainService
|
||||
}
|
||||
|
||||
func NewDomain(service DomainService) Domain {
|
||||
return Domain{
|
||||
service: service,
|
||||
}
|
||||
}
|
||||
|
||||
// GetById godoc
|
||||
//
|
||||
// @Tags domain
|
||||
// @Summary Получить домен по идентификатору
|
||||
// @Description Возвращает описание домена по его идентификатору
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.Identity true "Идентификатор домена"
|
||||
// @Success 200 {object} domain.Domain
|
||||
// @Failure 404 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /domain/get_domain_by_id [POST]
|
||||
func (c Domain) GetById(ctx context.Context, req domain.Identity) (*domain.Domain, error) {
|
||||
result, err := c.service.GetById(ctx, req.Id)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrDomainNotFound):
|
||||
return nil, apierrors.New(
|
||||
codes.NotFound,
|
||||
domain.ErrCodeDomainNotFound,
|
||||
fmt.Sprintf("domain with id %d not found", req.Id),
|
||||
err,
|
||||
)
|
||||
case err != nil:
|
||||
return nil, err
|
||||
default:
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
// GetBySystemId godoc
|
||||
//
|
||||
// @Tags domain
|
||||
// @Summary Получить домены по идентификатору системы
|
||||
// @Description Возвращает список доменов по системному идентификатору
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body integer false "Идентификатор системы"
|
||||
// @Success 200 {array} domain.Domain
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /domain/get_domains_by_system_id [POST]
|
||||
func (c Domain) GetBySystemId(ctx context.Context) ([]domain.Domain, error) {
|
||||
return c.service.GetBySystemId(ctx, domain.DefaultSystemId)
|
||||
}
|
||||
|
||||
// CreateUpdate godoc
|
||||
//
|
||||
// @Tags domain
|
||||
// @Summary Создать/обновить домен
|
||||
// @Description Если домен с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.DomainCreateUpdateRequest true "Объект домена"
|
||||
// @Success 200 {object} domain.Domain
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /domain/create_update_domain [POST]
|
||||
func (c Domain) CreateUpdate(ctx context.Context, req domain.DomainCreateUpdateRequest) (*domain.Domain, error) {
|
||||
result, err := c.service.CreateUpdate(ctx, req, domain.DefaultSystemId)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrSystemNotFound):
|
||||
return nil, apierrors.NewBusinessError(
|
||||
domain.ErrCodeSystemNotFound,
|
||||
fmt.Sprintf("system with id %d not found", domain.DefaultSystemId),
|
||||
err,
|
||||
)
|
||||
case errors.Is(err, domain.ErrDomainNotFound):
|
||||
return nil, apierrors.New(
|
||||
codes.NotFound,
|
||||
domain.ErrCodeDomainNotFound,
|
||||
fmt.Sprintf("domain with id %d not found", req.Id),
|
||||
err,
|
||||
)
|
||||
case errors.Is(err, domain.ErrDomainDuplicateName):
|
||||
return nil, apierrors.New(
|
||||
codes.AlreadyExists,
|
||||
domain.ErrCodeDomainDuplicateName,
|
||||
fmt.Sprintf("domain with name %s already exists", req.Name),
|
||||
err,
|
||||
)
|
||||
case err != nil:
|
||||
return nil, err
|
||||
default:
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Delete godoc
|
||||
//
|
||||
// @Tags domain
|
||||
// @Summary Удаление доменов
|
||||
// @Description Удаляет домены по списку их идентификаторов, возвращает количество удаленных доменов
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов доменов"
|
||||
// @Success 200 {object} domain.DeleteResponse
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /domain/delete_domains [POST]
|
||||
func (c Domain) Delete(ctx context.Context, req []int) (*domain.DeleteResponse, error) {
|
||||
if len(req) == 0 {
|
||||
return nil, apierrors.NewBusinessError(domain.ErrCodeInvalidRequest,
|
||||
"At least one id are required", errors.New("invalid id count"))
|
||||
}
|
||||
|
||||
result, err := c.service.Delete(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &domain.DeleteResponse{
|
||||
Deleted: result,
|
||||
}, nil
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"isp-system-service/domain"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type SecureService interface {
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"isp-system-service/domain"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
type ServiceService interface {
|
||||
GetById(ctx context.Context, id int) (*domain.Service, error)
|
||||
GetByIdList(ctx context.Context, idList []int) ([]domain.Service, error)
|
||||
GetByDomainId(ctx context.Context, domainId int) ([]domain.Service, error)
|
||||
CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdateRequest) (*domain.Service, error)
|
||||
Delete(ctx context.Context, idList []int) (int, error)
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
service ServiceService
|
||||
}
|
||||
|
||||
func NewService(service ServiceService) Service {
|
||||
return Service{
|
||||
service: service,
|
||||
}
|
||||
}
|
||||
|
||||
// GetById godoc
|
||||
//
|
||||
// @Tags service
|
||||
// @Summary Получить сервис по идентификатору
|
||||
// @Description Возвращает описание сервиса по его идентификатору
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.Identity true "Идентификатор сервиса"
|
||||
// @Success 200 {object} domain.Service
|
||||
// @Failure 404 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /service/get_service_by_id [POST]
|
||||
func (c Service) GetById(ctx context.Context, req domain.Identity) (*domain.Service, error) {
|
||||
result, err := c.service.GetById(ctx, req.Id)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrAppGroupNotFound):
|
||||
return nil, apierrors.New(
|
||||
codes.NotFound,
|
||||
domain.ErrCodeAppGroupNotFound,
|
||||
fmt.Sprintf("service with id %d not found", req.Id),
|
||||
err,
|
||||
)
|
||||
case err != nil:
|
||||
return nil, err
|
||||
default:
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Get godoc
|
||||
//
|
||||
// @Tags service
|
||||
// @Summary Получить список сервисов
|
||||
// @Description Возвращает список сервисов по их идентификаторам
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов сервисов"
|
||||
// @Success 200 {array} domain.Service
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /service/get_service [POST]
|
||||
func (c Service) Get(ctx context.Context, req []int) ([]domain.Service, error) {
|
||||
return c.service.GetByIdList(ctx, req)
|
||||
}
|
||||
|
||||
// GetByDomainId godoc
|
||||
//
|
||||
// @Tags service
|
||||
// @Summary Получить список сервисов по идентификатору домена
|
||||
// @Description Возвращает список сервисов по идентификатору домена
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.Identity true "Идентификатор домена"
|
||||
// @Success 200 {array} domain.Service
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /service/get_services_by_domain_id [POST]
|
||||
func (c Service) GetByDomainId(ctx context.Context, req domain.Identity) ([]domain.Service, error) {
|
||||
return c.service.GetByDomainId(ctx, req.Id)
|
||||
}
|
||||
|
||||
// CreateUpdate godoc
|
||||
//
|
||||
// @Tags service
|
||||
// @Summary Создать/обновить сервис
|
||||
// @Description Если сервис с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.ServiceCreateUpdateRequest true "Объект сервиса"
|
||||
// @Success 200 {object} domain.Service
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 404 {object} apierrors.Error
|
||||
// @Failure 409 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /service/create_update_service [POST]
|
||||
func (c Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdateRequest) (*domain.Service, error) {
|
||||
result, err := c.service.CreateUpdate(ctx, req)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrDomainNotFound):
|
||||
return nil, apierrors.NewBusinessError(
|
||||
domain.ErrCodeDomainNotFound,
|
||||
fmt.Sprintf("domain with id %d not found", req.DomainId),
|
||||
err,
|
||||
)
|
||||
case errors.Is(err, domain.ErrAppGroupNotFound):
|
||||
return nil, apierrors.New(
|
||||
codes.NotFound,
|
||||
domain.ErrCodeAppGroupNotFound,
|
||||
fmt.Sprintf("service with id %d not found", req.Id),
|
||||
err,
|
||||
)
|
||||
case errors.Is(err, domain.ErrAppGroupDuplicateName):
|
||||
return nil, apierrors.New(
|
||||
codes.AlreadyExists,
|
||||
domain.ErrCodeAppGroupNotFound,
|
||||
fmt.Sprintf("service with name %s already exists", req.Name),
|
||||
err,
|
||||
)
|
||||
case err != nil:
|
||||
return nil, err
|
||||
default:
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Delete godoc
|
||||
//
|
||||
// @Tags service
|
||||
// @Summary Удалить сервисы
|
||||
// @Description Удаляет сервисов по списку их идентификаторов, возвращает количество удаленных сервисов
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer true "Массив идентификаторов сервисов"
|
||||
// @Success 200 {object} domain.DeleteResponse
|
||||
// @Failure 400 {object} apierrors.Error
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /service/delete_service [POST]
|
||||
func (c Service) Delete(ctx context.Context, req []int) (*domain.DeleteResponse, error) {
|
||||
if len(req) == 0 {
|
||||
return nil, apierrors.NewBusinessError(domain.ErrCodeInvalidRequest,
|
||||
"At least one id are required", errors.New("invalid id count"))
|
||||
}
|
||||
|
||||
result, err := c.service.Delete(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &domain.DeleteResponse{
|
||||
Deleted: result,
|
||||
}, nil
|
||||
}
|
||||
+15
-1
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"isp-system-service/domain"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
@@ -64,6 +64,20 @@ func (c Token) Create(ctx context.Context, req domain.TokenCreateRequest) (*doma
|
||||
fmt.Sprintf("application with id %d not found", req.AppId),
|
||||
err,
|
||||
)
|
||||
case errors.Is(err, domain.ErrAppGroupNotFound):
|
||||
return nil, apierrors.New(
|
||||
codes.NotFound,
|
||||
domain.ErrCodeAppGroupNotFound,
|
||||
fmt.Sprintf("service for app_id id %d not found", req.AppId),
|
||||
err,
|
||||
)
|
||||
case errors.Is(err, domain.ErrDomainNotFound):
|
||||
return nil, apierrors.New(
|
||||
codes.NotFound,
|
||||
domain.ErrCodeDomainNotFound,
|
||||
fmt.Sprintf("domain for app_id id %d not found", req.AppId),
|
||||
err,
|
||||
)
|
||||
case err != nil:
|
||||
return nil, err
|
||||
default:
|
||||
|
||||
+625
-22
@@ -38,7 +38,9 @@
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {}
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
@@ -81,7 +83,9 @@
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {}
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
@@ -267,7 +271,7 @@
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Application"
|
||||
"$ref": "#/definitions/domain.ApplicationWithTokens"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
@@ -319,7 +323,7 @@
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Application"
|
||||
"$ref": "#/definitions/domain.ApplicationWithTokens"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
@@ -457,7 +461,7 @@
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Application"
|
||||
"$ref": "#/definitions/domain.ApplicationWithTokens"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
@@ -535,7 +539,7 @@
|
||||
},
|
||||
"/application/get_applications": {
|
||||
"post": {
|
||||
"description": "Возвращает массив приложений их идентификаторам",
|
||||
"description": "Возвращает массив приложений с токенами по их идентификаторам",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -565,7 +569,7 @@
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.Application"
|
||||
"$ref": "#/definitions/domain.ApplicationWithTokens"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -578,9 +582,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/application/get_by_app_group": {
|
||||
"/application/get_applications_by_service_id": {
|
||||
"post": {
|
||||
"description": "Возвращает список приложений по идентификатору группы",
|
||||
"description": "Возвращает список приложений по запрошенному идентификатору сервиса",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -590,10 +594,10 @@
|
||||
"tags": [
|
||||
"application"
|
||||
],
|
||||
"summary": "Получить список приложений по идентификатору группы",
|
||||
"summary": "Получить список приложений по идентификатору сервиса",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Тело запроса",
|
||||
"description": "Идентификатор сервиса",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -608,15 +612,41 @@
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.Application"
|
||||
"$ref": "#/definitions/domain.ApplicationWithTokens"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/application/get_system_tree": {
|
||||
"post": {
|
||||
"description": "Возвращает описание взаимосвязей сервисов и приложений",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"application"
|
||||
],
|
||||
"summary": "Метод получения системного дерева",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.DomainWithService"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
@@ -684,7 +714,7 @@
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Application"
|
||||
"$ref": "#/definitions/domain.ApplicationWithTokens"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
@@ -951,6 +981,182 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/domain/create_update_domain": {
|
||||
"post": {
|
||||
"description": "Если домен с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"domain"
|
||||
],
|
||||
"summary": "Создать/обновить домен",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Объект домена",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.DomainCreateUpdateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Domain"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/domain/delete_domains": {
|
||||
"post": {
|
||||
"description": "Удаляет домены по списку их идентификаторов, возвращает количество удаленных доменов",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"domain"
|
||||
],
|
||||
"summary": "Удаление доменов",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Массив идентификаторов доменов",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.DeleteResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/domain/get_domain_by_id": {
|
||||
"post": {
|
||||
"description": "Возвращает описание домена по его идентификатору",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"domain"
|
||||
],
|
||||
"summary": "Получить домен по идентификатору",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Идентификатор домена",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Identity"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Domain"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/domain/get_domains_by_system_id": {
|
||||
"post": {
|
||||
"description": "Возвращает список доменов по системному идентификатору",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"domain"
|
||||
],
|
||||
"summary": "Получить домены по идентификатору системы",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Идентификатор системы",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.Domain"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/secure/authenticate": {
|
||||
"post": {
|
||||
"description": "Проверяет наличие токена в системе,",
|
||||
@@ -1037,6 +1243,247 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/service/create_update_service": {
|
||||
"post": {
|
||||
"description": "Если сервис с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"service"
|
||||
],
|
||||
"summary": "Создать/обновить сервис",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Объект сервиса",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.ServiceCreateUpdateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Service"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
},
|
||||
"409": {
|
||||
"description": "Conflict",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/service/delete_service": {
|
||||
"post": {
|
||||
"description": "Удаляет сервисов по списку их идентификаторов, возвращает количество удаленных сервисов",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"service"
|
||||
],
|
||||
"summary": "Удалить сервисы",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Массив идентификаторов сервисов",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.DeleteResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/service/get_service": {
|
||||
"post": {
|
||||
"description": "Возвращает список сервисов по их идентификаторам",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"service"
|
||||
],
|
||||
"summary": "Получить список сервисов",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Массив идентификаторов сервисов",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.Service"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/service/get_service_by_id": {
|
||||
"post": {
|
||||
"description": "Возвращает описание сервиса по его идентификатору",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"service"
|
||||
],
|
||||
"summary": "Получить сервис по идентификатору",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Идентификатор сервиса",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Identity"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Service"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/service/get_services_by_domain_id": {
|
||||
"post": {
|
||||
"description": "Возвращает список сервисов по идентификатору домена",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"service"
|
||||
],
|
||||
"summary": "Получить список сервисов по идентификатору домена",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Идентификатор домена",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.Identity"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.Service"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apierrors.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/token/create_token": {
|
||||
"post": {
|
||||
"description": "Создает токен и привязывает его к приложению",
|
||||
@@ -1327,9 +1774,6 @@
|
||||
"domain.Application": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"applicationGroupId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1342,6 +1786,9 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"serviceId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1353,14 +1800,11 @@
|
||||
"domain.ApplicationCreateUpdateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"applicationGroupId",
|
||||
"name",
|
||||
"serviceId",
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"applicationGroupId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1370,6 +1814,9 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"serviceId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -1379,6 +1826,29 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.ApplicationSimple": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tokens": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.Token"
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.ApplicationWithTokens": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1401,6 +1871,15 @@
|
||||
},
|
||||
"applicationId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"domainId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"serviceId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"systemId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1507,6 +1986,66 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.Domain": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"systemId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.DomainCreateUpdateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.DomainWithService": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"services": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.ServiceWithApps"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.GetApplicationByTokenRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -1583,6 +2122,70 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.Service": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"domainId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.ServiceCreateUpdateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"domainId",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"domainId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.ServiceWithApps": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"apps": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/domain.ApplicationSimple"
|
||||
}
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain.Token": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+20
-12
@@ -10,21 +10,21 @@ const (
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
ApplicationGroupId int
|
||||
Type string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
ServiceId int
|
||||
Type string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type ApplicationCreateUpdateRequest struct {
|
||||
Id int
|
||||
Name string `validate:"required"`
|
||||
Description string
|
||||
ApplicationGroupId int `validate:"required"`
|
||||
Type string `validate:"required,oneof=SYSTEM MOBILE"`
|
||||
Id int
|
||||
Name string `validate:"required"`
|
||||
Description string
|
||||
ServiceId int `validate:"required"`
|
||||
Type string `validate:"required,oneof=SYSTEM MOBILE"`
|
||||
}
|
||||
|
||||
type ApplicationWithTokens struct {
|
||||
@@ -32,6 +32,14 @@ type ApplicationWithTokens struct {
|
||||
Tokens []Token
|
||||
}
|
||||
|
||||
type ApplicationSimple struct {
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
Type string
|
||||
Tokens []Token
|
||||
}
|
||||
|
||||
type CreateApplicationRequest struct {
|
||||
Id int `validate:"required"`
|
||||
Name string `validate:"required"`
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type DomainCreateUpdateRequest struct {
|
||||
Id int
|
||||
Name string `validate:"required"`
|
||||
Description string
|
||||
}
|
||||
|
||||
type Domain struct {
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
SystemId int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type DomainWithService struct {
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
Services []*ServiceWithApps
|
||||
}
|
||||
+10
-1
@@ -1,7 +1,7 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -13,12 +13,21 @@ const (
|
||||
|
||||
ErrCodeAppGroupNotFound = 605
|
||||
ErrCodeAppGroupDuplicateName = 606
|
||||
|
||||
ErrCodeSystemNotFound = 607
|
||||
ErrCodeDomainNotFound = 608
|
||||
ErrCodeDomainDuplicateName = 609
|
||||
)
|
||||
|
||||
var (
|
||||
ErrDomainNotFound = errors.New("domain not found")
|
||||
ErrDomainDuplicateName = errors.New("domain name already exist")
|
||||
|
||||
ErrAppGroupNotFound = errors.New("application group not found")
|
||||
ErrAppGroupDuplicateName = errors.New("application group name already exist")
|
||||
|
||||
ErrSystemNotFound = errors.New("system not found")
|
||||
|
||||
ErrApplicationNotFound = errors.New("application not found")
|
||||
ErrApplicationDuplicateName = errors.New("application name already exist")
|
||||
ErrApplicationDuplicateId = errors.New("application id already exist")
|
||||
|
||||
@@ -12,6 +12,9 @@ type AuthenticateResponse struct {
|
||||
|
||||
type AuthData struct {
|
||||
AppName string
|
||||
SystemId int
|
||||
DomainId int
|
||||
ServiceId int
|
||||
ApplicationId int
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
DomainId int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type ServiceCreateUpdateRequest struct {
|
||||
Id int
|
||||
Name string `validate:"required"`
|
||||
Description string
|
||||
DomainId int `validate:"required"`
|
||||
}
|
||||
|
||||
type ServiceWithApps struct {
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
Apps []*ApplicationSimple
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package domain
|
||||
|
||||
const (
|
||||
DefaultSystemId = 1
|
||||
)
|
||||
@@ -9,6 +9,7 @@ type AppGroup struct {
|
||||
Id int
|
||||
Name string
|
||||
Description sql.NullString
|
||||
DomainId int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Domain struct {
|
||||
Id int
|
||||
Name string
|
||||
Description *string
|
||||
SystemId int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
+7
-4
@@ -12,8 +12,11 @@ type Token struct {
|
||||
}
|
||||
|
||||
type AuthData struct {
|
||||
AppName string
|
||||
AppId int
|
||||
ExpireTime int
|
||||
CreatedAt time.Time
|
||||
AppName string
|
||||
SystemId int
|
||||
DomainId int
|
||||
ApplicationGroupId int
|
||||
AppId int
|
||||
ExpireTime int
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -1,28 +1,29 @@
|
||||
module isp-system-service
|
||||
|
||||
go 1.26.0
|
||||
go 1.26
|
||||
|
||||
require (
|
||||
github.com/Masterminds/squirrel v1.5.4
|
||||
github.com/jackc/pgx/v5 v5.10.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/txix-open/isp-kit v1.74.0
|
||||
github.com/txix-open/isp-kit v1.71.1
|
||||
github.com/txix-open/jsonschema v1.3.0
|
||||
google.golang.org/grpc v1.83.0
|
||||
google.golang.org/grpc v1.82.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/buger/jsonparser v1.6.0 // indirect
|
||||
github.com/buger/jsonparser v1.2.0 // indirect
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/coder/websocket v1.8.15 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.15 // indirect
|
||||
github.com/getsentry/sentry-go v0.48.0 // indirect
|
||||
github.com/go-faker/faker/v4 v4.10.1 // indirect
|
||||
github.com/go-logr/logr v1.4.4 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||
github.com/getsentry/sentry-go v0.47.0 // indirect
|
||||
github.com/go-faker/faker/v4 v4.9.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
@@ -34,10 +35,10 @@ require (
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/jmoiron/sqlx v1.4.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.19.1 // indirect
|
||||
github.com/klauspost/compress v1.19.0 // indirect
|
||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
||||
github.com/leodido/go-urn v1.5.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mailru/easyjson v0.9.2 // indirect
|
||||
github.com/mfridman/interpolate v0.0.2 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
@@ -45,14 +46,14 @@ require (
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/pressly/goose/v3 v3.27.3 // indirect
|
||||
github.com/prometheus/client_golang v1.24.1 // indirect
|
||||
github.com/pressly/goose/v3 v3.27.2 // indirect
|
||||
github.com/prometheus/client_golang v1.23.2 // indirect
|
||||
github.com/prometheus/client_model v0.6.2 // indirect
|
||||
github.com/prometheus/common v0.70.1 // indirect
|
||||
github.com/prometheus/common v0.69.0 // indirect
|
||||
github.com/prometheus/procfs v0.21.1 // indirect
|
||||
github.com/sethvargo/go-retry v0.4.0 // indirect
|
||||
github.com/sethvargo/go-retry v0.3.0 // indirect
|
||||
github.com/txix-open/bellows v1.2.0 // indirect
|
||||
github.com/txix-open/etp/v4 v4.1.3 // indirect
|
||||
github.com/txix-open/etp/v4 v4.1.1 // indirect
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb // indirect
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||
@@ -65,16 +66,16 @@ require (
|
||||
go.opentelemetry.io/otel/metric v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.44.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.28.0 // indirect
|
||||
golang.org/x/crypto v0.54.0 // indirect
|
||||
golang.org/x/net v0.57.0 // indirect
|
||||
golang.org/x/sync v0.22.0 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
golang.org/x/text v0.40.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0 // indirect
|
||||
golang.org/x/crypto v0.53.0 // indirect
|
||||
golang.org/x/net v0.56.0 // indirect
|
||||
golang.org/x/sync v0.21.0 // indirect
|
||||
golang.org/x/sys v0.46.0 // indirect
|
||||
golang.org/x/text v0.38.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260630182238-925bb5da69e7 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
@@ -9,8 +9,8 @@ github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPn
|
||||
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/buger/jsonparser v1.6.0 h1:IHTgLjkgckOjAp8p0aYfXkv+cqC+zrzALg/JywnPjxY=
|
||||
github.com/buger/jsonparser v1.6.0/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/buger/jsonparser v1.2.0 h1:4EFcvK1kD4jyj6YqNK6skK6w+y7FHHBR+XBCtxwu/6g=
|
||||
github.com/buger/jsonparser v1.2.0/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
@@ -23,17 +23,17 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI=
|
||||
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
||||
github.com/getsentry/sentry-go v0.48.0 h1:FRZNr7Uk1C86ev1bSJmYlUkL9oyivQA6YOcdYfaaMmY=
|
||||
github.com/getsentry/sentry-go v0.48.0/go.mod h1:E5UkA5wp1qR2+MDydNYlVeUiNN2xEdjYMidkgf0Qoss=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/getsentry/sentry-go v0.47.0 h1:AnSMSyrYA5qZCIN/2xpgAAwv63sVULV+vBq37ajouc8=
|
||||
github.com/getsentry/sentry-go v0.47.0/go.mod h1:h+b4VHpKnK7aUXB5wc+KDnPgp9ZtfliRD4eV85FbiSA=
|
||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||
github.com/go-faker/faker/v4 v4.10.1 h1:mGH3y0X8AfrXsfgPsPuTkWBYIebomvdkWEN1uDLoFFg=
|
||||
github.com/go-faker/faker/v4 v4.10.1/go.mod h1:VFIEwWDd16EdYDLF6NJ5gAAzEp7vz5LgKgJ2iZ17Tdg=
|
||||
github.com/go-faker/faker/v4 v4.9.0 h1:a4HXLwueuTCtgF93VpUsl8Zd2nG1VH2SgNWDPVEBg5U=
|
||||
github.com/go-faker/faker/v4 v4.9.0/go.mod h1:u1dIRP5neLB6kTzgyVjdBOV5R1uP7BdxkcWk7tiKQXk=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
@@ -70,8 +70,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
|
||||
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/compress v1.19.0 h1:sXLILfc9jV2QYWkzFOPWStmcUVH2RHEB1JCdY2oVvCQ=
|
||||
github.com/klauspost/compress v1.19.0/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
@@ -82,14 +82,14 @@ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq
|
||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
|
||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
|
||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
|
||||
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
|
||||
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mailru/easyjson v0.9.2 h1:dX8U45hQsZpxd80nLvDGihsQ/OxlvTkVUXH2r/8cb2M=
|
||||
github.com/mailru/easyjson v0.9.2/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||
github.com/mattn/go-isatty v0.0.23 h1:cYwCQTQf3HB6xUC+BtyCLZNr7IzbOmoZbmssVNzSyiQ=
|
||||
github.com/mattn/go-isatty v0.0.23/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||
github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs=
|
||||
github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
|
||||
@@ -112,24 +112,24 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pressly/goose/v3 v3.27.3 h1:pIglVHjw99r4e/hDHHwbl9vfOsDMqUokfkXo6+n/RxA=
|
||||
github.com/pressly/goose/v3 v3.27.3/go.mod h1:Dag+xpV6o20HR2LFY1j0q6MDwc3f7vPUFDA77R+0yGY=
|
||||
github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
|
||||
github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
|
||||
github.com/pressly/goose/v3 v3.27.2 h1:FjKNzcmMdGrQlSIu5alMSmakQtJFBgtw+A0bb1p/LC8=
|
||||
github.com/pressly/goose/v3 v3.27.2/go.mod h1:qWW+/8dkVtJYjJrbIpwD5xxnEJTUKvxkQ9JKQp9LaIM=
|
||||
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
|
||||
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
|
||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||
github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
|
||||
github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
|
||||
github.com/prometheus/common v0.69.0 h1:OA85nJQS/T/MaYh/Q2CcgDKSGWqNIgrBDvDH85CuiNk=
|
||||
github.com/prometheus/common v0.69.0/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y=
|
||||
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
|
||||
github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
|
||||
github.com/rabbitmq/amqp091-go v1.13.0 h1:L8NA1WtF76C6KA3LAoufjfLgbist/If1UQYcsOjtxXA=
|
||||
github.com/rabbitmq/amqp091-go v1.13.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||
github.com/rabbitmq/amqp091-go v1.12.0 h1:V0v14Iqfs+MwHWihJt/nGS5Ulu0vw572b2Co3mwunkI=
|
||||
github.com/rabbitmq/amqp091-go v1.12.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/sethvargo/go-retry v0.4.0 h1:9qy1OoIAxBL+gBYnkTnTnWle5wlfsXQlwRzIbbpdqPw=
|
||||
github.com/sethvargo/go-retry v0.4.0/go.mod h1:tvsjdKG6xfiCx4LSiUZ06kcv38xvdVQwv8R6/VnnVWg=
|
||||
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
||||
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
@@ -145,12 +145,12 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
||||
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
||||
github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
|
||||
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
||||
github.com/txix-open/etp/v4 v4.1.1 h1:Yna+0mw/kQZP7Rl6QI4spCrO6qgO8ZhP8PjHlJj2lTU=
|
||||
github.com/txix-open/etp/v4 v4.1.1/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
||||
github.com/txix-open/grmq v1.12.0 h1:lSPYvwLfTL0+b0xDQmuuN6RaKS3NCEJNK9ccWpOWa8Y=
|
||||
github.com/txix-open/grmq v1.12.0/go.mod h1:6m9CCTQao/HAFalu5rFOZGJ5KLEP6WzzIwj80Ml3KGE=
|
||||
github.com/txix-open/isp-kit v1.74.0 h1:Gi1X8Jnf9ppV4TXq4kMCBgBjJjqSKh57X8038I+tQFw=
|
||||
github.com/txix-open/isp-kit v1.74.0/go.mod h1:Kob233jk1j/Js7UmopJ5b7JpVZrpWbagEAjasgfqTdk=
|
||||
github.com/txix-open/isp-kit v1.71.1 h1:MNSuHy/HEvy7dKPQXkM+dgQpShDhcv1Sq1kLgep2LaA=
|
||||
github.com/txix-open/isp-kit v1.71.1/go.mod h1:j2sj86byoKllCs+DaRWwg56NgcL2omr/bUzmU7+AF74=
|
||||
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
||||
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
||||
@@ -182,8 +182,8 @@ go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRk
|
||||
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
|
||||
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
|
||||
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
|
||||
go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk=
|
||||
go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E=
|
||||
go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
|
||||
go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
@@ -194,24 +194,24 @@ go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ=
|
||||
go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
|
||||
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
|
||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
|
||||
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
|
||||
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
|
||||
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
|
||||
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
||||
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
||||
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
||||
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0 h1:ybvH/ZpOcpCrjtkb7oW/fdlzbEmRVeumw19SRQmNFKU=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0/go.mod h1:HJ9MpJLeDSstBkx1LILTpd5f41ADSMZcTPypw02qEGw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0 h1:mJiOtnGp0k/BcSgdu03G2NwnscCfCH+h2QKUBZr18KI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.83.0 h1:JeNZEKJFbQxArAMl+hiytHauacDNqJUllNfmIMmpqnQ=
|
||||
google.golang.org/grpc v1.83.0/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7 h1:jQ9p21COKWjP3VwuFrNRiiOTMh3mPpN45R7SLrH/HUU=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7/go.mod h1:KqHwBx2upmfa1XSi1WuRvC+2VGCLtooKkfmyvRbUmqA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260630182238-925bb5da69e7 h1:eM/YSd5bBFagF51o1E745Ta7RwzpW0h+z+QDNZOgmQ8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260630182238-925bb5da69e7/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU=
|
||||
google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -222,11 +222,11 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
modernc.org/libc v1.74.3 h1:a4J+Z8aVaxPyjyxRAdJzw246PqpcFGvVPnfT/AuM5Ws=
|
||||
modernc.org/libc v1.74.3/go.mod h1:4H7h/MJ8wnjL8RAbp9v3OXgnk22X7MouHIhDbvP3gj4=
|
||||
modernc.org/libc v1.73.4 h1:+ra4Ui8ngyt8HDcO1FTDPWlkAh6yOdaO2yAoh8MddQA=
|
||||
modernc.org/libc v1.73.4/go.mod h1:DXZ3eO8qMCNn2SnmTNCiC71nJ9Rcq3PsnpU6Vc4rWK8=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/sqlite v1.54.0 h1:JCxR4qwkJvOaqAoYcgDoO25Nc+ROg6EJ2LfBVzdrgog=
|
||||
modernc.org/sqlite v1.54.0/go.mod h1:4ntCLuNmnH8+GNqjka1wNg7KJd5/Hi5FYp8K+XQ7GZw=
|
||||
modernc.org/sqlite v1.53.0 h1:20WG8N9q4ji/dEqGk4uiI0c6OPjSeLTNYGFCc3+7c1M=
|
||||
modernc.org/sqlite v1.53.0/go.mod h1:xoEpOIpGrgT48H5iiyt/YXPCZPEzlfmfFwtk8Lklw8s=
|
||||
@@ -23,9 +23,10 @@ var (
|
||||
// @host localhost:9000
|
||||
// @BasePath /api/system
|
||||
|
||||
//go:generate swag init -pd -ot json -eot json
|
||||
//go:generate swag init --parseDependency
|
||||
//go:generate rm -f docs/swagger.yaml docs/docs.go
|
||||
func main() {
|
||||
boot := bootstrap.New(version, conf.Remote{}, cluster.Endpoints(routes.EndpointDescriptors()), cluster.GrpcTransport)
|
||||
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors(), cluster.GrpcTransport)
|
||||
app := boot.App
|
||||
logger := app.Logger()
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE application_group
|
||||
DROP CONSTRAINT fk_domain_id__domain_id;
|
||||
ALTER TABLE application_group
|
||||
DROP CONSTRAINT uq_name_domain_name;
|
||||
|
||||
ALTER TABLE application_group
|
||||
DROP COLUMN domain_id;
|
||||
|
||||
ALTER TABLE application_group
|
||||
ADD CONSTRAINT uq_application_group_name UNIQUE ("name");
|
||||
|
||||
ALTER TABLE domain
|
||||
DROP CONSTRAINT fk_system_id__system_id;
|
||||
|
||||
ALTER TABLE domain
|
||||
DROP CONSTRAINT uq_name_system_id;
|
||||
|
||||
DROP TABLE domain;
|
||||
DROP TABLE system;
|
||||
|
||||
-- +goose Down
|
||||
CREATE TABLE system (
|
||||
id SERIAL4 NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT (now() AT TIME ZONE 'utc'),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT (now() AT TIME ZONE 'utc'),
|
||||
CONSTRAINT UQ_name UNIQUE (name)
|
||||
);
|
||||
|
||||
CREATE TABLE domain (
|
||||
id SERIAL4 NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
system_id INTEGER NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT (now() AT TIME ZONE 'utc'),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT (now() AT TIME ZONE 'utc'),
|
||||
CONSTRAINT FK_system_id__system_id
|
||||
FOREIGN KEY (system_id)
|
||||
REFERENCES system (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE,
|
||||
CONSTRAINT UQ_name_system_id UNIQUE (name, system_id)
|
||||
);
|
||||
|
||||
-- Восстанавливаем root system/domain.
|
||||
INSERT INTO system (id, name)
|
||||
VALUES (1, 'rootSystem');
|
||||
|
||||
SELECT setval(
|
||||
'system_id_seq',
|
||||
GREATEST((SELECT COALESCE(MAX(id), 1) FROM system), 1)
|
||||
);
|
||||
|
||||
INSERT INTO domain (id, name, system_id)
|
||||
VALUES (1, 'root', 1);
|
||||
|
||||
SELECT setval(
|
||||
'domain_id_seq',
|
||||
GREATEST((SELECT COALESCE(MAX(id), 1) FROM domain), 1)
|
||||
);
|
||||
|
||||
ALTER TABLE application_group
|
||||
DROP CONSTRAINT uq_application_group_name;
|
||||
|
||||
ALTER TABLE application_group
|
||||
ADD COLUMN domain_id INTEGER DEFAULT 1;
|
||||
|
||||
ALTER TABLE application_group
|
||||
ALTER COLUMN domain_id SET NOT NULL;
|
||||
|
||||
ALTER TABLE application_group
|
||||
ADD CONSTRAINT FK_domain_id__domain_id
|
||||
FOREIGN KEY (domain_id)
|
||||
REFERENCES domain (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE application_group
|
||||
ADD CONSTRAINT UQ_name_domain_name
|
||||
UNIQUE (name, domain_id);
|
||||
|
||||
CREATE TRIGGER modify_system
|
||||
BEFORE UPDATE OR INSERT ON system
|
||||
FOR EACH ROW EXECUTE PROCEDURE update_created_modified_column_date();
|
||||
|
||||
CREATE TRIGGER modify_domain
|
||||
BEFORE UPDATE OR INSERT ON domain
|
||||
FOR EACH ROW EXECUTE PROCEDURE update_created_modified_column_date();
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/db"
|
||||
"github.com/txix-open/isp-kit/db/query"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||
)
|
||||
|
||||
|
||||
+38
-20
@@ -9,16 +9,12 @@ import (
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/db"
|
||||
"github.com/txix-open/isp-kit/db/query"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||
)
|
||||
|
||||
const (
|
||||
applicationGroupUniqueNameConstraint = "uq_application_group_name"
|
||||
)
|
||||
|
||||
type AppGroup struct {
|
||||
db db.DB
|
||||
}
|
||||
@@ -33,7 +29,7 @@ func (r AppGroup) GetAppGroupById(ctx context.Context, id int) (*entity.AppGroup
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupById")
|
||||
|
||||
q := `
|
||||
SELECT id, name, description, created_at, updated_at
|
||||
SELECT id, name, description, domain_id, created_at, updated_at
|
||||
FROM application_group
|
||||
WHERE id = $1
|
||||
`
|
||||
@@ -53,7 +49,7 @@ func (r AppGroup) GetAppGroupByIdList(ctx context.Context, idList []int) ([]enti
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupByIdList")
|
||||
|
||||
q, arg, err := query.New().
|
||||
Select("id", "name", "description", "created_at", "updated_at").
|
||||
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
|
||||
From("application_group").
|
||||
Where(squirrel.Eq{"id": idList}).
|
||||
OrderBy("created_at DESC").
|
||||
@@ -71,16 +67,38 @@ func (r AppGroup) GetAppGroupByIdList(ctx context.Context, idList []int) ([]enti
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r AppGroup) GetAppGroupByName(ctx context.Context, name string) (*entity.AppGroup, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupByName")
|
||||
func (r AppGroup) GetAppGroupByDomainId(ctx context.Context, domainIdList []int) ([]entity.AppGroup, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupByDomainId")
|
||||
|
||||
q, arg, err := query.New().
|
||||
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
|
||||
From("application_group").
|
||||
Where(squirrel.Eq{"domain_id": domainIdList}).
|
||||
OrderBy("created_at DESC").
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
result := make([]entity.AppGroup, 0)
|
||||
err = r.db.Select(ctx, &result, q, arg...)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r AppGroup) GetAppGroupByNameAndDomainId(ctx context.Context, name string, domainId int) (*entity.AppGroup, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupByNameAndDomainId")
|
||||
|
||||
q := `
|
||||
SELECT id, name, description, created_at, updated_at
|
||||
SELECT id, name, description, domain_id, created_at, updated_at
|
||||
FROM application_group
|
||||
WHERE name = $1
|
||||
WHERE name = $1 AND domain_id = $2
|
||||
`
|
||||
result := entity.AppGroup{}
|
||||
err := r.db.SelectRow(ctx, &result, q, name)
|
||||
err := r.db.SelectRow(ctx, &result, q, name, domainId)
|
||||
switch {
|
||||
case errors.Is(err, sql.ErrNoRows):
|
||||
return nil, domain.ErrAppGroupNotFound
|
||||
@@ -91,18 +109,18 @@ func (r AppGroup) GetAppGroupByName(ctx context.Context, name string) (*entity.A
|
||||
}
|
||||
}
|
||||
|
||||
func (r AppGroup) CreateAppGroup(ctx context.Context, name string, desc string) (*entity.AppGroup, error) {
|
||||
func (r AppGroup) CreateAppGroup(ctx context.Context, name string, desc string, domainId int) (*entity.AppGroup, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.CreateAppGroup")
|
||||
|
||||
q := `
|
||||
INSERT INTO application_group
|
||||
(name, description)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT (name) DO NOTHING
|
||||
RETURNING id, name, description, created_at, updated_at
|
||||
(name, description, domain_id)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (name, domain_id) DO NOTHING
|
||||
RETURNING id, name, description, domain_id, created_at, updated_at
|
||||
`
|
||||
result := entity.AppGroup{}
|
||||
err := r.db.SelectRow(ctx, &result, q, name, desc)
|
||||
err := r.db.SelectRow(ctx, &result, q, name, desc, domainId)
|
||||
switch {
|
||||
case errors.Is(err, sql.ErrNoRows):
|
||||
return nil, domain.ErrAppGroupDuplicateName
|
||||
@@ -120,7 +138,7 @@ func (r AppGroup) UpdateAppGroup(ctx context.Context, id int, name string, descr
|
||||
UPDATE application_group
|
||||
SET name = $1, description = $2
|
||||
WHERE id = $3
|
||||
RETURNING id, name, description, created_at, updated_at
|
||||
RETURNING id, name, description, domain_id, created_at, updated_at
|
||||
`
|
||||
result := entity.AppGroup{}
|
||||
err := r.db.SelectRow(ctx, &result, q, name, description, id)
|
||||
@@ -165,7 +183,7 @@ func (r AppGroup) GetAllAppGroups(ctx context.Context) ([]entity.AppGroup, error
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAllAppGroups")
|
||||
|
||||
q, arg, err := query.New().
|
||||
Select("id", "name", "description", "created_at", "updated_at").
|
||||
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
|
||||
From("application_group").
|
||||
OrderBy("created_at DESC").
|
||||
ToSql()
|
||||
|
||||
@@ -9,18 +9,12 @@ import (
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/db"
|
||||
"github.com/txix-open/isp-kit/db/query"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||
)
|
||||
|
||||
const (
|
||||
applicationPkConstraintName = "application_pkey"
|
||||
applicationUniqueNameConstraintName = "uq_name_application_group_id"
|
||||
applicationFkAppGroupConstraintName = "fk_application_group_id"
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
db db.DB
|
||||
}
|
||||
@@ -95,6 +89,26 @@ func (r Application) GetApplicationByAppGroupIdList(ctx context.Context, appGrou
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r Application) GetApplicationByNameAndAppGroupId(ctx context.Context, name string, serviceId int) (*entity.Application, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.GetApplicationByNameAndAppGroupId")
|
||||
|
||||
q := `
|
||||
SELECT id, name, description, application_group_id, type, created_at, updated_at
|
||||
FROM application
|
||||
WHERE name = $1 AND application_group_id = $2
|
||||
`
|
||||
result := entity.Application{}
|
||||
err := r.db.SelectRow(ctx, &result, q, name, serviceId)
|
||||
switch {
|
||||
case errors.Is(err, sql.ErrNoRows):
|
||||
return nil, nil // nolint:nilnil
|
||||
case err != nil:
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
default:
|
||||
return &result, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r Application) CreateApplication(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package repository
|
||||
|
||||
const (
|
||||
applicationPkConstraintName = "application_pkey"
|
||||
applicationUniqueNameConstraintName = "uq_name_application_group_id"
|
||||
applicationFkAppGroupConstraintName = "fk_application_group_id"
|
||||
|
||||
applicationGroupUniqueNameConstraint = "uq_name_domain_name"
|
||||
)
|
||||
@@ -0,0 +1,166 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/db"
|
||||
"github.com/txix-open/isp-kit/db/query"
|
||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||
)
|
||||
|
||||
type Domain struct {
|
||||
db db.DB
|
||||
}
|
||||
|
||||
func NewDomain(db db.DB) Domain {
|
||||
return Domain{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (r Domain) GetDomainById(ctx context.Context, id int) (*entity.Domain, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.GetDomainById")
|
||||
|
||||
q := `
|
||||
SELECT id, name, description, system_id, created_at, updated_at
|
||||
FROM domain
|
||||
WHERE id = $1
|
||||
`
|
||||
result := entity.Domain{}
|
||||
err := r.db.SelectRow(ctx, &result, q, id)
|
||||
switch {
|
||||
case errors.Is(err, sql.ErrNoRows):
|
||||
return nil, domain.ErrDomainNotFound
|
||||
case err != nil:
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
default:
|
||||
return &result, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r Domain) GetDomainByIdList(ctx context.Context, idList []int) ([]entity.Domain, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.GetDomainByIdList")
|
||||
|
||||
q, args, err := query.New().
|
||||
Select("id", "name", "description", "system_id", "created_at", "updated_at").
|
||||
From("domain").
|
||||
Where(squirrel.Eq{"id": idList}).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
result := make([]entity.Domain, 0)
|
||||
err = r.db.Select(ctx, &result, q, args...)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "select db")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r Domain) GetDomainBySystemId(ctx context.Context, systemId int) ([]entity.Domain, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.GetDomainBySystemId")
|
||||
|
||||
q := `
|
||||
SELECT id, name, description, system_id, created_at, updated_at
|
||||
FROM domain
|
||||
WHERE system_id = $1
|
||||
ORDER BY created_at DESC
|
||||
`
|
||||
result := make([]entity.Domain, 0)
|
||||
err := r.db.Select(ctx, &result, q, systemId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r Domain) GetDomainByNameAndSystemId(ctx context.Context, name string, systemId int) (*entity.Domain, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.GetDomainByNameAndSystemId")
|
||||
|
||||
q := `
|
||||
SELECT id, name, description, system_id, created_at, updated_at
|
||||
FROM domain
|
||||
WHERE name = $1 AND system_id = $2
|
||||
`
|
||||
result := entity.Domain{}
|
||||
err := r.db.SelectRow(ctx, &result, q, name, systemId)
|
||||
switch {
|
||||
case errors.Is(err, sql.ErrNoRows):
|
||||
return nil, domain.ErrDomainNotFound
|
||||
case err != nil:
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
default:
|
||||
return &result, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r Domain) CreateDomain(ctx context.Context, name string, desc string, systemId int) (*entity.Domain, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.CreateDomain")
|
||||
|
||||
q := `
|
||||
INSERT INTO domain
|
||||
(name, description, system_id)
|
||||
VALUES ($1, $2, $3)
|
||||
RETURNING id, name, description, system_id, created_at, updated_at
|
||||
`
|
||||
result := entity.Domain{}
|
||||
err := r.db.SelectRow(ctx, &result, q, name, desc, systemId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r Domain) UpdateDomain(ctx context.Context, id int, name string, description string) (*entity.Domain, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.UpdateDomain")
|
||||
|
||||
q := `
|
||||
UPDATE domain
|
||||
SET name = $1, description = $2
|
||||
WHERE id = $3
|
||||
RETURNING id, name, description, system_id, created_at, updated_at
|
||||
`
|
||||
result := entity.Domain{}
|
||||
err := r.db.SelectRow(ctx, &result, q, name, description, id)
|
||||
switch {
|
||||
case errors.Is(err, sql.ErrNoRows):
|
||||
return nil, domain.ErrDomainNotFound
|
||||
case err != nil:
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
default:
|
||||
return &result, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r Domain) DeleteDomain(ctx context.Context, idList []int) (int, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.DeleteDomain")
|
||||
|
||||
q, args, err := query.New().
|
||||
Delete("domain").
|
||||
Where(squirrel.Eq{"id": idList}).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return 0, errors.WithMessagef(err, "build query")
|
||||
}
|
||||
|
||||
result, err := r.db.Exec(ctx, q, args...)
|
||||
if err != nil {
|
||||
return 0, errors.WithMessagef(err, "exec query %s", q)
|
||||
}
|
||||
|
||||
rowsAffected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return 0, errors.WithMessagef(err, "get rows affected")
|
||||
}
|
||||
|
||||
return int(rowsAffected), nil
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"hash/fnv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/db"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||
)
|
||||
|
||||
|
||||
+8
-4
@@ -8,9 +8,9 @@ import (
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/db"
|
||||
"github.com/txix-open/isp-kit/db/query"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||
)
|
||||
|
||||
@@ -112,10 +112,14 @@ func (r Token) AuthDataByToken(ctx context.Context, token string) (*entity.AuthD
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.AuthDataByToken")
|
||||
|
||||
q := `
|
||||
SELECT app_id, application.name AS app_name , token.expire_time, token.created_at
|
||||
SELECT system_id, domain_id, application_group_id, app_id, application.name AS app_name , token.expire_time, token.created_at
|
||||
FROM token
|
||||
LEFT JOIN application
|
||||
ON token.app_id = application.id
|
||||
LEFT JOIN application
|
||||
ON token.app_id = application.id
|
||||
LEFT JOIN application_group
|
||||
ON application.application_group_id = application_group.id
|
||||
LEFT JOIN domain
|
||||
ON application_group.domain_id = domain.id
|
||||
WHERE token = $1
|
||||
`
|
||||
result := entity.AuthData{}
|
||||
|
||||
+70
-28
@@ -12,6 +12,8 @@ import (
|
||||
|
||||
type Controllers struct {
|
||||
AccessList controller.AccessList
|
||||
Domain controller.Domain
|
||||
Service controller.Service
|
||||
Application controller.Application
|
||||
AppGroup controller.AppGroup
|
||||
Token controller.Token
|
||||
@@ -31,9 +33,11 @@ func Handler(wrapper endpoint.Wrapper, c Controllers) *grpc.Mux {
|
||||
}
|
||||
|
||||
func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor {
|
||||
return concatEndpoints(
|
||||
return concatCluster(
|
||||
secureCluster(c),
|
||||
accessListCluster(c),
|
||||
domainCluster(c),
|
||||
serviceCluster(c),
|
||||
applicationCluster(c),
|
||||
tokenCluster(c),
|
||||
applicationGroupCluster(c),
|
||||
@@ -61,74 +65,124 @@ func accessListCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||
{
|
||||
Path: "system/access_list/get_by_id",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("app_access_view"),
|
||||
Handler: c.AccessList.GetById,
|
||||
},
|
||||
{
|
||||
Path: "system/access_list/set_one",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("app_access_edit"),
|
||||
Handler: c.AccessList.SetOne,
|
||||
},
|
||||
{
|
||||
Path: "system/access_list/set_list",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("app_access_edit"),
|
||||
Handler: c.AccessList.SetList,
|
||||
},
|
||||
{
|
||||
Path: "system/access_list/delete_list",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("app_access_edit"),
|
||||
Handler: c.AccessList.DeleteList,
|
||||
},
|
||||
{
|
||||
Path: "system/access_list/delete_list_with_methods",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("app_access_edit"),
|
||||
Handler: c.AccessList.DeleteListWithMethods,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func domainCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||
return []cluster.EndpointDescriptor{
|
||||
{
|
||||
Path: "system/domain/get_domains_by_system_id",
|
||||
Inner: true,
|
||||
Handler: c.Domain.GetBySystemId,
|
||||
},
|
||||
{
|
||||
Path: "system/domain/create_update_domain",
|
||||
Inner: true,
|
||||
Handler: c.Domain.CreateUpdate,
|
||||
},
|
||||
{
|
||||
Path: "system/domain/get_domain_by_id",
|
||||
Inner: true,
|
||||
Handler: c.Domain.GetById,
|
||||
},
|
||||
{
|
||||
Path: "system/domain/delete_domains",
|
||||
Inner: true,
|
||||
Handler: c.Domain.Delete,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// deprecated
|
||||
func serviceCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||
return []cluster.EndpointDescriptor{
|
||||
{
|
||||
Path: "system/service/get_service",
|
||||
Inner: true,
|
||||
Handler: c.Service.Get,
|
||||
},
|
||||
{
|
||||
Path: "system/service/get_services_by_domain_id",
|
||||
Inner: true,
|
||||
Handler: c.Service.GetByDomainId,
|
||||
},
|
||||
{
|
||||
Path: "system/service/create_update_service",
|
||||
Inner: true,
|
||||
Handler: c.Service.CreateUpdate,
|
||||
},
|
||||
{
|
||||
Path: "system/service/get_service_by_id",
|
||||
Inner: true,
|
||||
Handler: c.Service.GetById,
|
||||
},
|
||||
{
|
||||
Path: "system/service/delete_service",
|
||||
Inner: true,
|
||||
Handler: c.Service.Delete,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func applicationCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||
return []cluster.EndpointDescriptor{
|
||||
{
|
||||
Path: "system/application/get_applications",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_view"),
|
||||
Handler: c.Application.GetByIdList,
|
||||
},
|
||||
{
|
||||
Path: "system/application/get_by_app_group",
|
||||
Extra: cluster.RequireAdminPermission("application_group_view"),
|
||||
Path: "system/application/get_applications_by_service_id",
|
||||
Inner: true,
|
||||
Handler: c.Application.GetByAppGroup,
|
||||
Handler: c.Application.GetByServiceId,
|
||||
},
|
||||
{
|
||||
Path: "system/application/create_update_application",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_app_edit"),
|
||||
Handler: c.Application.CreateUpdate,
|
||||
},
|
||||
{
|
||||
Path: "system/application/get_application_by_id",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_view"),
|
||||
Handler: c.Application.GetById,
|
||||
},
|
||||
{
|
||||
Path: "system/application/get_application_by_token",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_view"),
|
||||
Handler: c.Application.GetByToken,
|
||||
},
|
||||
{
|
||||
Path: "system/application/delete_applications",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_app_delete"),
|
||||
Handler: c.Application.Delete,
|
||||
},
|
||||
{
|
||||
Path: "system/application/get_system_tree",
|
||||
Inner: true,
|
||||
Handler: c.Application.GetSystemTree,
|
||||
},
|
||||
{
|
||||
Path: "system/application/next_id",
|
||||
Inner: true,
|
||||
@@ -137,18 +191,15 @@ func applicationCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||
{
|
||||
Path: "system/application/get_all",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_view"),
|
||||
Handler: c.Application.GetAll,
|
||||
},
|
||||
{
|
||||
Path: "system/application/create_application",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_app_add"),
|
||||
Handler: c.Application.Create,
|
||||
}, {
|
||||
Path: "system/application/update_application",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_app_edit"),
|
||||
Handler: c.Application.Update,
|
||||
},
|
||||
}
|
||||
@@ -159,25 +210,21 @@ func tokenCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||
{
|
||||
Path: "system/token/create_token",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_token_add"),
|
||||
Handler: c.Token.Create,
|
||||
},
|
||||
{
|
||||
Path: "system/token/revoke_tokens",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_token_delete"),
|
||||
Handler: c.Token.Revoke,
|
||||
},
|
||||
{
|
||||
Path: "system/token/revoke_tokens_for_app",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_token_delete"),
|
||||
Handler: c.Token.RevokeForApp,
|
||||
},
|
||||
{
|
||||
Path: "system/token/get_tokens_by_app_id",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_token_view"),
|
||||
Handler: c.Token.GetByAppId,
|
||||
},
|
||||
}
|
||||
@@ -188,27 +235,22 @@ func applicationGroupCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||
{
|
||||
Path: "system/application_group/create",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_add"),
|
||||
Handler: c.AppGroup.Create,
|
||||
}, {
|
||||
Path: "system/application_group/update",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_edit"),
|
||||
Handler: c.AppGroup.Update,
|
||||
}, {
|
||||
Path: "system/application_group/delete_list",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_delete"),
|
||||
Handler: c.AppGroup.DeleteList,
|
||||
}, {
|
||||
Path: "system/application_group/get_by_id_list",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_view"),
|
||||
Handler: c.AppGroup.GetByIdList,
|
||||
}, {
|
||||
Path: "system/application_group/get_all",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("application_group_view"),
|
||||
Handler: c.AppGroup.GetAll,
|
||||
},
|
||||
}
|
||||
@@ -221,9 +263,9 @@ func commonEndpoints() []cluster.EndpointDescriptor {
|
||||
)
|
||||
}
|
||||
|
||||
func concatEndpoints(endpoints ...[]cluster.EndpointDescriptor) []cluster.EndpointDescriptor {
|
||||
func concatCluster(clusters ...[]cluster.EndpointDescriptor) []cluster.EndpointDescriptor {
|
||||
var result []cluster.EndpointDescriptor
|
||||
for _, c := range endpoints {
|
||||
for _, c := range clusters {
|
||||
result = append(result, c...)
|
||||
}
|
||||
return result
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type AccessListRepo interface {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type AppGroup struct {
|
||||
@@ -19,7 +19,7 @@ func NewAppGroup(repo AppGroupRepo) AppGroup {
|
||||
}
|
||||
|
||||
func (s AppGroup) Create(ctx context.Context, req domain.CreateAppGroupRequest) (*domain.AppGroup, error) {
|
||||
appGroup, err := s.repo.CreateAppGroup(ctx, req.Name, req.Description)
|
||||
appGroup, err := s.repo.CreateAppGroup(ctx, req.Name, req.Description, 1)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create appGroup")
|
||||
}
|
||||
|
||||
+128
-38
@@ -6,7 +6,7 @@ import (
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type ApplicationDeleteTx interface {
|
||||
@@ -20,6 +20,7 @@ type ApplicationTxRunner interface {
|
||||
type Application struct {
|
||||
txRunner ApplicationTxRunner
|
||||
appRepo ApplicationRepo
|
||||
domainRepo DomainRepo
|
||||
serviceRepo AppGroupRepo
|
||||
tokenRepo TokenRepo
|
||||
}
|
||||
@@ -27,24 +28,31 @@ type Application struct {
|
||||
func NewApplication(
|
||||
txRunner ApplicationTxRunner,
|
||||
applicationRepo ApplicationRepo,
|
||||
domainRepo DomainRepo,
|
||||
appGroupRepo AppGroupRepo,
|
||||
tokenRepo TokenRepo,
|
||||
) Application {
|
||||
return Application{
|
||||
txRunner: txRunner,
|
||||
appRepo: applicationRepo,
|
||||
domainRepo: domainRepo,
|
||||
serviceRepo: appGroupRepo,
|
||||
tokenRepo: tokenRepo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Application) GetById(ctx context.Context, appId int) (*domain.Application, error) {
|
||||
app, err := s.appRepo.GetApplicationById(ctx, appId)
|
||||
func (s Application) GetById(ctx context.Context, appId int) (*domain.ApplicationWithTokens, error) {
|
||||
application, err := s.appRepo.GetApplicationById(ctx, appId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get application by id")
|
||||
}
|
||||
|
||||
return new(s.convertApplication(*app)), nil
|
||||
arr, err := s.EnrichWithTokens(ctx, []entity.Application{*application})
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "enrich application with tokens")
|
||||
}
|
||||
|
||||
return arr[0], nil
|
||||
}
|
||||
|
||||
func (s Application) GetByToken(ctx context.Context, tokenStr string) (*domain.GetApplicationByTokenResponse, error) {
|
||||
@@ -66,53 +74,127 @@ func (s Application) GetByToken(ctx context.Context, tokenStr string) (*domain.G
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s Application) GetByIdList(ctx context.Context, idList []int) ([]domain.Application, error) {
|
||||
apps, err := s.appRepo.GetApplicationByIdList(ctx, idList)
|
||||
func (s Application) GetByIdList(ctx context.Context, idList []int) ([]*domain.ApplicationWithTokens, error) {
|
||||
res, err := s.appRepo.GetApplicationByIdList(ctx, idList)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get application by id list")
|
||||
}
|
||||
|
||||
result := make([]domain.Application, len(apps))
|
||||
for i, a := range apps {
|
||||
result[i] = s.convertApplication(a)
|
||||
}
|
||||
return result, nil
|
||||
return s.EnrichWithTokens(ctx, res)
|
||||
}
|
||||
|
||||
func (s Application) GetByAppGroup(ctx context.Context, appGroupId int) ([]domain.Application, error) {
|
||||
apps, err := s.appRepo.GetApplicationByAppGroupIdList(ctx, []int{appGroupId})
|
||||
func (s Application) GetByServiceId(ctx context.Context, id int) ([]*domain.ApplicationWithTokens, error) {
|
||||
arr, err := s.appRepo.GetApplicationByAppGroupIdList(ctx, []int{id})
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get apps by app group ids")
|
||||
return nil, errors.WithMessage(err, "get application by app_group_id")
|
||||
}
|
||||
|
||||
result := make([]domain.Application, len(apps))
|
||||
for i, a := range apps {
|
||||
result[i] = s.convertApplication(a)
|
||||
return s.EnrichWithTokens(ctx, arr)
|
||||
}
|
||||
|
||||
func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithService, error) {
|
||||
domainEntityList, err := s.domainRepo.GetDomainBySystemId(ctx, systemId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get domains by system_id")
|
||||
}
|
||||
if len(domainEntityList) == 0 {
|
||||
return []*domain.DomainWithService{}, nil
|
||||
}
|
||||
|
||||
result := make([]*domain.DomainWithService, len(domainEntityList))
|
||||
resultByDomainId := make(map[int]*domain.DomainWithService, len(domainEntityList))
|
||||
domainIdList := make([]int, len(domainEntityList))
|
||||
for i, domainEntity := range domainEntityList {
|
||||
domainIdList[i] = domainEntity.Id
|
||||
description := ""
|
||||
if domainEntity.Description != nil {
|
||||
description = *domainEntity.Description
|
||||
}
|
||||
r := &domain.DomainWithService{
|
||||
Id: domainEntity.Id,
|
||||
Name: domainEntity.Name,
|
||||
Description: description,
|
||||
Services: make([]*domain.ServiceWithApps, 0),
|
||||
}
|
||||
resultByDomainId[domainEntity.Id] = r
|
||||
result[i] = r
|
||||
}
|
||||
|
||||
serviceEntityList, err := s.serviceRepo.GetAppGroupByDomainId(ctx, domainIdList)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get service by domain_id")
|
||||
}
|
||||
|
||||
serviceIdList := make([]int, len(serviceEntityList))
|
||||
resultServiceByServiceId := make(map[int]*domain.ServiceWithApps, len(serviceEntityList))
|
||||
for i, serviceEntity := range serviceEntityList {
|
||||
serviceIdList[i] = serviceEntity.Id
|
||||
resultService := &domain.ServiceWithApps{
|
||||
Id: serviceEntity.Id,
|
||||
Name: serviceEntity.Name,
|
||||
Description: serviceEntity.Description.String,
|
||||
Apps: make([]*domain.ApplicationSimple, 0),
|
||||
}
|
||||
r := resultByDomainId[serviceEntity.DomainId]
|
||||
r.Services = append(r.Services, resultService)
|
||||
resultServiceByServiceId[serviceEntity.Id] = resultService
|
||||
}
|
||||
|
||||
applicationEntityList, err := s.appRepo.GetApplicationByAppGroupIdList(ctx, serviceIdList)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get application by service_id")
|
||||
}
|
||||
|
||||
for _, applicationEntity := range applicationEntityList {
|
||||
resultService := resultServiceByServiceId[applicationEntity.ApplicationGroupId]
|
||||
resultService.Apps = append(resultService.Apps, &domain.ApplicationSimple{
|
||||
Id: applicationEntity.Id,
|
||||
Name: applicationEntity.Name,
|
||||
Type: applicationEntity.Type,
|
||||
Description: applicationEntity.Description.String,
|
||||
Tokens: make([]domain.Token, 0),
|
||||
})
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.Application, error) {
|
||||
if req.Id != 0 {
|
||||
app, err := s.appRepo.UpdateApplication(ctx, req.Id, req.Name, req.Description)
|
||||
func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error) {
|
||||
if req.Id == 0 {
|
||||
_, err := s.appRepo.GetApplicationByNameAndAppGroupId(ctx, req.Name, req.ServiceId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "update application")
|
||||
return nil, errors.WithMessage(err, "get application by name and service_id")
|
||||
}
|
||||
|
||||
return new(s.convertApplication(*app)), nil
|
||||
appId, err := s.appRepo.NextApplicationId(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "next app id")
|
||||
}
|
||||
|
||||
app, err := s.appRepo.CreateApplication(ctx, appId, req.Name, req.Description, req.ServiceId, req.Type)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create application")
|
||||
}
|
||||
|
||||
result, err := s.EnrichWithTokens(ctx, []entity.Application{*app})
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "enrich application with tokens")
|
||||
}
|
||||
|
||||
return result[0], nil
|
||||
}
|
||||
|
||||
appId, err := s.appRepo.NextApplicationId(ctx)
|
||||
app, err := s.appRepo.UpdateApplication(ctx, req.Id, req.Name, req.Description)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "next app id")
|
||||
return nil, errors.WithMessage(err, "update application")
|
||||
}
|
||||
|
||||
app, err := s.appRepo.CreateApplication(ctx, appId, req.Name, req.Description, req.ApplicationGroupId, req.Type)
|
||||
result, err := s.EnrichWithTokens(ctx, []entity.Application{*app})
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create application")
|
||||
return nil, errors.WithMessage(err, "enrich application with tokens")
|
||||
}
|
||||
|
||||
return new(s.convertApplication(*app)), nil
|
||||
return result[0], nil
|
||||
}
|
||||
|
||||
func (s Application) Delete(ctx context.Context, idList []int) (int, error) {
|
||||
@@ -185,32 +267,40 @@ func (s Application) GetAll(ctx context.Context) ([]domain.Application, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Application) Create(ctx context.Context, req domain.CreateApplicationRequest) (*domain.Application, error) {
|
||||
func (s Application) Create(ctx context.Context, req domain.CreateApplicationRequest) (*domain.ApplicationWithTokens, error) {
|
||||
app, err := s.appRepo.CreateApplication(ctx, req.Id, req.Name, req.Description, req.ApplicationGroupId, req.Type)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create application")
|
||||
}
|
||||
|
||||
return new(s.convertApplication(*app)), nil
|
||||
return &domain.ApplicationWithTokens{
|
||||
App: s.convertApplication(*app),
|
||||
Tokens: make([]domain.Token, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s Application) Update(ctx context.Context, req domain.UpdateApplicationRequest) (*domain.Application, error) {
|
||||
func (s Application) Update(ctx context.Context, req domain.UpdateApplicationRequest) (*domain.ApplicationWithTokens, error) {
|
||||
app, err := s.appRepo.UpdateApplicationWithNewId(ctx, req.OldId, req.NewId, req.Name, req.Description)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "update application")
|
||||
}
|
||||
|
||||
return new(s.convertApplication(*app)), nil
|
||||
result, err := s.EnrichWithTokens(ctx, []entity.Application{*app})
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "enrich application with tokens")
|
||||
}
|
||||
|
||||
return result[0], nil
|
||||
}
|
||||
|
||||
func (s Application) convertApplication(req entity.Application) domain.Application {
|
||||
return domain.Application{
|
||||
Id: req.Id,
|
||||
Name: req.Name,
|
||||
Description: req.Description.String,
|
||||
ApplicationGroupId: req.ApplicationGroupId,
|
||||
Type: req.Type,
|
||||
CreatedAt: req.CreatedAt,
|
||||
UpdatedAt: req.UpdatedAt,
|
||||
Id: req.Id,
|
||||
Name: req.Name,
|
||||
Description: req.Description.String,
|
||||
ServiceId: req.ApplicationGroupId,
|
||||
Type: req.Type,
|
||||
CreatedAt: req.CreatedAt,
|
||||
UpdatedAt: req.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,15 @@ import (
|
||||
"isp-system-service/conf"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
const adminAppId = 1
|
||||
|
||||
type Transaction interface {
|
||||
CreateAppGroup(ctx context.Context, name string, desc string) (*entity.AppGroup, error)
|
||||
CreateDomain(ctx context.Context, name string, desc string, systemId int) (*entity.Domain, error)
|
||||
CreateAppGroup(ctx context.Context, name string, desc string, domainId int) (*entity.AppGroup, error)
|
||||
CreateApplication(ctx context.Context, id int, name string, desc string, appGroupId int, appType string) (*entity.Application, error)
|
||||
UpsertAccessList(ctx context.Context, e entity.AccessList) (int, error)
|
||||
SaveToken(ctx context.Context, token string, appId int, expireTime int) (*entity.Token, error)
|
||||
@@ -74,7 +75,12 @@ func (s Service) transaction(ctx context.Context, tx Transaction) error {
|
||||
|
||||
s.logger.Info(ctx, "initial admin ui token is empty, run baseline")
|
||||
|
||||
service, err := tx.CreateAppGroup(ctx, "rootService", "")
|
||||
domain, err := tx.CreateDomain(ctx, "root", "", 1)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "create domain")
|
||||
}
|
||||
|
||||
service, err := tx.CreateAppGroup(ctx, "rootService", "", domain.Id)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "create service")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Domain struct {
|
||||
repo DomainRepo
|
||||
}
|
||||
|
||||
func NewDomain(repo DomainRepo) Domain {
|
||||
return Domain{
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Domain) GetById(ctx context.Context, id int) (*domain.Domain, error) {
|
||||
domainEntity, err := s.repo.GetDomainById(ctx, id)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get domain by id")
|
||||
}
|
||||
|
||||
result := s.convertDomain(*domainEntity)
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (s Domain) GetBySystemId(ctx context.Context, systemId int) ([]domain.Domain, error) {
|
||||
domainEntity, err := s.repo.GetDomainBySystemId(ctx, systemId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get domain by system_id")
|
||||
}
|
||||
|
||||
result := make([]domain.Domain, len(domainEntity))
|
||||
for i := range domainEntity {
|
||||
result[i] = s.convertDomain(domainEntity[i])
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Domain) CreateUpdate(ctx context.Context, req domain.DomainCreateUpdateRequest, systemId int) (*domain.Domain, error) {
|
||||
existed, err := s.repo.GetDomainByNameAndSystemId(ctx, req.Name, systemId)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrDomainNotFound):
|
||||
case err != nil:
|
||||
return nil, errors.WithMessage(err, "get domain by name and system_id")
|
||||
}
|
||||
|
||||
if req.Id == 0 {
|
||||
if existed != nil {
|
||||
return nil, domain.ErrDomainDuplicateName
|
||||
}
|
||||
|
||||
domainEntity, err := s.repo.CreateDomain(ctx, req.Name, req.Description, systemId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create domain")
|
||||
}
|
||||
|
||||
result := s.convertDomain(*domainEntity)
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
if existed != nil && existed.Id != req.Id {
|
||||
return nil, domain.ErrDomainDuplicateName
|
||||
}
|
||||
|
||||
_, err = s.repo.GetDomainById(ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get domain by id")
|
||||
}
|
||||
|
||||
domainEntity, err := s.repo.UpdateDomain(ctx, req.Id, req.Name, req.Description)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "update domain")
|
||||
}
|
||||
|
||||
result := s.convertDomain(*domainEntity)
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (s Domain) Delete(ctx context.Context, idList []int) (int, error) {
|
||||
result, err := s.repo.DeleteDomain(ctx, idList)
|
||||
if err != nil {
|
||||
return 0, errors.WithMessage(err, "delete domain")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Domain) convertDomain(req entity.Domain) domain.Domain {
|
||||
desc := ""
|
||||
if req.Description != nil {
|
||||
desc = *req.Description
|
||||
}
|
||||
result := domain.Domain{
|
||||
Id: req.Id,
|
||||
Name: req.Name,
|
||||
Description: desc,
|
||||
SystemId: req.SystemId,
|
||||
CreatedAt: req.CreatedAt,
|
||||
UpdatedAt: req.UpdatedAt,
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
+13
-2
@@ -10,10 +10,20 @@ type TokenRepo interface {
|
||||
GetTokenById(ctx context.Context, token string) (*entity.Token, error)
|
||||
}
|
||||
|
||||
type DomainRepo interface {
|
||||
GetDomainById(ctx context.Context, id int) (*entity.Domain, error)
|
||||
GetDomainBySystemId(ctx context.Context, systemId int) ([]entity.Domain, error)
|
||||
GetDomainByNameAndSystemId(ctx context.Context, name string, systemId int) (*entity.Domain, error)
|
||||
CreateDomain(ctx context.Context, name string, desc string, systemId int) (*entity.Domain, error)
|
||||
UpdateDomain(ctx context.Context, id int, name string, description string) (*entity.Domain, error)
|
||||
DeleteDomain(ctx context.Context, idList []int) (int, error)
|
||||
}
|
||||
|
||||
type ApplicationRepo interface {
|
||||
GetApplicationById(ctx context.Context, id int) (*entity.Application, error)
|
||||
GetApplicationByIdList(ctx context.Context, idList []int) ([]entity.Application, error)
|
||||
GetApplicationByAppGroupIdList(ctx context.Context, appGroupIdList []int) ([]entity.Application, error)
|
||||
GetApplicationByNameAndAppGroupId(ctx context.Context, name string, appGroupId int) (*entity.Application, error)
|
||||
CreateApplication(ctx context.Context, id int, name string, desc string, appGroupId int, appType string) (*entity.Application, error)
|
||||
UpdateApplication(ctx context.Context, id int, name string, description string) (*entity.Application, error)
|
||||
UpdateApplicationWithNewId(ctx context.Context, oldId int, newId int, name string, description string) (*entity.Application, error)
|
||||
@@ -24,9 +34,10 @@ type ApplicationRepo interface {
|
||||
type AppGroupRepo interface {
|
||||
GetAppGroupById(ctx context.Context, id int) (*entity.AppGroup, error)
|
||||
GetAppGroupByIdList(ctx context.Context, idList []int) ([]entity.AppGroup, error)
|
||||
GetAppGroupByDomainId(ctx context.Context, domainIdList []int) ([]entity.AppGroup, error)
|
||||
GetAllAppGroups(ctx context.Context) ([]entity.AppGroup, error)
|
||||
GetAppGroupByName(ctx context.Context, name string) (*entity.AppGroup, error)
|
||||
CreateAppGroup(ctx context.Context, name string, desc string) (*entity.AppGroup, error)
|
||||
GetAppGroupByNameAndDomainId(ctx context.Context, name string, domainId int) (*entity.AppGroup, error)
|
||||
CreateAppGroup(ctx context.Context, name string, desc string, domainId int) (*entity.AppGroup, error)
|
||||
UpdateAppGroup(ctx context.Context, id int, name string, description string) (*entity.AppGroup, error)
|
||||
DeleteAppGroup(ctx context.Context, idList []int) (int, error)
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type TokenRep interface {
|
||||
@@ -46,6 +46,9 @@ func (s Service) Authenticate(ctx context.Context, token string) (*domain.AuthDa
|
||||
|
||||
return &domain.AuthData{
|
||||
AppName: authData.AppName,
|
||||
SystemId: authData.SystemId,
|
||||
DomainId: authData.DomainId,
|
||||
ServiceId: authData.ApplicationGroupId,
|
||||
ApplicationId: authData.AppId,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
domainRepo DomainRepo
|
||||
serviceRepo AppGroupRepo
|
||||
}
|
||||
|
||||
func NewService(
|
||||
domainRepo DomainRepo,
|
||||
serviceRepo AppGroupRepo,
|
||||
) Service {
|
||||
return Service{
|
||||
domainRepo: domainRepo,
|
||||
serviceRepo: serviceRepo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Service) GetById(ctx context.Context, id int) (*domain.Service, error) {
|
||||
serviceEntity, err := s.serviceRepo.GetAppGroupById(ctx, id)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get service by id")
|
||||
}
|
||||
|
||||
result := s.convertService(*serviceEntity)
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (s Service) GetByIdList(ctx context.Context, idList []int) ([]domain.Service, error) {
|
||||
serviceEntity, err := s.serviceRepo.GetAppGroupByIdList(ctx, idList)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get system by id list")
|
||||
}
|
||||
|
||||
result := make([]domain.Service, len(serviceEntity))
|
||||
for i := range serviceEntity {
|
||||
result[i] = s.convertService(serviceEntity[i])
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Service) GetByDomainId(ctx context.Context, domainId int) ([]domain.Service, error) {
|
||||
serviceEntity, err := s.serviceRepo.GetAppGroupByDomainId(ctx, []int{domainId})
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get system by id list")
|
||||
}
|
||||
|
||||
result := make([]domain.Service, len(serviceEntity))
|
||||
for i := range serviceEntity {
|
||||
result[i] = s.convertService(serviceEntity[i])
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdateRequest) (*domain.Service, error) {
|
||||
req.DomainId = 1 // temporary use only 1 domain, soon domain entity will be removed
|
||||
|
||||
_, err := s.domainRepo.GetDomainById(ctx, req.DomainId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get domain by id")
|
||||
}
|
||||
|
||||
if req.Id == 0 {
|
||||
serviceEntity, err := s.serviceRepo.CreateAppGroup(ctx, req.Name, req.Description, req.DomainId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create service")
|
||||
}
|
||||
|
||||
result := s.convertService(*serviceEntity)
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
_, err = s.serviceRepo.GetAppGroupById(ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get service by id")
|
||||
}
|
||||
|
||||
serviceEntity, err := s.serviceRepo.UpdateAppGroup(ctx, req.Id, req.Name, req.Description)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "update service")
|
||||
}
|
||||
|
||||
result := s.convertService(*serviceEntity)
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (s Service) Delete(ctx context.Context, idList []int) (int, error) {
|
||||
result, err := s.serviceRepo.DeleteAppGroup(ctx, idList)
|
||||
if err != nil {
|
||||
return 0, errors.WithMessage(err, "delete service")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Service) convertService(req entity.AppGroup) domain.Service {
|
||||
result := domain.Service{
|
||||
Id: req.Id,
|
||||
Name: req.Name,
|
||||
Description: req.Description.String,
|
||||
DomainId: req.DomainId,
|
||||
CreatedAt: req.CreatedAt,
|
||||
UpdatedAt: req.UpdatedAt,
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
+17
-1
@@ -6,7 +6,7 @@ import (
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type ApplicationTokenCreator interface {
|
||||
@@ -35,6 +35,8 @@ type Token struct {
|
||||
appEnricher AppEnricher
|
||||
tx TokenTxRunner
|
||||
appRepo ApplicationRepo
|
||||
domainRepo DomainRepo
|
||||
serviceRepo AppGroupRepo
|
||||
tokenRepo TokenRepo
|
||||
}
|
||||
|
||||
@@ -43,6 +45,8 @@ func NewToken(
|
||||
appEnricher AppEnricher,
|
||||
tx TokenTxRunner,
|
||||
appRepo ApplicationRepo,
|
||||
domainRepo DomainRepo,
|
||||
appGroupRepo AppGroupRepo,
|
||||
tokenRepo TokenRepo,
|
||||
) Token {
|
||||
return Token{
|
||||
@@ -50,6 +54,8 @@ func NewToken(
|
||||
jwt: jwtGenerate,
|
||||
tx: tx,
|
||||
appRepo: appRepo,
|
||||
domainRepo: domainRepo,
|
||||
serviceRepo: appGroupRepo,
|
||||
tokenRepo: tokenRepo,
|
||||
}
|
||||
}
|
||||
@@ -74,6 +80,16 @@ func (s Token) Create(ctx context.Context, req domain.TokenCreateRequest) (*doma
|
||||
return nil, errors.WithMessage(err, "get application by id")
|
||||
}
|
||||
|
||||
serviceEntity, err := s.serviceRepo.GetAppGroupById(ctx, applicationEntity.ApplicationGroupId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get service by id")
|
||||
}
|
||||
|
||||
_, err = s.domainRepo.GetDomainById(ctx, serviceEntity.DomainId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get domain by id")
|
||||
}
|
||||
|
||||
token, err := s.jwt.CreateApplicationToken()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create application token")
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type TokenSource struct{}
|
||||
|
||||
@@ -44,10 +44,19 @@ func (s *AccessListSuite) SetupTest() {
|
||||
_, s.api = grpct.TestServer(s.test, config.Handler)
|
||||
s.accessListRepo = repository.NewAccessList(s.testDb)
|
||||
|
||||
createdDomain, err := repository.NewDomain(s.testDb).CreateDomain(
|
||||
s.T().Context(),
|
||||
fake.It[string](),
|
||||
fake.It[string](),
|
||||
1,
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
appGroup, err := repository.NewAppGroup(s.testDb).CreateAppGroup(
|
||||
s.T().Context(),
|
||||
fake.It[string](),
|
||||
fake.It[string](),
|
||||
createdDomain.Id,
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ type AppGroupSuite struct {
|
||||
|
||||
test *test.Test
|
||||
testDb *dbt.TestDb
|
||||
domainRepo repository.Domain
|
||||
appGroupRepo repository.AppGroup
|
||||
api *client.Client
|
||||
}
|
||||
@@ -41,7 +42,17 @@ func (s *AppGroupSuite) SetupTest() {
|
||||
locator := assembly.NewLocator(s.testDb, s.test.Logger())
|
||||
config := locator.Config(conf.Remote{})
|
||||
_, s.api = grpct.TestServer(s.test, config.Handler)
|
||||
s.domainRepo = repository.NewDomain(s.testDb)
|
||||
s.appGroupRepo = repository.NewAppGroup(s.testDb)
|
||||
|
||||
q := `
|
||||
INSERT INTO domain
|
||||
(id, name, description, system_id)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, name, description, system_id, created_at, updated_at
|
||||
`
|
||||
_, err := s.testDb.Exec(s.T().Context(), q, 1, fake.It[string](), fake.It[string](), 1)
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
func (s *AppGroupSuite) TestGetByIdList() {
|
||||
@@ -85,6 +96,7 @@ func (s *AppGroupSuite) TestGetByIdList_EmptyDescription() {
|
||||
s.T().Context(),
|
||||
fake.It[string](),
|
||||
"",
|
||||
1,
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
appGroups = append(appGroups, domain.AppGroup{
|
||||
@@ -269,6 +281,7 @@ func (s *AppGroupSuite) createAppGroup() *entity.AppGroup {
|
||||
s.T().Context(),
|
||||
fake.It[string](),
|
||||
fake.It[string](),
|
||||
1,
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
return appGroup
|
||||
|
||||
+46
-70
@@ -6,7 +6,6 @@ import (
|
||||
"isp-system-service/domain"
|
||||
"isp-system-service/entity"
|
||||
"isp-system-service/repository"
|
||||
"math"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -30,6 +29,7 @@ type ApplicationSuite struct {
|
||||
|
||||
test *test.Test
|
||||
testDb *dbt.TestDb
|
||||
domainRepo repository.Domain
|
||||
appRepo repository.Application
|
||||
appGroupRepo repository.AppGroup
|
||||
tokenRepo repository.Token
|
||||
@@ -44,6 +44,7 @@ func (s *ApplicationSuite) SetupTest() {
|
||||
locator := assembly.NewLocator(s.testDb, s.test.Logger())
|
||||
config := locator.Config(conf.Remote{})
|
||||
_, s.api = grpct.TestServer(s.test, config.Handler)
|
||||
s.domainRepo = repository.NewDomain(s.testDb)
|
||||
s.appRepo = repository.NewApplication(s.testDb)
|
||||
s.appGroupRepo = repository.NewAppGroup(s.testDb)
|
||||
s.tokenRepo = repository.NewToken(s.testDb)
|
||||
@@ -67,44 +68,8 @@ func (s *ApplicationSuite) TestGetAllApplications() {
|
||||
s.Require().ElementsMatch(expectedApps, result)
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) Test_GetByAppId() {
|
||||
expectedApps := s.insertApps(2)
|
||||
|
||||
result := []domain.Application{}
|
||||
err := s.api.Invoke("system/application/get_by_app_group").
|
||||
JsonRequestBody(domain.Identity{
|
||||
Id: expectedApps[0].ApplicationGroupId,
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
|
||||
for i := range result {
|
||||
s.Require().NotEmpty(result[i].CreatedAt)
|
||||
result[i].CreatedAt = time.Time{}
|
||||
|
||||
s.Require().NotEmpty(result[i].UpdatedAt)
|
||||
result[i].UpdatedAt = time.Time{}
|
||||
}
|
||||
s.Require().ElementsMatch(expectedApps, result)
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) Test_GetByAppId_NotFoundAny() {
|
||||
_ = s.insertApps(2)
|
||||
|
||||
result := []domain.Application{}
|
||||
err := s.api.Invoke("system/application/get_by_app_group").
|
||||
JsonRequestBody(domain.Identity{
|
||||
Id: math.MaxInt32,
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Empty(result)
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) TestCreate_HappyPath() {
|
||||
result := domain.Application{}
|
||||
result := domain.ApplicationWithTokens{}
|
||||
appGroup := s.createAppGroup()
|
||||
|
||||
apiReq := domain.CreateApplicationRequest{
|
||||
@@ -120,20 +85,21 @@ func (s *ApplicationSuite) TestCreate_HappyPath() {
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Require().NotEmpty(result.CreatedAt)
|
||||
result.CreatedAt = time.Time{}
|
||||
s.Require().NotEmpty(result.App.CreatedAt)
|
||||
result.App.CreatedAt = time.Time{}
|
||||
|
||||
s.Require().NotEmpty(result.UpdatedAt)
|
||||
result.UpdatedAt = time.Time{}
|
||||
s.Require().NotEmpty(result.App.UpdatedAt)
|
||||
result.App.UpdatedAt = time.Time{}
|
||||
|
||||
expectedApp := domain.Application{
|
||||
Id: apiReq.Id,
|
||||
Name: apiReq.Name,
|
||||
Description: apiReq.Description,
|
||||
Type: apiReq.Type,
|
||||
ApplicationGroupId: apiReq.ApplicationGroupId,
|
||||
Id: apiReq.Id,
|
||||
Name: apiReq.Name,
|
||||
Description: apiReq.Description,
|
||||
Type: apiReq.Type,
|
||||
ServiceId: apiReq.ApplicationGroupId,
|
||||
}
|
||||
s.Require().Equal(expectedApp, result)
|
||||
s.Require().Equal(expectedApp, result.App)
|
||||
s.Require().Empty(result.Tokens)
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) TestCreate_AppGroupNotFound() {
|
||||
@@ -159,7 +125,7 @@ func (s *ApplicationSuite) TestCreate_ApplicationNameNotUniqueInAppGroup() {
|
||||
Id: inserted[0].Id + 1,
|
||||
Name: inserted[0].Name,
|
||||
Type: domain.ApplicationSystemType,
|
||||
ApplicationGroupId: inserted[0].ApplicationGroupId,
|
||||
ApplicationGroupId: inserted[0].ServiceId,
|
||||
}
|
||||
|
||||
err := s.api.Invoke("system/application/create_application").
|
||||
@@ -177,7 +143,7 @@ func (s *ApplicationSuite) TestCreate_ApplicationIdNotUnique() {
|
||||
Id: inserted[0].Id,
|
||||
Name: inserted[0].Name,
|
||||
Type: domain.ApplicationSystemType,
|
||||
ApplicationGroupId: inserted[0].ApplicationGroupId,
|
||||
ApplicationGroupId: inserted[0].ServiceId,
|
||||
}
|
||||
|
||||
err := s.api.Invoke("system/application/create_application").
|
||||
@@ -197,27 +163,28 @@ func (s *ApplicationSuite) TestUpdate_HappyPath() {
|
||||
Description: fake.It[string](),
|
||||
}
|
||||
|
||||
var result domain.Application
|
||||
var result domain.ApplicationWithTokens
|
||||
err := s.api.Invoke("system/application/update_application").
|
||||
JsonRequestBody(apiReq).
|
||||
JsonResponseBody(&result).
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Require().NotEmpty(result.CreatedAt)
|
||||
result.CreatedAt = time.Time{}
|
||||
s.Require().NotEmpty(result.App.CreatedAt)
|
||||
result.App.CreatedAt = time.Time{}
|
||||
|
||||
s.Require().NotEmpty(result.UpdatedAt)
|
||||
result.UpdatedAt = time.Time{}
|
||||
s.Require().NotEmpty(result.App.UpdatedAt)
|
||||
result.App.UpdatedAt = time.Time{}
|
||||
|
||||
expectedApp := domain.Application{
|
||||
Id: apiReq.NewId,
|
||||
Name: apiReq.Name,
|
||||
Description: apiReq.Description,
|
||||
Type: inserted[0].Type,
|
||||
ApplicationGroupId: inserted[0].ApplicationGroupId,
|
||||
Id: apiReq.NewId,
|
||||
Name: apiReq.Name,
|
||||
Description: apiReq.Description,
|
||||
Type: inserted[0].Type,
|
||||
ServiceId: inserted[0].ServiceId,
|
||||
}
|
||||
s.Require().Equal(expectedApp, result)
|
||||
s.Require().Equal(expectedApp, result.App)
|
||||
s.Require().Empty(result.Tokens)
|
||||
|
||||
app, err := s.appRepo.GetApplicationById(s.T().Context(), apiReq.NewId)
|
||||
s.Require().NoError(err)
|
||||
@@ -227,7 +194,7 @@ func (s *ApplicationSuite) TestUpdate_HappyPath() {
|
||||
Name: apiReq.Name,
|
||||
Description: app.Description,
|
||||
Type: inserted[0].Type,
|
||||
ApplicationGroupId: inserted[0].ApplicationGroupId,
|
||||
ApplicationGroupId: inserted[0].ServiceId,
|
||||
}
|
||||
|
||||
s.Require().NotEmpty(app.CreatedAt)
|
||||
@@ -294,7 +261,7 @@ func (s *ApplicationSuite) TestGetByToken() {
|
||||
token := fake.It[string]()
|
||||
expectedApp := domain.GetApplicationByTokenResponse{
|
||||
ApplicationId: insertedApps[0].Id,
|
||||
ApplicationGroupId: insertedApps[0].ApplicationGroupId,
|
||||
ApplicationGroupId: insertedApps[0].ServiceId,
|
||||
}
|
||||
_, err := s.tokenRepo.SaveToken(s.T().Context(), token, expectedApp.ApplicationId, fake.It[int]())
|
||||
s.Require().NoError(err)
|
||||
@@ -322,10 +289,19 @@ func (s *ApplicationSuite) TestGetByToken_NotFound() {
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) createAppGroup() *entity.AppGroup {
|
||||
createdDomain, err := s.domainRepo.CreateDomain(
|
||||
s.T().Context(),
|
||||
fake.It[string](),
|
||||
fake.It[string](),
|
||||
1,
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
appGroup, err := s.appGroupRepo.CreateAppGroup(
|
||||
s.T().Context(),
|
||||
fake.It[string](),
|
||||
fake.It[string](),
|
||||
createdDomain.Id,
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
return appGroup
|
||||
@@ -353,13 +329,13 @@ func (s *ApplicationSuite) insertApps(appsCount uint) []domain.Application {
|
||||
s.Require().NotEmpty(createdApp.UpdatedAt)
|
||||
|
||||
toExpect = append(toExpect, domain.Application{
|
||||
Id: createdApp.Id,
|
||||
Name: createdApp.Name,
|
||||
Description: createdApp.Description.String,
|
||||
ApplicationGroupId: createdApp.ApplicationGroupId,
|
||||
Type: createdApp.Type,
|
||||
CreatedAt: time.Time{},
|
||||
UpdatedAt: time.Time{},
|
||||
Id: createdApp.Id,
|
||||
Name: createdApp.Name,
|
||||
Description: createdApp.Description.String,
|
||||
ServiceId: createdApp.ApplicationGroupId,
|
||||
Type: createdApp.Type,
|
||||
CreatedAt: time.Time{},
|
||||
UpdatedAt: time.Time{},
|
||||
})
|
||||
}
|
||||
return toExpect
|
||||
|
||||
@@ -6,12 +6,22 @@ import (
|
||||
"github.com/txix-open/isp-kit/test/dbt"
|
||||
)
|
||||
|
||||
func InsertDomain(db *dbt.TestDb, value entity.Domain) {
|
||||
q := `
|
||||
INSERT INTO domain
|
||||
(id, name, description, system_id, created_at, updated_at)
|
||||
VALUES
|
||||
(:id, :name, :description, 1, :created_at, :updated_at)
|
||||
`
|
||||
db.Must().ExecNamed(q, value)
|
||||
}
|
||||
|
||||
func InsertAppGroup(db *dbt.TestDb, value entity.AppGroup) {
|
||||
q := `
|
||||
INSERT INTO application_group
|
||||
(id, name, description, created_at, updated_at)
|
||||
(id, name, description, domain_id, created_at, updated_at)
|
||||
VALUES
|
||||
(:id, :name, :description, :created_at, :updated_at)
|
||||
(:id, :name, :description, :domain_id, :created_at, :updated_at)
|
||||
`
|
||||
db.Must().ExecNamed(q, value)
|
||||
}
|
||||
|
||||
+10
-1
@@ -42,8 +42,11 @@ func (s *SecureSuite) SetupSuite() {
|
||||
_, s.api = grpct.TestServer(s.test, config.Handler)
|
||||
|
||||
createdTime := time.Now().UTC()
|
||||
InsertDomain(s.testDb, entity.Domain{
|
||||
Id: 3, Name: "test_domain", SystemId: 1, CreatedAt: createdTime, UpdatedAt: createdTime,
|
||||
})
|
||||
InsertAppGroup(s.testDb, entity.AppGroup{
|
||||
Id: 5, Name: "test_application_group", CreatedAt: createdTime, UpdatedAt: createdTime,
|
||||
Id: 5, Name: "test_application_group", DomainId: 3, CreatedAt: createdTime, UpdatedAt: createdTime,
|
||||
})
|
||||
InsertApplication(s.testDb, entity.Application{
|
||||
Id: 7, Name: "test_application", ApplicationGroupId: 5, CreatedAt: createdTime, UpdatedAt: createdTime,
|
||||
@@ -69,6 +72,9 @@ func (s *SecureSuite) TestAuthenticate_Success() {
|
||||
ErrorReason: "",
|
||||
AuthData: &domain.AuthData{
|
||||
AppName: "test_application",
|
||||
SystemId: 1,
|
||||
DomainId: 3,
|
||||
ServiceId: 5,
|
||||
ApplicationId: 7,
|
||||
},
|
||||
}, result)
|
||||
@@ -108,6 +114,9 @@ func (s *SecureSuite) TestAuthenticate_NotExpired() {
|
||||
ErrorReason: "",
|
||||
AuthData: &domain.AuthData{
|
||||
AppName: "test_application",
|
||||
SystemId: 1,
|
||||
DomainId: 3,
|
||||
ServiceId: 5,
|
||||
ApplicationId: 7,
|
||||
},
|
||||
}, result)
|
||||
|
||||
@@ -87,6 +87,7 @@ func (m Manager) TokenRevokeTx(ctx context.Context, msgTx func(ctx context.Conte
|
||||
|
||||
type baselineTx struct {
|
||||
repository.Locker
|
||||
repository.Domain
|
||||
repository.AppGroup
|
||||
repository.Application
|
||||
repository.AccessList
|
||||
@@ -97,6 +98,7 @@ func (m Manager) BaselineTx(ctx context.Context, txTx func(ctx context.Context,
|
||||
return m.db.RunInTransaction(ctx, func(ctx context.Context, tx *db.Tx) error {
|
||||
return txTx(ctx, baselineTx{
|
||||
Locker: repository.NewLocker(tx),
|
||||
Domain: repository.NewDomain(tx),
|
||||
AppGroup: repository.NewAppGroup(tx),
|
||||
Application: repository.NewApplication(tx),
|
||||
AccessList: repository.NewAccessList(tx),
|
||||
|
||||
Reference in new issue
Block a user