Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48f0aaa40c | ||
|
|
09ec0b3f88 | ||
|
|
bef400d0d9 | ||
|
|
7108122102 | ||
|
|
8b8bc04fbf | ||
|
|
9de75322e5 | ||
|
|
51dfcdb9ba | ||
|
|
f062aada42 | ||
|
|
81c5af7538 | ||
|
|
c0b47ef9c6 | ||
|
|
bbec75c8a1 | ||
|
|
7ca053a733 | ||
|
|
24b80af7da | ||
|
|
42a2ceb9c9 | ||
|
|
231792aefa | ||
|
|
2ea518d902 | ||
|
|
13e8ff0ed8 | ||
|
|
66d8645f4a | ||
|
|
53cab90a5b | ||
|
|
dd41024768 | ||
|
|
fff9ddcbf8 | ||
|
|
f65dd9c2aa | ||
|
|
0d61264e73 | ||
|
|
cbc9d0643a | ||
|
|
e5d73d91de | ||
|
|
bb0d2b460a | ||
|
|
ab89a27053 | ||
|
|
132830bf6f | ||
|
|
c3e71c0c7e | ||
|
|
b0d60603bb | ||
|
|
894781c727 | ||
|
|
82a2d8d98f | ||
|
|
ab07db354b | ||
|
|
e1f081bf63 | ||
|
|
bcd4083dd9 | ||
|
|
74aba7fcfe | ||
|
|
29348a3c39 | ||
|
|
ea83597b19 | ||
|
|
4c88184112 | ||
|
|
8efe886a84 | ||
|
|
636a901c66 | ||
|
|
b139590408 | ||
|
|
ceeb2f03be | ||
|
|
1a90f50218 | ||
|
|
ce75f8933c | ||
|
|
f40b91a431 | ||
|
|
9c1fc87430 | ||
|
|
9b8432bb4c | ||
|
|
8deb2a2e38 | ||
|
|
2863f95a97 | ||
|
|
a7feb4e234 | ||
|
|
7b5ca9d12c | ||
|
|
9db858b0e2 | ||
|
|
b429c0b6fc | ||
|
|
82fd46b056 | ||
|
|
da4156afde | ||
|
|
ed5cb04ed3 | ||
|
|
e0fc90e4d4 | ||
|
|
97fcc21fc6 | ||
|
|
3d9c516cfb | ||
|
|
1ba15f4532 | ||
|
|
27d727823f | ||
|
|
6a120d6caa | ||
|
|
0e22b988b2 | ||
|
|
c0994fa5f1 | ||
|
|
1512fe33ce | ||
|
|
0934f8136f | ||
|
|
4b5412e21b | ||
|
|
bb36c55746 | ||
|
|
203c802071 | ||
|
|
cc94ca71a4 | ||
|
|
a7c58f86ec | ||
|
|
0f4c57cb67 | ||
|
|
bd7a06f8f0 | ||
|
|
8c4393b861 | ||
|
|
228b04e01d | ||
|
|
bbfb435c46 | ||
|
|
379102a1ac | ||
|
|
d9f8ae19f8 | ||
|
|
2d9efe3454 | ||
|
|
220706c876 | ||
|
|
c88a15c392 | ||
|
|
9f8efb6712 | ||
|
|
3bd6fe820d | ||
|
|
540e18743a | ||
|
|
8440633967 | ||
|
|
9f4a0b5fe1 | ||
|
|
ffab32fcff | ||
|
|
23013ef033 | ||
|
|
091f3ed06e | ||
|
|
c4a34c6cd2 | ||
|
|
e07527855f | ||
|
|
85012da9b0 | ||
|
|
f5139e46ed | ||
|
|
9f69df64e6 | ||
|
|
1c048520f8 | ||
|
|
e5bf25d2a4 | ||
|
|
1f633a417d | ||
|
|
d92df57ff7 | ||
|
|
b3905d7ceb | ||
|
|
15c18b1452 | ||
|
|
bf366f7824 | ||
|
|
293a9def27 | ||
|
|
c9334e651b | ||
|
|
05d645d5f4 | ||
|
|
5a811a9203 | ||
|
|
0aa1dc40fd | ||
|
|
9c13075f79 | ||
|
|
0aec014161 | ||
|
|
f215008349 | ||
|
|
8a0ebe803a | ||
|
|
c1da3c89ad | ||
|
|
9fb2e48c8c | ||
|
|
6b8f3c8b1d | ||
|
|
d5289efddc | ||
|
|
25b61e7d1d | ||
|
|
493f0f1190 | ||
|
|
9f76e76e55 | ||
|
|
ff84d68b72 | ||
|
|
0885d3e331 | ||
|
|
a6e50b6096 | ||
|
|
fa4221d4a4 | ||
|
|
555e253da1 | ||
|
|
3b56724d8e | ||
|
|
5af4c6a254 | ||
|
|
12a2a86ac4 | ||
|
|
f4a7463eec | ||
|
|
cfac1dd58e | ||
|
|
c420a98f70 |
No files matched your search
+64
-51
@@ -1,56 +1,69 @@
|
|||||||
run:
|
run:
|
||||||
allow-parallel-runners: true
|
timeout: 2m
|
||||||
issues:
|
|
||||||
exclude-rules:
|
|
||||||
- path: controller #достаточное кол-во контекса на уровне контроллеров
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
- path: transaction #транзакции прозрачны
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
linters:
|
linters:
|
||||||
enable-all: true
|
disable-all: true
|
||||||
disable:
|
enable:
|
||||||
- goimports #у нас собственные правила форматирования импортов
|
- asciicheck
|
||||||
- wsl #расставление пробелов очень индивидуально
|
- bodyclose
|
||||||
- exhaustivestruct #не имеет смысла
|
- deadcode
|
||||||
- varnamelen #очень индивидуально (db)
|
- dogsled
|
||||||
- exhaustruct #не имеет смысла
|
- errcheck
|
||||||
- golint #устарел
|
- funlen
|
||||||
- contextcheck #не имеет смысла
|
- goconst
|
||||||
- gci #у нас собственные правила форматирования импортов
|
- gocritic
|
||||||
- gofumpt #у нас собственные правила форматирования импортов
|
- gocyclo
|
||||||
- nolintlint #Goland все равно форматирует с отступом
|
- gofmt
|
||||||
- nlreturn #не всегда имеет смысл
|
- gomnd
|
||||||
- godot #не актуально для свагера
|
- goprintffuncname
|
||||||
- ifshort #приняли решение, что мы так не пишем if err := ...; err != nil {}
|
- gosimple
|
||||||
- godox #не позволяет оставлять todo
|
- govet
|
||||||
- maligned #аллокацией памяти для структур конфликтует с удобством их чтения
|
- nakedret
|
||||||
- nosnakecase #не позволяет заводить пакеты используя snake_case
|
- nestif
|
||||||
- depguard #не всегда имеет смысл
|
- nolintlint
|
||||||
- dupword #не имеет смысла
|
- prealloc
|
||||||
- tagalign #не всегда имеет смысл
|
- rowserrcheck
|
||||||
- musttag #у нас собственные правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внених для нас структур
|
- staticcheck
|
||||||
- perfsprint #мнимая производительность в угоду читаемости
|
- structcheck
|
||||||
- gomnd #устарел
|
- typecheck
|
||||||
|
- unconvert
|
||||||
|
- unparam
|
||||||
|
- unused
|
||||||
|
- varcheck
|
||||||
|
- gosec
|
||||||
|
- misspell
|
||||||
|
- whitespace
|
||||||
|
- exhaustive #смотрит на соответствие между элементами enum и swich кейсами
|
||||||
|
- exportloopref #for _,p := []int{1, 2, 3} { s.Bar(&p) /* If s stores the pointer, it will be bug.*/ }
|
||||||
|
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
|
||||||
linters-settings:
|
linters-settings:
|
||||||
funlen:
|
funlen:
|
||||||
lines: 80
|
lines: 80
|
||||||
lll:
|
statements: 40
|
||||||
line-length: 150
|
prealloc:
|
||||||
cyclop:
|
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
||||||
max-complexity: 15 #по умолчанию 10 мало
|
# True by default.
|
||||||
revive:
|
simple: true
|
||||||
rules:
|
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||||
- name: var-naming #отключаем Id -> ID
|
for-loops: true # Report preallocation suggestions on for loops, false by default
|
||||||
disabled: true
|
gocritic:
|
||||||
stylecheck:
|
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
|
||||||
checks: #отключаем Id -> ID
|
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
|
||||||
- "-ST1000"
|
enabled-tags:
|
||||||
- "-ST1016"
|
- diagnostic
|
||||||
- "-ST1020"
|
- performance
|
||||||
- "-ST1021"
|
disabled-checks:
|
||||||
- "-ST1022"
|
- hugeParam
|
||||||
testifylint:
|
- rangeValCopy
|
||||||
disable:
|
- ifElseChain
|
||||||
- compares
|
exhaustive:
|
||||||
|
default-signifies-exhaustive: true
|
||||||
|
|
||||||
|
issues:
|
||||||
|
exclude-rules:
|
||||||
|
- path: _test\.go # to exclude all test files for linter errcheck
|
||||||
|
linters:
|
||||||
|
- errcheck
|
||||||
|
- linters:
|
||||||
|
- gosec
|
||||||
|
text: "G101:"
|
||||||
@@ -1,13 +1,3 @@
|
|||||||
### v5.0.0
|
|
||||||
* изменен механизм инициализации токена панели администратора
|
|
||||||
* для механизма инициализации используется поле `baseline.initialAdminUiToken` в конфигурации
|
|
||||||
* если поле не заполнено, механизм не запускается
|
|
||||||
* иначе проверяется существование токена в базе, если токен уже создан, механизм не запускается
|
|
||||||
* иначе создаются все сущности и выпускается бессрочный токен, приложению выдается доступ к методу `admin/auth/login`
|
|
||||||
* механизм запускается при получении конфигурации
|
|
||||||
* при конкурентном запуске модуля, механизм запускается только на одном инстансе
|
|
||||||
* логи механизма маркируются полем "worker": "baseline"
|
|
||||||
* обновлена зависимости
|
|
||||||
### v4.0.0
|
### v4.0.0
|
||||||
* Удален `InstanceUuid`
|
* Удален `InstanceUuid`
|
||||||
* Удалена интеграция с Redis
|
* Удалена интеграция с Redis
|
||||||
|
|||||||
+13
-12
@@ -2,7 +2,6 @@ package assembly
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/txix-open/isp-kit/rc"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/app"
|
"github.com/txix-open/isp-kit/app"
|
||||||
@@ -13,6 +12,7 @@ import (
|
|||||||
"github.com/txix-open/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-system-service/conf"
|
"isp-system-service/conf"
|
||||||
|
"isp-system-service/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Assembly struct {
|
type Assembly struct {
|
||||||
@@ -25,6 +25,7 @@ type Assembly struct {
|
|||||||
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
||||||
dbCli := dbrx.New(dbx.WithMigrationRunner(boot.MigrationsDir, boot.App.Logger()))
|
dbCli := dbrx.New(dbx.WithMigrationRunner(boot.MigrationsDir, boot.App.Logger()))
|
||||||
server := grpc.NewServer()
|
server := grpc.NewServer()
|
||||||
|
|
||||||
return &Assembly{
|
return &Assembly{
|
||||||
boot: boot,
|
boot: boot,
|
||||||
db: dbCli,
|
db: dbCli,
|
||||||
@@ -34,27 +35,27 @@ func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error {
|
func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error {
|
||||||
newCfg, _, err := rc.Upgrade[conf.Remote](a.boot.RemoteConfig, remoteConfig)
|
var (
|
||||||
|
newCfg conf.Remote
|
||||||
|
prevCfg conf.Remote
|
||||||
|
)
|
||||||
|
err := a.boot.RemoteConfig.Upgrade(remoteConfig, &newCfg, &prevCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.boot.Fatal(errors.WithMessage(err, "upgrade remote config"))
|
a.logger.Fatal(ctx, errors.WithMessage(err, "upgrade remote config"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
migrations.Initialize.SetParams(a.boot.MigrationsDir, newCfg.Database.Schema)
|
||||||
|
|
||||||
a.logger.SetLevel(newCfg.LogLevel)
|
a.logger.SetLevel(newCfg.LogLevel)
|
||||||
|
|
||||||
err = a.db.Upgrade(ctx, newCfg.Database)
|
err = a.db.Upgrade(ctx, newCfg.Database)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.boot.Fatal(errors.WithMessage(err, "upgrade db client"))
|
a.logger.Fatal(ctx, errors.WithMessage(err, "upgrade db client"), log.Any("config", newCfg.Database))
|
||||||
}
|
}
|
||||||
|
|
||||||
locator := NewLocator(a.db, a.logger)
|
locator := NewLocator(a.db, a.logger)
|
||||||
config := locator.Config(newCfg)
|
handler := locator.Handler(newCfg)
|
||||||
|
a.server.Upgrade(handler)
|
||||||
err = config.Baseline.Do(a.boot.App.Context())
|
|
||||||
if err != nil {
|
|
||||||
a.boot.Fatal(errors.WithMessage(err, "run baseline"))
|
|
||||||
}
|
|
||||||
|
|
||||||
a.server.Upgrade(config.Handler)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-27
@@ -2,15 +2,14 @@ package assembly
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/txix-open/isp-kit/db"
|
"github.com/txix-open/isp-kit/db"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/endpoint"
|
"github.com/txix-open/isp-kit/grpc/endpoint"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/isp"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-system-service/conf"
|
"isp-system-service/conf"
|
||||||
"isp-system-service/controller"
|
"isp-system-service/controller"
|
||||||
"isp-system-service/repository"
|
"isp-system-service/repository"
|
||||||
"isp-system-service/routes"
|
"isp-system-service/routes"
|
||||||
"isp-system-service/service"
|
"isp-system-service/service"
|
||||||
"isp-system-service/service/baseline"
|
|
||||||
"isp-system-service/service/secure"
|
"isp-system-service/service/secure"
|
||||||
"isp-system-service/transaction"
|
"isp-system-service/transaction"
|
||||||
)
|
)
|
||||||
@@ -32,51 +31,43 @@ func NewLocator(db DB, logger log.Logger) Locator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
func (l Locator) Handler(cfg conf.Remote) isp.BackendServiceServer {
|
||||||
Handler *grpc.Mux
|
|
||||||
Baseline baseline.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l Locator) Config(cfg conf.Remote) Config {
|
|
||||||
txManager := transaction.NewManager(l.db)
|
txManager := transaction.NewManager(l.db)
|
||||||
accessListRep := repository.NewAccessList(l.db)
|
accessListRep := repository.NewAccessList(l.db)
|
||||||
applicationRep := repository.NewApplication(l.db)
|
applicationRep := repository.NewApplication(l.db)
|
||||||
domainRep := repository.NewDomain(l.db)
|
domainRep := repository.NewDomain(l.db)
|
||||||
serviceRep := repository.NewService(l.db)
|
groupRep := repository.NewApplicationGroup(l.db)
|
||||||
tokenRep := repository.NewToken(l.db)
|
tokenRep := repository.NewToken(l.db)
|
||||||
|
|
||||||
secureService := secure.NewService(tokenRep, accessListRep)
|
secureApplicationGroup := secure.NewApplicationGroup(tokenRep, accessListRep)
|
||||||
accessListService := service.NewAccessList(txManager, accessListRep, applicationRep)
|
accessListService := service.NewAccessList(txManager, accessListRep, applicationRep)
|
||||||
applicationService := service.NewApplication(txManager, applicationRep, domainRep, serviceRep, tokenRep)
|
applicationService := service.NewApplication(txManager, applicationRep, domainRep, groupRep, tokenRep)
|
||||||
domainService := service.NewDomain(domainRep)
|
domainService := service.NewDomain(domainRep)
|
||||||
serviceService := service.NewService(domainRep, serviceRep)
|
applicationGroupService := service.NewApplicationGroup(domainRep, groupRep)
|
||||||
|
|
||||||
jwtService := service.NewTokenSource()
|
jwtService := service.NewTokenSource()
|
||||||
tokenService := service.NewToken(jwtService, applicationService, txManager,
|
tokenService := service.NewToken(jwtService, applicationService, txManager,
|
||||||
applicationRep, domainRep, serviceRep, tokenRep,
|
applicationRep, domainRep, groupRep, tokenRep,
|
||||||
)
|
)
|
||||||
|
|
||||||
secureController := controller.NewSecure(secureService)
|
secureController := controller.NewSecure(secureApplicationGroup)
|
||||||
accessListController := controller.NewAccessList(accessListService)
|
accessListController := controller.NewAccessList(accessListService)
|
||||||
applicationController := controller.NewApplication(applicationService)
|
applicationController := controller.NewApplication(applicationService)
|
||||||
domainController := controller.NewDomain(domainService)
|
domainController := controller.NewDomain(domainService)
|
||||||
serviceController := controller.NewService(serviceService)
|
serviceController := controller.NewService(applicationGroupService)
|
||||||
|
groupController := controller.NewApplicationGroup(applicationGroupService)
|
||||||
tokenController := controller.NewToken(tokenService)
|
tokenController := controller.NewToken(tokenService)
|
||||||
|
|
||||||
c := routes.Controllers{
|
c := routes.Controllers{
|
||||||
Secure: secureController,
|
Secure: secureController,
|
||||||
AccessList: accessListController,
|
AccessList: accessListController,
|
||||||
Domain: domainController,
|
Domain: domainController,
|
||||||
Service: serviceController,
|
Service: serviceController,
|
||||||
Application: applicationController,
|
ApplicationGroup: groupController,
|
||||||
Token: tokenController,
|
Application: applicationController,
|
||||||
|
Token: tokenController,
|
||||||
}
|
}
|
||||||
mapper := endpoint.DefaultWrapper(l.logger, endpoint.BodyLogger(l.logger))
|
mapper := endpoint.DefaultWrapper(l.logger, endpoint.BodyLogger(l.logger))
|
||||||
server := routes.Handler(mapper, c)
|
server := routes.Handler(mapper, c)
|
||||||
|
return server
|
||||||
baselineService := baseline.NewService(cfg.Baseline, txManager, l.logger)
|
|
||||||
return Config{
|
|
||||||
Handler: server,
|
|
||||||
Baseline: baselineService,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,5 @@
|
|||||||
"username": "{{ msp_pgsql_user }}",
|
"username": "{{ msp_pgsql_user }}",
|
||||||
"host": "{{ msp_pgsql_address }}",
|
"host": "{{ msp_pgsql_address }}",
|
||||||
"port": 5432
|
"port": 5432
|
||||||
},
|
|
||||||
"baseline": {
|
|
||||||
"initialAdminUiToken": "{{ isp_service_admin_token }}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-7
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/txix-open/jsonschema"
|
"github.com/txix-open/jsonschema"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:gochecknoinits
|
|
||||||
func init() {
|
func init() {
|
||||||
schema.CustomGenerators.Register("logLevel", func(field reflect.StructField, t *jsonschema.Schema) {
|
schema.CustomGenerators.Register("logLevel", func(field reflect.StructField, t *jsonschema.Schema) {
|
||||||
t.Type = "string"
|
t.Type = "string"
|
||||||
@@ -19,10 +18,5 @@ func init() {
|
|||||||
|
|
||||||
type Remote struct {
|
type Remote struct {
|
||||||
Database dbx.Config `schema:"Настройка базы данных"`
|
Database dbx.Config `schema:"Настройка базы данных"`
|
||||||
Baseline Baseline
|
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования"`
|
||||||
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Baseline struct {
|
|
||||||
InitialAdminUiToken string
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package conf_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"isp-system-service/conf"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/test/rct"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDefaultRemoteConfig(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
rct.Test(t, "default_remote_config.json", conf.Remote{})
|
|
||||||
}
|
|
||||||
+14
-14
@@ -12,8 +12,8 @@ import (
|
|||||||
type ApplicationService interface {
|
type ApplicationService interface {
|
||||||
GetById(ctx context.Context, appId int) (*domain.ApplicationWithTokens, error)
|
GetById(ctx context.Context, appId int) (*domain.ApplicationWithTokens, error)
|
||||||
GetByIdList(ctx context.Context, idList []int) ([]*domain.ApplicationWithTokens, error)
|
GetByIdList(ctx context.Context, idList []int) ([]*domain.ApplicationWithTokens, error)
|
||||||
GetByServiceId(ctx context.Context, id int) ([]*domain.ApplicationWithTokens, error)
|
GetByApplicationGroupId(ctx context.Context, id int) ([]*domain.ApplicationWithTokens, error)
|
||||||
SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithService, error)
|
SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithApplicationGroup, error)
|
||||||
CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error)
|
CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error)
|
||||||
Delete(ctx context.Context, idList []int) (int, error)
|
Delete(ctx context.Context, idList []int) (int, error)
|
||||||
}
|
}
|
||||||
@@ -66,30 +66,30 @@ func (c Application) GetByIdList(ctx context.Context, req []int) ([]*domain.Appl
|
|||||||
return c.service.GetByIdList(ctx, req)
|
return c.service.GetByIdList(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetByServiceId godoc
|
// GetByApplicationGroupId godoc
|
||||||
// @Tags application
|
// @Tags application
|
||||||
// @Summary Получить список приложений по идентификатору сервиса
|
// @Summary Получить список приложений по идентификатору группы приложений
|
||||||
// @Description Возвращает список приложений по запрошенному идентификатору сервиса
|
// @Description Возвращает список приложений по запрошенному идентификатору группы приложений
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body domain.Identity true "Идентификатор сервиса"
|
// @Param body body domain.Identity true "Идентификатор группы приложений"
|
||||||
// @Success 200 {array} domain.ApplicationWithTokens
|
// @Success 200 {array} domain.ApplicationWithTokens
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /application/get_applications_by_service_id [POST]
|
// @Router /application/get_applications_by_service_id [POST]
|
||||||
func (c Application) GetByServiceId(ctx context.Context, req domain.Identity) ([]*domain.ApplicationWithTokens, error) {
|
func (c Application) GetByApplicationGroupId(ctx context.Context, req domain.Identity) ([]*domain.ApplicationWithTokens, error) {
|
||||||
return c.service.GetByServiceId(ctx, req.Id)
|
return c.service.GetByApplicationGroupId(ctx, req.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSystemTree godoc
|
// GetSystemTree godoc
|
||||||
// @Tags application
|
// @Tags application
|
||||||
// @Summary Метод получения системного дерева
|
// @Summary Метод получения системного дерева
|
||||||
// @Description Возвращает описание взаимосвязей сервисов и приложений
|
// @Description Возвращает описание взаимосвязей группы приложений и приложений
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {array} domain.DomainWithService
|
// @Success 200 {array} domain.DomainWithApplicationGroup
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /application/get_system_tree [POST]
|
// @Router /application/get_system_tree [POST]
|
||||||
func (c Application) GetSystemTree(ctx context.Context) ([]*domain.DomainWithService, error) {
|
func (c Application) GetSystemTree(ctx context.Context) ([]*domain.DomainWithApplicationGroup, error) {
|
||||||
return c.service.SystemTree(ctx, domain.DefaultSystemId)
|
return c.service.SystemTree(ctx, domain.DefaultSystemId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,12 +109,12 @@ func (c Application) GetSystemTree(ctx context.Context) ([]*domain.DomainWithSer
|
|||||||
func (c Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error) {
|
func (c Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error) {
|
||||||
result, err := c.service.CreateUpdate(ctx, req)
|
result, err := c.service.CreateUpdate(ctx, req)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, domain.ErrServiceNotFound):
|
case errors.Is(err, domain.ErrApplicationGroupNotFound):
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "service with id %d not found", req.ServiceId)
|
return nil, status.Errorf(codes.InvalidArgument, "application group with id %d not found", req.ApplicationGroupId)
|
||||||
case errors.Is(err, domain.ErrApplicationDuplicateName):
|
case errors.Is(err, domain.ErrApplicationDuplicateName):
|
||||||
return nil, status.Errorf(codes.AlreadyExists, "application with name %s already exists", req.Name)
|
return nil, status.Errorf(codes.AlreadyExists, "application with name %s already exists", req.Name)
|
||||||
case errors.Is(err, domain.ErrApplicationNotFound):
|
case errors.Is(err, domain.ErrApplicationNotFound):
|
||||||
return nil, status.Errorf(codes.NotFound, "Application with id %d not found", req.Id)
|
return nil, status.Errorf(codes.NotFound, "application with id %d not found", req.Id)
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return nil, err
|
return nil, err
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
"isp-system-service/domain"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ApplicationGroupService interface {
|
||||||
|
GetById(ctx context.Context, id int) (*domain.ApplicationGroup, error)
|
||||||
|
GetByIdList(ctx context.Context, idList []int) ([]domain.ApplicationGroup, error)
|
||||||
|
CreateUpdate(ctx context.Context, req domain.ApplicationGroupCreateUpdateRequest) (*domain.ApplicationGroup, error)
|
||||||
|
Delete(ctx context.Context, idList []int) (int, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ApplicationGroup struct {
|
||||||
|
service ApplicationGroupService
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewApplicationGroup(service ApplicationGroupService) ApplicationGroup {
|
||||||
|
return ApplicationGroup{
|
||||||
|
service: service,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetById godoc
|
||||||
|
// @Tags application_group
|
||||||
|
// @Summary Получить группу приложений по идентификатору
|
||||||
|
// @Description Возвращает описание группы приложений по ее идентификатору
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body domain.Identity true "Идентификатор группы приложений"
|
||||||
|
// @Success 200 {object} domain.ApplicationGroup
|
||||||
|
// @Failure 404 {object} domain.GrpcError
|
||||||
|
// @Failure 500 {object} domain.GrpcError
|
||||||
|
// @Router /application_group/get_group_by_id [POST]
|
||||||
|
func (c ApplicationGroup) GetById(ctx context.Context, req domain.Identity) (*domain.ApplicationGroup, error) {
|
||||||
|
result, err := c.service.GetById(ctx, req.Id)
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, domain.ErrApplicationGroupNotFound):
|
||||||
|
return nil, status.Errorf(codes.NotFound, "application group with id %d not found", req.Id)
|
||||||
|
case err != nil:
|
||||||
|
return nil, err
|
||||||
|
default:
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get godoc
|
||||||
|
// @Tags application_group
|
||||||
|
// @Summary Получить список группы приложений
|
||||||
|
// @Description Возвращает список групп приложений по их идентификаторам
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body []integer false "Массив идентификаторов групп приложений"
|
||||||
|
// @Success 200 {array} domain.ApplicationGroup
|
||||||
|
// @Failure 500 {object} domain.GrpcError
|
||||||
|
// @Router /application_group/get_group [POST]
|
||||||
|
func (c ApplicationGroup) Get(ctx context.Context, req []int) ([]domain.ApplicationGroup, error) {
|
||||||
|
return c.service.GetByIdList(ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateUpdate godoc
|
||||||
|
// @Tags application_group
|
||||||
|
// @Summary Создать/обновить группу приложений
|
||||||
|
// @Description Если группы приложений с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body domain.ApplicationGroupCreateUpdateRequest true "Объект группы приложений"
|
||||||
|
// @Success 200 {object} domain.ApplicationGroup
|
||||||
|
// @Failure 400 {object} domain.GrpcError
|
||||||
|
// @Failure 404 {object} domain.GrpcError
|
||||||
|
// @Failure 409 {object} domain.GrpcError
|
||||||
|
// @Failure 500 {object} domain.GrpcError
|
||||||
|
// @Router /application_group/create_update_group [POST]
|
||||||
|
func (c ApplicationGroup) CreateUpdate(ctx context.Context, req domain.ApplicationGroupCreateUpdateRequest) (*domain.ApplicationGroup, error) {
|
||||||
|
req.DomainId = 1 // Хардкодом проставляем domainId = 1
|
||||||
|
|
||||||
|
result, err := c.service.CreateUpdate(ctx, req)
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, domain.ErrDomainNotFound):
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "domain with id %d not found", req.DomainId)
|
||||||
|
case errors.Is(err, domain.ErrApplicationGroupNotFound):
|
||||||
|
return nil, status.Errorf(codes.NotFound, "application group with id %d not found", req.Id)
|
||||||
|
case errors.Is(err, domain.ErrApplicationGroupDuplicateName):
|
||||||
|
return nil, status.Errorf(codes.AlreadyExists, "application group with name %s already exists", req.Name)
|
||||||
|
case err != nil:
|
||||||
|
return nil, err
|
||||||
|
default:
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete godoc
|
||||||
|
// @Tags application_group
|
||||||
|
// @Summary Удалить группы приложений
|
||||||
|
// @Description Удаляет группы приложений по списку их идентификаторов, возвращает количество удаленных групп
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body []integer true "Массив идентификаторов групп приложений"
|
||||||
|
// @Success 200 {object} domain.DeleteResponse
|
||||||
|
// @Failure 400 {object} domain.GrpcError
|
||||||
|
// @Failure 500 {object} domain.GrpcError
|
||||||
|
// @Router /application_group/delete_group [POST]
|
||||||
|
func (c ApplicationGroup) Delete(ctx context.Context, req []int) (*domain.DeleteResponse, error) {
|
||||||
|
if len(req) == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "at least one id are required")
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := c.service.Delete(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &domain.DeleteResponse{
|
||||||
|
Deleted: result,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
+11
-11
@@ -10,10 +10,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ServiceService interface {
|
type ServiceService interface {
|
||||||
GetById(ctx context.Context, id int) (*domain.Service, error)
|
GetById(ctx context.Context, id int) (*domain.ApplicationGroup, error)
|
||||||
GetByIdList(ctx context.Context, idList []int) ([]domain.Service, error)
|
GetByIdList(ctx context.Context, idList []int) ([]domain.ApplicationGroup, error)
|
||||||
GetByDomainId(ctx context.Context, domainId int) ([]domain.Service, error)
|
GetByDomainId(ctx context.Context, domainId int) ([]domain.ApplicationGroup, error)
|
||||||
CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdateRequest) (*domain.Service, error)
|
CreateUpdate(ctx context.Context, req domain.ApplicationGroupCreateUpdateRequest) (*domain.ApplicationGroup, error)
|
||||||
Delete(ctx context.Context, idList []int) (int, error)
|
Delete(ctx context.Context, idList []int) (int, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,10 +38,10 @@ func NewService(service ServiceService) Service {
|
|||||||
// @Failure 404 {object} domain.GrpcError
|
// @Failure 404 {object} domain.GrpcError
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /service/get_service_by_id [POST]
|
// @Router /service/get_service_by_id [POST]
|
||||||
func (c Service) GetById(ctx context.Context, req domain.Identity) (*domain.Service, error) {
|
func (c Service) GetById(ctx context.Context, req domain.Identity) (*domain.ApplicationGroup, error) {
|
||||||
result, err := c.service.GetById(ctx, req.Id)
|
result, err := c.service.GetById(ctx, req.Id)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, domain.ErrServiceNotFound):
|
case errors.Is(err, domain.ErrApplicationGroupNotFound):
|
||||||
return nil, status.Errorf(codes.NotFound, "service with id %d not found", req.Id)
|
return nil, status.Errorf(codes.NotFound, "service with id %d not found", req.Id)
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -60,7 +60,7 @@ func (c Service) GetById(ctx context.Context, req domain.Identity) (*domain.Serv
|
|||||||
// @Success 200 {array} domain.Service
|
// @Success 200 {array} domain.Service
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /service/get_service [POST]
|
// @Router /service/get_service [POST]
|
||||||
func (c Service) Get(ctx context.Context, req []int) ([]domain.Service, error) {
|
func (c Service) Get(ctx context.Context, req []int) ([]domain.ApplicationGroup, error) {
|
||||||
return c.service.GetByIdList(ctx, req)
|
return c.service.GetByIdList(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ func (c Service) Get(ctx context.Context, req []int) ([]domain.Service, error) {
|
|||||||
// @Success 200 {array} domain.Service
|
// @Success 200 {array} domain.Service
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /service/get_services_by_domain_id [POST]
|
// @Router /service/get_services_by_domain_id [POST]
|
||||||
func (c Service) GetByDomainId(ctx context.Context, req domain.Identity) ([]domain.Service, error) {
|
func (c Service) GetByDomainId(ctx context.Context, req domain.Identity) ([]domain.ApplicationGroup, error) {
|
||||||
return c.service.GetByDomainId(ctx, req.Id)
|
return c.service.GetByDomainId(ctx, req.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,14 +91,14 @@ func (c Service) GetByDomainId(ctx context.Context, req domain.Identity) ([]doma
|
|||||||
// @Failure 409 {object} domain.GrpcError
|
// @Failure 409 {object} domain.GrpcError
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /service/create_update_service [POST]
|
// @Router /service/create_update_service [POST]
|
||||||
func (c Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdateRequest) (*domain.Service, error) {
|
func (c Service) CreateUpdate(ctx context.Context, req domain.ApplicationGroupCreateUpdateRequest) (*domain.ApplicationGroup, error) {
|
||||||
result, err := c.service.CreateUpdate(ctx, req)
|
result, err := c.service.CreateUpdate(ctx, req)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, domain.ErrDomainNotFound):
|
case errors.Is(err, domain.ErrDomainNotFound):
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "domain with id %d not found", req.DomainId)
|
return nil, status.Errorf(codes.InvalidArgument, "domain with id %d not found", req.DomainId)
|
||||||
case errors.Is(err, domain.ErrServiceNotFound):
|
case errors.Is(err, domain.ErrApplicationGroupNotFound):
|
||||||
return nil, status.Errorf(codes.NotFound, "service with id %d not found", req.Id)
|
return nil, status.Errorf(codes.NotFound, "service with id %d not found", req.Id)
|
||||||
case errors.Is(err, domain.ErrServiceDuplicateName):
|
case errors.Is(err, domain.ErrApplicationGroupDuplicateName):
|
||||||
return nil, status.Errorf(codes.AlreadyExists, "service with name %s already exists", req.Name)
|
return nil, status.Errorf(codes.AlreadyExists, "service with name %s already exists", req.Name)
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
+2
-2
@@ -55,8 +55,8 @@ func (c Token) Create(ctx context.Context, req domain.TokenCreateRequest) (*doma
|
|||||||
switch {
|
switch {
|
||||||
case errors.Is(err, domain.ErrApplicationNotFound):
|
case errors.Is(err, domain.ErrApplicationNotFound):
|
||||||
return nil, status.Errorf(codes.NotFound, "application with id %d not found", req.AppId)
|
return nil, status.Errorf(codes.NotFound, "application with id %d not found", req.AppId)
|
||||||
case errors.Is(err, domain.ErrServiceNotFound):
|
case errors.Is(err, domain.ErrApplicationGroupNotFound):
|
||||||
return nil, status.Errorf(codes.NotFound, "service for app_id id %d not found", req.AppId)
|
return nil, status.Errorf(codes.NotFound, "application group for app_id id %d not found", req.AppId)
|
||||||
case errors.Is(err, domain.ErrDomainNotFound):
|
case errors.Is(err, domain.ErrDomainNotFound):
|
||||||
return nil, status.Errorf(codes.NotFound, "domain for app_id %d not found", req.AppId)
|
return nil, status.Errorf(codes.NotFound, "domain for app_id %d not found", req.AppId)
|
||||||
case err != nil:
|
case err != nil:
|
||||||
|
|||||||
+2
-2
@@ -180,7 +180,8 @@ definitions:
|
|||||||
domain.GrpcError:
|
domain.GrpcError:
|
||||||
properties:
|
properties:
|
||||||
details:
|
details:
|
||||||
items: {}
|
items:
|
||||||
|
type: object
|
||||||
type: array
|
type: array
|
||||||
errorCode:
|
errorCode:
|
||||||
type: string
|
type: string
|
||||||
@@ -262,7 +263,6 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
required:
|
required:
|
||||||
- appId
|
- appId
|
||||||
- expireTimeMs
|
|
||||||
type: object
|
type: object
|
||||||
domain.TokenRevokeRequest:
|
domain.TokenRevokeRequest:
|
||||||
properties:
|
properties:
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
type AccessListSetOneRequest struct {
|
type AccessListSetOneRequest struct {
|
||||||
AppId int `validate:"required"`
|
AppId int `valid:"required~Required"`
|
||||||
Method string `validate:"required"`
|
Method string `valid:"required~Required"`
|
||||||
Value bool
|
Value bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ type AccessListSetOneResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AccessListSetListRequest struct {
|
type AccessListSetListRequest struct {
|
||||||
AppId int `validate:"required"`
|
AppId int `valid:"required~Required"`
|
||||||
RemoveOld bool
|
RemoveOld bool
|
||||||
Methods []MethodInfo
|
Methods []MethodInfo
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -5,21 +5,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Application struct {
|
type Application struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
ServiceId int
|
ApplicationGroupId int
|
||||||
Type string
|
Type string
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApplicationCreateUpdateRequest struct {
|
type ApplicationCreateUpdateRequest struct {
|
||||||
Id int
|
Id int
|
||||||
Name string `validate:"required"`
|
Name string `valid:"required~Required"`
|
||||||
Description string
|
Description string
|
||||||
ServiceId int `validate:"required"`
|
ApplicationGroupId int `valid:"required~Required"`
|
||||||
Type string `validate:"required,oneof=SYSTEM MOBILE"`
|
Type string `valid:"required~Required,in(SYSTEM|MOBILE)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApplicationWithTokens struct {
|
type ApplicationWithTokens struct {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type ApplicationGroup struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
@@ -13,14 +13,14 @@ type Service struct {
|
|||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServiceCreateUpdateRequest struct {
|
type ApplicationGroupCreateUpdateRequest struct {
|
||||||
Id int
|
Id int
|
||||||
Name string `validate:"required"`
|
Name string `valid:"required~Required"`
|
||||||
Description string
|
Description string
|
||||||
DomainId int `validate:"required"`
|
DomainId int `valid:"required~Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServiceWithApps struct {
|
type ApplicationGroupWithApps struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
+1
-1
@@ -2,7 +2,7 @@ package domain
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
Identity struct {
|
Identity struct {
|
||||||
Id int `validate:"required"`
|
Id int `valid:"required~Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteResponse struct {
|
DeleteResponse struct {
|
||||||
|
|||||||
+6
-6
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
type DomainCreateUpdateRequest struct {
|
type DomainCreateUpdateRequest struct {
|
||||||
Id int
|
Id int
|
||||||
Name string `validate:"required"`
|
Name string `valid:"required~Required"`
|
||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,9 +19,9 @@ type Domain struct {
|
|||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type DomainWithService struct {
|
type DomainWithApplicationGroup struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
Services []*ServiceWithApps
|
ApplicationGroup []*ApplicationGroupWithApps
|
||||||
}
|
}
|
||||||
+2
-2
@@ -8,8 +8,8 @@ var (
|
|||||||
ErrDomainNotFound = errors.New("domain not found")
|
ErrDomainNotFound = errors.New("domain not found")
|
||||||
ErrDomainDuplicateName = errors.New("domain name already exist")
|
ErrDomainDuplicateName = errors.New("domain name already exist")
|
||||||
|
|
||||||
ErrServiceNotFound = errors.New("service not found")
|
ErrApplicationGroupNotFound = errors.New("application group not found")
|
||||||
ErrServiceDuplicateName = errors.New("service name already exist")
|
ErrApplicationGroupDuplicateName = errors.New("application group name already exist")
|
||||||
|
|
||||||
ErrSystemNotFound = errors.New("system not found")
|
ErrSystemNotFound = errors.New("system not found")
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -1,7 +1,7 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
type AuthenticateRequest struct {
|
type AuthenticateRequest struct {
|
||||||
Token string `validate:"required"`
|
Token string `valid:"required~Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthenticateResponse struct {
|
type AuthenticateResponse struct {
|
||||||
@@ -11,15 +11,15 @@ type AuthenticateResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AuthData struct {
|
type AuthData struct {
|
||||||
SystemId int
|
SystemId int
|
||||||
DomainId int
|
DomainId int
|
||||||
ServiceId int
|
ApplicationGroupId int
|
||||||
ApplicationId int
|
ApplicationId int
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthorizeRequest struct {
|
type AuthorizeRequest struct {
|
||||||
ApplicationId int `validate:"required"`
|
ApplicationId int `valid:"required~Required"`
|
||||||
Endpoint string `validate:"required"`
|
Endpoint string `valid:"required~Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthorizeResponse struct {
|
type AuthorizeResponse struct {
|
||||||
|
|||||||
+3
-3
@@ -12,11 +12,11 @@ type Token struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TokenRevokeRequest struct {
|
type TokenRevokeRequest struct {
|
||||||
AppId int `validate:"required"`
|
AppId int `valid:"required~Required"`
|
||||||
Tokens []string
|
Tokens []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type TokenCreateRequest struct {
|
type TokenCreateRequest struct {
|
||||||
AppId int `validate:"required"`
|
AppId int `valid:"required~Required"`
|
||||||
ExpireTimeMs int `validate:"required"`
|
ExpireTimeMs int `valid:"required~Required"`
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Application struct {
|
type Application struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Description *string
|
Description *string
|
||||||
ServiceId int
|
ApplicationGroupId int
|
||||||
Type string
|
Type string
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type ApplicationGroup struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Description *string
|
Description *string
|
||||||
+6
-6
@@ -12,10 +12,10 @@ type Token struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AuthData struct {
|
type AuthData struct {
|
||||||
SystemId int
|
SystemId int
|
||||||
DomainId int
|
DomainId int
|
||||||
ServiceId int
|
ApplicationGroupIdId int
|
||||||
AppId int
|
AppId int
|
||||||
ExpireTime int
|
ExpireTime int
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,11 @@ go 1.22
|
|||||||
require (
|
require (
|
||||||
github.com/Masterminds/squirrel v1.5.4
|
github.com/Masterminds/squirrel v1.5.4
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
|
github.com/pressly/goose v2.7.0+incompatible
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
github.com/txix-open/isp-kit v1.38.1
|
github.com/txix-open/isp-kit v1.31.4
|
||||||
github.com/txix-open/jsonschema v1.2.0
|
github.com/txix-open/jsonschema v1.2.0
|
||||||
google.golang.org/grpc v1.66.0
|
google.golang.org/grpc v1.64.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -17,21 +18,18 @@ require (
|
|||||||
github.com/buger/jsonparser v1.1.1 // indirect
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/coder/websocket v1.8.12 // indirect
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||||
github.com/getsentry/sentry-go v0.28.1 // indirect
|
github.com/getsentry/sentry-go v0.27.0 // indirect
|
||||||
github.com/go-faker/faker/v4 v4.4.2 // indirect
|
github.com/go-logr/logr v1.4.1 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 // indirect
|
|
||||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
|
||||||
github.com/jackc/pgx/v5 v5.6.0 // indirect
|
github.com/jackc/pgx/v5 v5.5.5 // indirect
|
||||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||||
github.com/jmoiron/sqlx v1.4.0 // indirect
|
github.com/jmoiron/sqlx v1.4.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
@@ -43,38 +41,35 @@ require (
|
|||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
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.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/pressly/goose/v3 v3.21.1 // indirect
|
github.com/pressly/goose/v3 v3.20.0 // indirect
|
||||||
github.com/prometheus/client_golang v1.19.1 // indirect
|
github.com/prometheus/client_golang v1.19.0 // indirect
|
||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
github.com/prometheus/common v0.55.0 // indirect
|
github.com/prometheus/common v0.53.0 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/procfs v0.14.0 // indirect
|
||||||
github.com/sethvargo/go-retry v0.3.0 // indirect
|
github.com/sethvargo/go-retry v0.2.4 // indirect
|
||||||
github.com/txix-open/bellows v1.2.0 // indirect
|
github.com/txix-open/bellows v1.2.0 // indirect
|
||||||
github.com/txix-open/etp/v3 v3.2.0 // indirect
|
github.com/txix-open/etp/v3 v3.0.0 // indirect
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 // indirect
|
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 // indirect
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
go.opentelemetry.io/otel v1.26.0 // indirect
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 // indirect
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0 // indirect
|
||||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
go.opentelemetry.io/otel/metric v1.26.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
|
go.opentelemetry.io/otel/sdk v1.26.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect
|
go.opentelemetry.io/otel/trace v1.26.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.28.0 // indirect
|
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
|
|
||||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.27.0 // indirect
|
go.uber.org/zap v1.27.0 // indirect
|
||||||
golang.org/x/crypto v0.26.0 // indirect
|
golang.org/x/crypto v0.22.0 // indirect
|
||||||
golang.org/x/net v0.28.0 // indirect
|
golang.org/x/net v0.24.0 // indirect
|
||||||
golang.org/x/sync v0.8.0 // indirect
|
golang.org/x/sync v0.7.0 // indirect
|
||||||
golang.org/x/sys v0.24.0 // indirect
|
golang.org/x/sys v0.19.0 // indirect
|
||||||
golang.org/x/text v0.17.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
|
||||||
google.golang.org/protobuf v1.34.2 // indirect
|
google.golang.org/protobuf v1.33.0 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
nhooyr.io/websocket v1.8.11 // indirect
|
||||||
)
|
)
|
||||||
@@ -14,24 +14,20 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
|
|||||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
|
|
||||||
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/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 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
|
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
|
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||||
github.com/getsentry/sentry-go v0.28.1 h1:zzaSm/vHmGllRM6Tpx1492r0YDzauArdBfkJRtY6P5k=
|
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
|
||||||
github.com/getsentry/sentry-go v0.28.1/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg=
|
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
|
||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
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-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||||
github.com/go-faker/faker/v4 v4.4.2 h1:96WeU9QKEqRUVYdjHquY2/5bAqmVM0IfGKHV5mbfqmQ=
|
|
||||||
github.com/go-faker/faker/v4 v4.4.2/go.mod h1:4K3v4AbKXYNHMQNaREMc9/kRB9j5JJzpFo6KHRvrcIw=
|
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
|
||||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
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-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
@@ -47,18 +43,18 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
|
|||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||||
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
||||||
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
|
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
|
||||||
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
|
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
|
||||||
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
||||||
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
||||||
@@ -93,8 +89,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
|||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
|
||||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
||||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
||||||
@@ -103,24 +97,26 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pressly/goose/v3 v3.21.1 h1:5SSAKKWej8LVVzNLuT6KIvP1eFDuPvxa+B6H0w78buQ=
|
github.com/pressly/goose v2.7.0+incompatible h1:PWejVEv07LCerQEzMMeAtjuyCKbyprZ/LBa6K5P0OCQ=
|
||||||
github.com/pressly/goose/v3 v3.21.1/go.mod h1:sqthmzV8PitchEkjecFJII//l43dLOCzfWh8pHEe+vE=
|
github.com/pressly/goose v2.7.0+incompatible/go.mod h1:m+QHWCqxR3k8D9l7qfzuC/djtlfzxr34mozWDYEu1z8=
|
||||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
github.com/pressly/goose/v3 v3.20.0 h1:uPJdOxF/Ipj7ABVNOAMJXSxwFXZGwMGHNqjC8e61VA0=
|
||||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
github.com/pressly/goose/v3 v3.20.0/go.mod h1:BRfF2GcG4FTG12QfdBVy3q1yveaf4ckL9vWwEcIO3lA=
|
||||||
|
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
|
||||||
|
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
|
||||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||||
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
|
github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE=
|
||||||
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
|
github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ=
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
|
github.com/rabbitmq/amqp091-go v1.9.0 h1:qrQtyzB4H8BQgEuJwhmVQqVHB9O4+MNDJCCAcpc3Aoo=
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
github.com/rabbitmq/amqp091-go v1.9.0/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
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/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||||
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec=
|
||||||
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
|
github.com/sethvargo/go-retry v0.2.4/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
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.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
@@ -135,63 +131,56 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
|
|||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
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/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
||||||
github.com/txix-open/etp/v3 v3.2.0 h1:EgTchT8VtCYV1iEo/y4jII3/NybrXiQDE0y6pmS350M=
|
github.com/txix-open/etp/v3 v3.0.0 h1:dzb28pB5b12r4wWjs1ap1fP10/Wmwngg3mv2V+tkWT4=
|
||||||
github.com/txix-open/etp/v3 v3.2.0/go.mod h1:lgen0TJmiturgBhvlxH1/PQ7iLL/OebKbxPAQYkuKI0=
|
github.com/txix-open/etp/v3 v3.0.0/go.mod h1:DqYK1yIERoFsOWmlgYNrKfLU5u3dE4N64Tzpv7aYLLA=
|
||||||
github.com/txix-open/grmq v1.6.0 h1:V4QRb0sI2CMfdMaMsFGvGvUIDGad5vr3khNU7A3LlP8=
|
github.com/txix-open/grmq v1.6.0 h1:V4QRb0sI2CMfdMaMsFGvGvUIDGad5vr3khNU7A3LlP8=
|
||||||
github.com/txix-open/grmq v1.6.0/go.mod h1:s+NNNv42+32yLpjvl2tpqtyBbMB9e7kKFee3lfa/dyo=
|
github.com/txix-open/grmq v1.6.0/go.mod h1:s+NNNv42+32yLpjvl2tpqtyBbMB9e7kKFee3lfa/dyo=
|
||||||
github.com/txix-open/isp-kit v1.38.1 h1:IYsiW2xc06//xQsWcHX9A1GXCGTXQRXbUqotcxa6eDY=
|
github.com/txix-open/isp-kit v1.31.4 h1:FiOOpsXBhP7B+YaviDXZjzHpAE/J++r9baEgW4Y2gAc=
|
||||||
github.com/txix-open/isp-kit v1.38.1/go.mod h1:uVn5y71Rg8jlFjFK3+QCh9uw1O7mcK+1grCNFZRWhME=
|
github.com/txix-open/isp-kit v1.31.4/go.mod h1:t6/NHdK5JvpIiQU4+NUjky4jLbo7Bz/4hzpoBxZt64U=
|
||||||
github.com/txix-open/jsonschema v1.2.0 h1:B8TrdSsPhDvYv67oi/LVqf7/+PuqFlMsNwUzGeHfl1s=
|
github.com/txix-open/jsonschema v1.2.0 h1:B8TrdSsPhDvYv67oi/LVqf7/+PuqFlMsNwUzGeHfl1s=
|
||||||
github.com/txix-open/jsonschema v1.2.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
github.com/txix-open/jsonschema v1.2.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 h1:Z0Sqf+U+Sc6hfIXtRCIZlbJprkCjwMFbS4ZbEPQ44To=
|
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 h1:Z0Sqf+U+Sc6hfIXtRCIZlbJprkCjwMFbS4ZbEPQ44To=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99/go.mod h1:pA0NYmhL0uEkkxj55S+S7MZU4e2QIt46x9XSrzrWc3c=
|
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99/go.mod h1:pA0NYmhL0uEkkxj55S+S7MZU4e2QIt46x9XSrzrWc3c=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
|
go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 h1:1u/AyyOqAWzy+SkPxDpahCNZParHV8Vid1RnI2clyDE=
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0/go.mod h1:z46paqbJ9l7c9fIPCXTqTGwhQZ5XoTIsfeFYWboizjs=
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0 h1:1wp/gyxsuYtuE/JFxsQRtcCDtMrO2qMvlfXALU5wkzI=
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0/go.mod h1:gbTHmghkGgqxMomVQQMur1Nba4M0MQ8AYThXDUjsJ38=
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30=
|
||||||
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
|
go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4=
|
||||||
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
|
go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY=
|
go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0/go.mod h1:s75jGIWA9OfCMzF0xr+ZgfrB5FEbbV7UuYo32ahUiFI=
|
go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU=
|
go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk=
|
go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94=
|
||||||
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
|
go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A=
|
||||||
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
|
|
||||||
go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE=
|
|
||||||
go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg=
|
|
||||||
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
|
|
||||||
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
|
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
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/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||||
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||||
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||||
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
|
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||||
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||||
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988 h1:+/tmTy5zAieooKIXfzDm9KiA3Bv6JBwriRN9LY+yayk=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be h1:Zz7rLWqp0ApfsR/l7+zSHhY3PMiH2xqgxlfYfAfNpoU=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988/go.mod h1:4+X6GvPs+25wZKbQq9qyAXrwIRExv7w0Ea6MgZLZiDM=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be/go.mod h1:dvdCTIoAGbkWbcIKBniID56/7XHTt6WfxXNMxuziJ+w=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
|
||||||
google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c=
|
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
|
||||||
google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
|
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
|
||||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
@@ -214,3 +203,5 @@ modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
|||||||
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
||||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||||
|
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
|
||||||
|
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
||||||
@@ -43,6 +43,7 @@ func main() {
|
|||||||
|
|
||||||
err = app.Run()
|
err = app.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
boot.Fatal(err)
|
app.Shutdown()
|
||||||
|
logger.Fatal(app.Context(), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/pressly/goose"
|
||||||
|
"isp-system-service/domain"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
insertDomain = "INSERT INTO %s.domain (id, name, description, system_id) VALUES (%d, '%s', '%s', %d) RETURNING id;"
|
||||||
|
insertApplicationGroup = "INSERT INTO %s.application_group (id, name, description, domain_id) VALUES (%d, '%s', '%s', %d) RETURNING id;"
|
||||||
|
insertApp = "INSERT INTO %s.application (id, name, description, application_group_id, type) VALUES (%d, '%s', '%s', %d, '%s') RETURNING id;"
|
||||||
|
insertToken = "INSERT INTO %s.token (token, app_id, expire_time) VALUES ('%s', %d, %d);"
|
||||||
|
|
||||||
|
setSeqQuery = "SELECT setval('%s.%s_id_seq' :: regclass, %d);"
|
||||||
|
|
||||||
|
initFile = "init.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
goose.AddMigration(Initialize.Up, Initialize.Down)
|
||||||
|
}
|
||||||
|
|
||||||
|
var Initialize = &initializeMigration{}
|
||||||
|
|
||||||
|
type initializeMigration struct {
|
||||||
|
migrationDir string
|
||||||
|
schema string
|
||||||
|
}
|
||||||
|
|
||||||
|
type identity struct {
|
||||||
|
domainId int
|
||||||
|
appId int
|
||||||
|
applicationGroupId int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *initializeMigration) SetParams(migrationDir string, schema string) {
|
||||||
|
i.migrationDir = migrationDir
|
||||||
|
i.schema = schema
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *initializeMigration) Up(tx *sql.Tx) error {
|
||||||
|
path := filepath.Join(i.migrationDir, initFile)
|
||||||
|
bytes, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "read file")
|
||||||
|
}
|
||||||
|
|
||||||
|
list := make([]domain.DomainWithApplicationGroup, 0)
|
||||||
|
err = json.Unmarshal(bytes, &list)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "json unmarshal")
|
||||||
|
}
|
||||||
|
|
||||||
|
lastDomainId := 0
|
||||||
|
lastApplicationGroupId := 0
|
||||||
|
lastAppId := 0
|
||||||
|
for _, domainInfo := range list {
|
||||||
|
last, err := i.insert(tx, domainInfo)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "")
|
||||||
|
}
|
||||||
|
if last.domainId > lastDomainId {
|
||||||
|
lastDomainId = last.domainId
|
||||||
|
}
|
||||||
|
if last.applicationGroupId > lastApplicationGroupId {
|
||||||
|
lastApplicationGroupId = last.applicationGroupId
|
||||||
|
}
|
||||||
|
if last.appId > lastAppId {
|
||||||
|
lastAppId = last.appId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.setSeq(tx, "domain", lastDomainId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "set domain")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.setSeq(tx, "application_group", lastApplicationGroupId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "set application group")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.setSeq(tx, "application", lastAppId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "set application")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *initializeMigration) Down(tx *sql.Tx) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *initializeMigration) insert(tx *sql.Tx, domainInfo domain.DomainWithApplicationGroup) (*identity, error) {
|
||||||
|
domainId, err := i.insertNode(tx, insertDomain, true, i.schema, domainInfo.Id, domainInfo.Name, domainInfo.Description, 1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "insert domain")
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationGroupId := 0
|
||||||
|
appId := 0
|
||||||
|
for _, applicationGroup := range domainInfo.ApplicationGroup {
|
||||||
|
applicationGroupId, err = i.insertNode(tx, insertApplicationGroup, true, i.schema, applicationGroup.Id, applicationGroup.Name, applicationGroup.Description, domainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "insert application group")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, app := range applicationGroup.Apps {
|
||||||
|
appId, err = i.insertNode(tx, insertApp, true, i.schema, app.Id, app.Name, app.Description, applicationGroupId, app.Type)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "insert application")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, t := range app.Tokens {
|
||||||
|
_, err = i.insertNode(tx, insertToken, false, i.schema, t.Token, appId, t.ExpireTime)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "insert token")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &identity{
|
||||||
|
domainId: domainId,
|
||||||
|
appId: appId,
|
||||||
|
applicationGroupId: applicationGroupId,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *initializeMigration) insertNode(tx *sql.Tx, query string, scan bool, args ...interface{}) (int, error) {
|
||||||
|
var id int
|
||||||
|
query = fmt.Sprintf(query, args...)
|
||||||
|
row := tx.QueryRow(query)
|
||||||
|
if scan {
|
||||||
|
err := row.Scan(&id)
|
||||||
|
if err != nil {
|
||||||
|
return 0, errors.WithMessage(err, "row scan")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return id, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *initializeMigration) setSeq(tx *sql.Tx, table string, value int) error {
|
||||||
|
q := fmt.Sprintf(setSeqQuery, i.schema, table, value)
|
||||||
|
_, err := tx.Exec(q)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "exec db")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- +goose Up
|
||||||
|
insert into access_list (app_id, method, value)
|
||||||
|
values (1, 'admin/auth/login', true)
|
||||||
|
on conflict (app_id, method) do update set value = true;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
-- +goose Up
|
||||||
|
ALTER TABLE service RENAME TO application_group;
|
||||||
|
|
||||||
|
ALTER TABLE application RENAME COLUMN service_id TO application_group_id;
|
||||||
|
|
||||||
|
ALTER TABLE application RENAME CONSTRAINT UQ_name_service_id TO UQ_name_application_group_id;
|
||||||
|
|
||||||
|
ALTER TABLE application RENAME CONSTRAINT FK_service_id__domain_id TO FK_application_group_id__domain_id;
|
||||||
|
|
||||||
|
ALTER TRIGGER modify_service ON application_group RENAME TO modify_application_group;
|
||||||
|
-- +goose Down
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "rootDomain",
|
||||||
|
"description": "",
|
||||||
|
"services": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "rootService",
|
||||||
|
"description": "",
|
||||||
|
"apps": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "admin",
|
||||||
|
"description": "",
|
||||||
|
"type": "SYSTEM",
|
||||||
|
"tokens": [
|
||||||
|
{
|
||||||
|
"token": "{{ isp_service_admin_token }}",
|
||||||
|
"expireTime": -1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -31,7 +31,7 @@ func (r AccessList) GetAccessListByAppIdAndMethod(ctx context.Context, appId int
|
|||||||
result := entity.AccessList{}
|
result := entity.AccessList{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, appId, method)
|
err := r.db.SelectRow(ctx, &result, q, appId, method)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrAccessListNotFound
|
return nil, domain.ErrAccessListNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessagef(err, "select db")
|
return nil, errors.WithMessagef(err, "select db")
|
||||||
|
|||||||
+17
-17
@@ -24,14 +24,14 @@ func NewApplication(db db.DB) Application {
|
|||||||
|
|
||||||
func (r Application) GetApplicationById(ctx context.Context, id int) (*entity.Application, error) {
|
func (r Application) GetApplicationById(ctx context.Context, id int) (*entity.Application, error) {
|
||||||
q := `
|
q := `
|
||||||
SELECT id, name, description, service_id, type, created_at, updated_at
|
SELECT id, name, description, application_group_id, type, created_at, updated_at
|
||||||
FROM application
|
FROM application
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
`
|
`
|
||||||
result := entity.Application{}
|
result := entity.Application{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, id)
|
err := r.db.SelectRow(ctx, &result, q, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrApplicationNotFound
|
return nil, domain.ErrApplicationNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
@@ -42,7 +42,7 @@ func (r Application) GetApplicationById(ctx context.Context, id int) (*entity.Ap
|
|||||||
|
|
||||||
func (r Application) GetApplicationByIdList(ctx context.Context, idList []int) ([]entity.Application, error) {
|
func (r Application) GetApplicationByIdList(ctx context.Context, idList []int) ([]entity.Application, error) {
|
||||||
q, args, err := query.New().
|
q, args, err := query.New().
|
||||||
Select("id", "name", "description", "service_id", "type", "created_at", "updated_at").
|
Select("id", "name", "description", "application_group_id", "type", "created_at", "updated_at").
|
||||||
From("application").
|
From("application").
|
||||||
Where(squirrel.Eq{"id": idList}).
|
Where(squirrel.Eq{"id": idList}).
|
||||||
OrderBy("created_at DESC").
|
OrderBy("created_at DESC").
|
||||||
@@ -60,11 +60,11 @@ func (r Application) GetApplicationByIdList(ctx context.Context, idList []int) (
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Application) GetApplicationByServiceIdList(ctx context.Context, serviceIdList []int) ([]entity.Application, error) {
|
func (r Application) GetApplicationByApplicationGroupIdList(ctx context.Context, applicationGroupIdList []int) ([]entity.Application, error) {
|
||||||
q, args, err := query.New().
|
q, args, err := query.New().
|
||||||
Select("id", "name", "description", "service_id", "type", "created_at", "updated_at").
|
Select("id", "name", "description", "application_group_id", "type", "created_at", "updated_at").
|
||||||
From("application").
|
From("application").
|
||||||
Where(squirrel.Eq{"service_id": serviceIdList}).
|
Where(squirrel.Eq{"application_group_id": applicationGroupIdList}).
|
||||||
OrderBy("created_at DESC").
|
OrderBy("created_at DESC").
|
||||||
ToSql()
|
ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -80,17 +80,17 @@ func (r Application) GetApplicationByServiceIdList(ctx context.Context, serviceI
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Application) GetApplicationByNameAndServiceId(ctx context.Context, name string, serviceId int) (*entity.Application, error) {
|
func (r Application) GetApplicationByNameAndApplicationGroupId(ctx context.Context, name string, applicationGroupId int) (*entity.Application, error) {
|
||||||
q := `
|
q := `
|
||||||
SELECT id, name, description, service_id, type, created_at, updated_at
|
SELECT id, name, description, application_group_id, type, created_at, updated_at
|
||||||
FROM application
|
FROM application
|
||||||
WHERE name = $1 AND service_id = $2
|
WHERE name = $1 AND application_group_id = $2
|
||||||
`
|
`
|
||||||
result := entity.Application{}
|
result := entity.Application{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, name, serviceId)
|
err := r.db.SelectRow(ctx, &result, q, name, applicationGroupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, nil //nolint:nilnil
|
return nil, nil
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessagef(err, "select row db")
|
return nil, errors.WithMessagef(err, "select row db")
|
||||||
}
|
}
|
||||||
@@ -98,16 +98,16 @@ func (r Application) GetApplicationByNameAndServiceId(ctx context.Context, name
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Application) CreateApplication(ctx context.Context, name string, desc string, serviceId int, appType string) (
|
func (r Application) CreateApplication(ctx context.Context, name string, desc string, applicationGroupId int, appType string) (
|
||||||
*entity.Application, error) {
|
*entity.Application, error) {
|
||||||
q := `
|
q := `
|
||||||
INSERT INTO application
|
INSERT INTO application
|
||||||
(name, description, service_id, type)
|
(name, description, application_group_id, type)
|
||||||
VALUES ($1, $2, $3, $4)
|
VALUES ($1, $2, $3, $4)
|
||||||
RETURNING id, name, description, service_id, type, created_at, updated_at
|
RETURNING id, name, description, application_group_id, type, created_at, updated_at
|
||||||
`
|
`
|
||||||
result := entity.Application{}
|
result := entity.Application{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, name, desc, serviceId, appType)
|
err := r.db.SelectRow(ctx, &result, q, name, desc, applicationGroupId, appType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select row db")
|
return nil, errors.WithMessagef(err, "select row db")
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ func (r Application) UpdateApplication(ctx context.Context, id int, name string,
|
|||||||
SET name = $2,
|
SET name = $2,
|
||||||
description = $3
|
description = $3
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
RETURNING id, name, description, service_id, type, created_at, updated_at
|
RETURNING id, name, description, application_group_id, type, created_at, updated_at
|
||||||
`
|
`
|
||||||
result := entity.Application{}
|
result := entity.Application{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, id, name, description)
|
err := r.db.SelectRow(ctx, &result, q, id, name, description)
|
||||||
|
|||||||
@@ -12,27 +12,27 @@ import (
|
|||||||
"isp-system-service/entity"
|
"isp-system-service/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type ApplicationGroup struct {
|
||||||
db db.DB
|
db db.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(db db.DB) Service {
|
func NewApplicationGroup(db db.DB) ApplicationGroup {
|
||||||
return Service{
|
return ApplicationGroup{
|
||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Service) GetServiceById(ctx context.Context, id int) (*entity.Service, error) {
|
func (r ApplicationGroup) GetApplicationGroupById(ctx context.Context, id int) (*entity.ApplicationGroup, error) {
|
||||||
q := `
|
q := `
|
||||||
SELECT id, name, description, domain_id, created_at, updated_at
|
SELECT id, name, description, domain_id, created_at, updated_at
|
||||||
FROM service
|
FROM application_group
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
`
|
`
|
||||||
result := entity.Service{}
|
result := entity.ApplicationGroup{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, id)
|
err := r.db.SelectRow(ctx, &result, q, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrServiceNotFound
|
return nil, domain.ErrApplicationGroupNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
}
|
}
|
||||||
@@ -40,10 +40,10 @@ func (r Service) GetServiceById(ctx context.Context, id int) (*entity.Service, e
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Service) GetServiceByIdList(ctx context.Context, idList []int) ([]entity.Service, error) {
|
func (r ApplicationGroup) GetApplicationGroupByIdList(ctx context.Context, idList []int) ([]entity.ApplicationGroup, error) {
|
||||||
q, arg, err := query.New().
|
q, arg, err := query.New().
|
||||||
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
|
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
|
||||||
From("service").
|
From("application_group").
|
||||||
Where(squirrel.Eq{"id": idList}).
|
Where(squirrel.Eq{"id": idList}).
|
||||||
OrderBy("created_at DESC").
|
OrderBy("created_at DESC").
|
||||||
ToSql()
|
ToSql()
|
||||||
@@ -51,7 +51,7 @@ func (r Service) GetServiceByIdList(ctx context.Context, idList []int) ([]entity
|
|||||||
return nil, errors.WithMessage(err, "build query")
|
return nil, errors.WithMessage(err, "build query")
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make([]entity.Service, 0)
|
result := make([]entity.ApplicationGroup, 0)
|
||||||
err = r.db.Select(ctx, &result, q, arg...)
|
err = r.db.Select(ctx, &result, q, arg...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select db")
|
return nil, errors.WithMessagef(err, "select db")
|
||||||
@@ -60,10 +60,10 @@ func (r Service) GetServiceByIdList(ctx context.Context, idList []int) ([]entity
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Service) GetServiceByDomainId(ctx context.Context, domainIdList []int) ([]entity.Service, error) {
|
func (r ApplicationGroup) GetApplicationGroupByDomainId(ctx context.Context, domainIdList []int) ([]entity.ApplicationGroup, error) {
|
||||||
q, arg, err := query.New().
|
q, arg, err := query.New().
|
||||||
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
|
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
|
||||||
From("service").
|
From("application_group").
|
||||||
Where(squirrel.Eq{"domain_id": domainIdList}).
|
Where(squirrel.Eq{"domain_id": domainIdList}).
|
||||||
OrderBy("created_at DESC").
|
OrderBy("created_at DESC").
|
||||||
ToSql()
|
ToSql()
|
||||||
@@ -71,7 +71,7 @@ func (r Service) GetServiceByDomainId(ctx context.Context, domainIdList []int) (
|
|||||||
return nil, errors.WithMessage(err, "build query")
|
return nil, errors.WithMessage(err, "build query")
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make([]entity.Service, 0)
|
result := make([]entity.ApplicationGroup, 0)
|
||||||
err = r.db.Select(ctx, &result, q, arg...)
|
err = r.db.Select(ctx, &result, q, arg...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select db")
|
return nil, errors.WithMessagef(err, "select db")
|
||||||
@@ -80,17 +80,17 @@ func (r Service) GetServiceByDomainId(ctx context.Context, domainIdList []int) (
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Service) GetServiceByNameAndDomainId(ctx context.Context, name string, domainId int) (*entity.Service, error) {
|
func (r ApplicationGroup) GetSApplicationGroupByNameAndDomainId(ctx context.Context, name string, domainId int) (*entity.ApplicationGroup, error) {
|
||||||
q := `
|
q := `
|
||||||
SELECT id, name, description, domain_id, created_at, updated_at
|
SELECT id, name, description, domain_id, created_at, updated_at
|
||||||
FROM service
|
FROM application_group
|
||||||
WHERE name = $1 AND domain_id = $2
|
WHERE name = $1 AND domain_id = $2
|
||||||
`
|
`
|
||||||
result := entity.Service{}
|
result := entity.ApplicationGroup{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, name, domainId)
|
err := r.db.SelectRow(ctx, &result, q, name, domainId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrServiceNotFound
|
return nil, domain.ErrApplicationGroupNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select db")
|
return nil, errors.WithMessage(err, "select db")
|
||||||
}
|
}
|
||||||
@@ -98,14 +98,14 @@ func (r Service) GetServiceByNameAndDomainId(ctx context.Context, name string, d
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Service) CreateService(ctx context.Context, name string, desc string, domainId int) (*entity.Service, error) {
|
func (r ApplicationGroup) CreateApplicationGroup(ctx context.Context, name string, desc string, domainId int) (*entity.ApplicationGroup, error) {
|
||||||
q := `
|
q := `
|
||||||
INSERT INTO service
|
INSERT INTO application_group
|
||||||
(name, description, domain_id)
|
(name, description, domain_id)
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2, $3)
|
||||||
RETURNING id, name, description, domain_id, created_at, updated_at
|
RETURNING id, name, description, domain_id, created_at, updated_at
|
||||||
`
|
`
|
||||||
result := entity.Service{}
|
result := entity.ApplicationGroup{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, name, desc, domainId)
|
err := r.db.SelectRow(ctx, &result, q, name, desc, domainId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
@@ -114,18 +114,18 @@ func (r Service) CreateService(ctx context.Context, name string, desc string, do
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Service) UpdateService(ctx context.Context, id int, name string, description string) (*entity.Service, error) {
|
func (r ApplicationGroup) UpdateApplicationGroup(ctx context.Context, id int, name string, description string) (*entity.ApplicationGroup, error) {
|
||||||
q := `
|
q := `
|
||||||
UPDATE service
|
UPDATE application_group
|
||||||
SET name = $1, description = $2
|
SET name = $1, description = $2
|
||||||
WHERE id = $3
|
WHERE id = $3
|
||||||
RETURNING id, name, description, domain_id, created_at, updated_at
|
RETURNING id, name, description, domain_id, created_at, updated_at
|
||||||
`
|
`
|
||||||
result := entity.Service{}
|
result := entity.ApplicationGroup{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, name, description, id)
|
err := r.db.SelectRow(ctx, &result, q, name, description, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrServiceNotFound
|
return nil, domain.ErrApplicationGroupNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
}
|
}
|
||||||
@@ -133,9 +133,9 @@ func (r Service) UpdateService(ctx context.Context, id int, name string, descrip
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Service) DeleteService(ctx context.Context, idList []int) (int, error) {
|
func (r ApplicationGroup) DeleteApplicationGroup(ctx context.Context, idList []int) (int, error) {
|
||||||
q, args, err := query.New().
|
q, args, err := query.New().
|
||||||
Delete("service").
|
Delete("application_group").
|
||||||
Where(squirrel.Eq{"id": idList}).
|
Where(squirrel.Eq{"id": idList}).
|
||||||
ToSql()
|
ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -31,7 +31,7 @@ func (r Domain) GetDomainById(ctx context.Context, id int) (*entity.Domain, erro
|
|||||||
result := entity.Domain{}
|
result := entity.Domain{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, id)
|
err := r.db.SelectRow(ctx, &result, q, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrDomainNotFound
|
return nil, domain.ErrDomainNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
@@ -84,7 +84,7 @@ func (r Domain) GetDomainByNameAndSystemId(ctx context.Context, name string, sys
|
|||||||
result := entity.Domain{}
|
result := entity.Domain{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, name, systemId)
|
err := r.db.SelectRow(ctx, &result, q, name, systemId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrDomainNotFound
|
return nil, domain.ErrDomainNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
@@ -103,7 +103,7 @@ func (r Domain) CreateDomain(ctx context.Context, name string, desc string, syst
|
|||||||
result := entity.Domain{}
|
result := entity.Domain{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, name, desc, systemId)
|
err := r.db.SelectRow(ctx, &result, q, name, desc, systemId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrDomainNotFound
|
return nil, domain.ErrDomainNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
@@ -122,7 +122,7 @@ func (r Domain) UpdateDomain(ctx context.Context, id int, name string, descripti
|
|||||||
result := entity.Domain{}
|
result := entity.Domain{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, name, description, id)
|
err := r.db.SelectRow(ctx, &result, q, name, description, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrDomainNotFound
|
return nil, domain.ErrDomainNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"hash/fnv"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/db"
|
|
||||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
prefix = "msp-service-template"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Locker struct {
|
|
||||||
db db.DB
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewLocker(db db.DB) Locker {
|
|
||||||
return Locker{db: db}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l Locker) TryLock(ctx context.Context, key string) (bool, error) {
|
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Locker.TryLock")
|
|
||||||
|
|
||||||
hash := fnv.New32a()
|
|
||||||
_, err := hash.Write([]byte(prefix + key))
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "generate hash")
|
|
||||||
}
|
|
||||||
sum := hash.Sum32()
|
|
||||||
|
|
||||||
acquired := false
|
|
||||||
err = l.db.SelectRow(ctx, &acquired, "SELECT pg_try_advisory_xact_lock($1)", sum)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "pg try acquire advisory lock")
|
|
||||||
}
|
|
||||||
return acquired, nil
|
|
||||||
}
|
|
||||||
+6
-9
@@ -41,14 +41,11 @@ func (r Token) SaveToken(ctx context.Context, token string, appId int, expireTim
|
|||||||
func (r Token) GetTokenById(ctx context.Context, token string) (*entity.Token, error) {
|
func (r Token) GetTokenById(ctx context.Context, token string) (*entity.Token, error) {
|
||||||
q := `
|
q := `
|
||||||
SELECT token, app_id, expire_time, created_at
|
SELECT token, app_id, expire_time, created_at
|
||||||
FROM token
|
FROM system
|
||||||
WHERE token = $1
|
WHERE token = $1
|
||||||
`
|
`
|
||||||
result := entity.Token{}
|
result := entity.Token{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, token)
|
err := r.db.SelectRow(ctx, &result, q, token)
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
|
||||||
return nil, nil //nolint:nilnil
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
}
|
}
|
||||||
@@ -100,20 +97,20 @@ func (r Token) DeleteToken(ctx context.Context, tokens []string) (int, error) {
|
|||||||
|
|
||||||
func (r Token) AuthDataByToken(ctx context.Context, token string) (*entity.AuthData, error) {
|
func (r Token) AuthDataByToken(ctx context.Context, token string) (*entity.AuthData, error) {
|
||||||
q := `
|
q := `
|
||||||
SELECT system_id, domain_id, service_id, app_id, token.expire_time, token.created_at
|
SELECT system_id, domain_id, application_group_id, app_id, token.expire_time, token.created_at
|
||||||
FROM token
|
FROM token
|
||||||
LEFT JOIN application
|
LEFT JOIN application
|
||||||
ON token.app_id = application.id
|
ON token.app_id = application.id
|
||||||
LEFT JOIN service
|
LEFT JOIN application_group
|
||||||
ON application.service_id = service.id
|
ON application.application_group_id = service.id
|
||||||
LEFT JOIN domain
|
LEFT JOIN domain
|
||||||
ON service.domain_id = domain.id
|
ON application_group.domain_id = domain.id
|
||||||
WHERE token = $1
|
WHERE token = $1
|
||||||
`
|
`
|
||||||
result := entity.AuthData{}
|
result := entity.AuthData{}
|
||||||
err := r.db.SelectRow(ctx, &result, q, token)
|
err := r.db.SelectRow(ctx, &result, q, token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if err == sql.ErrNoRows {
|
||||||
return nil, domain.ErrTokenNotFound
|
return nil, domain.ErrTokenNotFound
|
||||||
}
|
}
|
||||||
return nil, errors.WithMessage(err, "select row db")
|
return nil, errors.WithMessage(err, "select row db")
|
||||||
|
|||||||
+36
-8
@@ -4,23 +4,25 @@ import (
|
|||||||
"github.com/txix-open/isp-kit/cluster"
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/txix-open/isp-kit/grpc/endpoint"
|
"github.com/txix-open/isp-kit/grpc/endpoint"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/isp"
|
||||||
"isp-system-service/controller"
|
"isp-system-service/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Controllers struct {
|
type Controllers struct {
|
||||||
AccessList controller.AccessList
|
AccessList controller.AccessList
|
||||||
Domain controller.Domain
|
Domain controller.Domain
|
||||||
Service controller.Service
|
Service controller.Service
|
||||||
Application controller.Application
|
ApplicationGroup controller.ApplicationGroup
|
||||||
Token controller.Token
|
Application controller.Application
|
||||||
Secure controller.Secure
|
Token controller.Token
|
||||||
|
Secure controller.Secure
|
||||||
}
|
}
|
||||||
|
|
||||||
func EndpointDescriptors() []cluster.EndpointDescriptor {
|
func EndpointDescriptors() []cluster.EndpointDescriptor {
|
||||||
return endpointDescriptors(Controllers{})
|
return endpointDescriptors(Controllers{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func Handler(wrapper endpoint.Wrapper, c Controllers) *grpc.Mux {
|
func Handler(wrapper endpoint.Wrapper, c Controllers) isp.BackendServiceServer {
|
||||||
muxer := grpc.NewMux()
|
muxer := grpc.NewMux()
|
||||||
for _, descriptor := range endpointDescriptors(c) {
|
for _, descriptor := range endpointDescriptors(c) {
|
||||||
muxer.Handle(descriptor.Path, wrapper.Endpoint(descriptor.Handler))
|
muxer.Handle(descriptor.Path, wrapper.Endpoint(descriptor.Handler))
|
||||||
@@ -34,6 +36,7 @@ func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor {
|
|||||||
accessListCluster(c),
|
accessListCluster(c),
|
||||||
domainCluster(c),
|
domainCluster(c),
|
||||||
serviceCluster(c),
|
serviceCluster(c),
|
||||||
|
applicationGroupCluster(c),
|
||||||
applicationCluster(c),
|
applicationCluster(c),
|
||||||
tokenCluster(c),
|
tokenCluster(c),
|
||||||
})
|
})
|
||||||
@@ -129,6 +132,31 @@ func serviceCluster(c Controllers) []cluster.EndpointDescriptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func applicationGroupCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||||
|
return []cluster.EndpointDescriptor{
|
||||||
|
{
|
||||||
|
Path: "system/application_group/get_group",
|
||||||
|
Inner: true,
|
||||||
|
Handler: c.ApplicationGroup.Get,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Path: "system/application_group/create_update_group",
|
||||||
|
Inner: true,
|
||||||
|
Handler: c.ApplicationGroup.CreateUpdate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Path: "system/application_group/get_group_by_id",
|
||||||
|
Inner: true,
|
||||||
|
Handler: c.ApplicationGroup.GetById,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Path: "system/application_group/delete_group",
|
||||||
|
Inner: true,
|
||||||
|
Handler: c.ApplicationGroup.Delete,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func applicationCluster(c Controllers) []cluster.EndpointDescriptor {
|
func applicationCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||||
return []cluster.EndpointDescriptor{
|
return []cluster.EndpointDescriptor{
|
||||||
{
|
{
|
||||||
@@ -139,7 +167,7 @@ func applicationCluster(c Controllers) []cluster.EndpointDescriptor {
|
|||||||
{
|
{
|
||||||
Path: "system/application/get_applications_by_service_id",
|
Path: "system/application/get_applications_by_service_id",
|
||||||
Inner: true,
|
Inner: true,
|
||||||
Handler: c.Application.GetByServiceId,
|
Handler: c.Application.GetByApplicationGroupId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: "system/application/create_update_application",
|
Path: "system/application/create_update_application",
|
||||||
|
|||||||
+51
-51
@@ -11,8 +11,8 @@ import (
|
|||||||
type IApplicationApplicationRep interface {
|
type IApplicationApplicationRep interface {
|
||||||
GetApplicationById(ctx context.Context, id int) (*entity.Application, error)
|
GetApplicationById(ctx context.Context, id int) (*entity.Application, error)
|
||||||
GetApplicationByIdList(ctx context.Context, idList []int) ([]entity.Application, error)
|
GetApplicationByIdList(ctx context.Context, idList []int) ([]entity.Application, error)
|
||||||
GetApplicationByServiceIdList(ctx context.Context, serviceIdList []int) ([]entity.Application, error)
|
GetApplicationByApplicationGroupIdList(ctx context.Context, serviceIdList []int) ([]entity.Application, error)
|
||||||
GetApplicationByNameAndServiceId(ctx context.Context, name string, serviceId int) (*entity.Application, error)
|
GetApplicationByNameAndApplicationGroupId(ctx context.Context, name string, serviceId int) (*entity.Application, error)
|
||||||
CreateApplication(ctx context.Context, name string, desc string, serviceId int, appType string) (*entity.Application, error)
|
CreateApplication(ctx context.Context, name string, desc string, serviceId int, appType string) (*entity.Application, error)
|
||||||
UpdateApplication(ctx context.Context, id int, name string, description string) (*entity.Application, error)
|
UpdateApplication(ctx context.Context, id int, name string, description string) (*entity.Application, error)
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,8 @@ type IApplicationTokenRep interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IApplicationServiceRep interface {
|
type IApplicationServiceRep interface {
|
||||||
GetServiceById(ctx context.Context, id int) (*entity.Service, error)
|
GetApplicationGroupById(ctx context.Context, id int) (*entity.ApplicationGroup, error)
|
||||||
GetServiceByDomainId(ctx context.Context, domainIdList []int) ([]entity.Service, error)
|
GetApplicationGroupByDomainId(ctx context.Context, domainIdList []int) ([]entity.ApplicationGroup, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type IApplicationDomainRep interface {
|
type IApplicationDomainRep interface {
|
||||||
@@ -42,7 +42,7 @@ type Application struct {
|
|||||||
tx IApplicationTxRunner
|
tx IApplicationTxRunner
|
||||||
applicationRep IApplicationApplicationRep
|
applicationRep IApplicationApplicationRep
|
||||||
domainRep IApplicationDomainRep
|
domainRep IApplicationDomainRep
|
||||||
serviceRep IApplicationServiceRep
|
groupRep IApplicationServiceRep
|
||||||
tokenRep IApplicationTokenRep
|
tokenRep IApplicationTokenRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,14 +50,14 @@ func NewApplication(
|
|||||||
tx IApplicationTxRunner,
|
tx IApplicationTxRunner,
|
||||||
applicationRep IApplicationApplicationRep,
|
applicationRep IApplicationApplicationRep,
|
||||||
domainRep IApplicationDomainRep,
|
domainRep IApplicationDomainRep,
|
||||||
serviceRep IApplicationServiceRep,
|
groupRep IApplicationServiceRep,
|
||||||
tokenRep IApplicationTokenRep,
|
tokenRep IApplicationTokenRep,
|
||||||
) Application {
|
) Application {
|
||||||
return Application{
|
return Application{
|
||||||
tx: tx,
|
tx: tx,
|
||||||
applicationRep: applicationRep,
|
applicationRep: applicationRep,
|
||||||
domainRep: domainRep,
|
domainRep: domainRep,
|
||||||
serviceRep: serviceRep,
|
groupRep: groupRep,
|
||||||
tokenRep: tokenRep,
|
tokenRep: tokenRep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,26 +85,26 @@ func (s Application) GetByIdList(ctx context.Context, idList []int) ([]*domain.A
|
|||||||
return s.EnrichWithTokens(ctx, res)
|
return s.EnrichWithTokens(ctx, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Application) GetByServiceId(ctx context.Context, id int) ([]*domain.ApplicationWithTokens, error) {
|
func (s Application) GetByApplicationGroupId(ctx context.Context, id int) ([]*domain.ApplicationWithTokens, error) {
|
||||||
arr, err := s.applicationRep.GetApplicationByServiceIdList(ctx, []int{id})
|
arr, err := s.applicationRep.GetApplicationByApplicationGroupIdList(ctx, []int{id})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get application by service_id")
|
return nil, errors.WithMessage(err, "get application by application_group_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.EnrichWithTokens(ctx, arr)
|
return s.EnrichWithTokens(ctx, arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithService, error) {
|
func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithApplicationGroup, error) {
|
||||||
domainEntityList, err := s.domainRep.GetDomainBySystemId(ctx, systemId)
|
domainEntityList, err := s.domainRep.GetDomainBySystemId(ctx, systemId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get domains by system_id")
|
return nil, errors.WithMessage(err, "get domains by system_id")
|
||||||
}
|
}
|
||||||
if len(domainEntityList) == 0 {
|
if len(domainEntityList) == 0 {
|
||||||
return []*domain.DomainWithService{}, nil
|
return []*domain.DomainWithApplicationGroup{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make([]*domain.DomainWithService, len(domainEntityList))
|
result := make([]*domain.DomainWithApplicationGroup, len(domainEntityList))
|
||||||
resultByDomainId := make(map[int]*domain.DomainWithService, len(domainEntityList))
|
resultByDomainId := make(map[int]*domain.DomainWithApplicationGroup, len(domainEntityList))
|
||||||
domainIdList := make([]int, len(domainEntityList))
|
domainIdList := make([]int, len(domainEntityList))
|
||||||
for i, domainEntity := range domainEntityList {
|
for i, domainEntity := range domainEntityList {
|
||||||
domainIdList[i] = domainEntity.Id
|
domainIdList[i] = domainEntity.Id
|
||||||
@@ -112,52 +112,52 @@ func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.Do
|
|||||||
if domainEntity.Description != nil {
|
if domainEntity.Description != nil {
|
||||||
description = *domainEntity.Description
|
description = *domainEntity.Description
|
||||||
}
|
}
|
||||||
r := &domain.DomainWithService{
|
r := &domain.DomainWithApplicationGroup{
|
||||||
Id: domainEntity.Id,
|
Id: domainEntity.Id,
|
||||||
Name: domainEntity.Name,
|
Name: domainEntity.Name,
|
||||||
Description: description,
|
Description: description,
|
||||||
Services: make([]*domain.ServiceWithApps, 0),
|
ApplicationGroup: make([]*domain.ApplicationGroupWithApps, 0),
|
||||||
}
|
}
|
||||||
resultByDomainId[domainEntity.Id] = r
|
resultByDomainId[domainEntity.Id] = r
|
||||||
result[i] = r
|
result[i] = r
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceEntityList, err := s.serviceRep.GetServiceByDomainId(ctx, domainIdList)
|
applicationGroupEntityList, err := s.groupRep.GetApplicationGroupByDomainId(ctx, domainIdList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get service by domain_id")
|
return nil, errors.WithMessage(err, "get application group by domain_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceIdList := make([]int, len(serviceEntityList))
|
applicationGroupIdList := make([]int, len(applicationGroupEntityList))
|
||||||
resultServiceByServiceId := make(map[int]*domain.ServiceWithApps, len(serviceEntityList))
|
resultApplicationGroupById := make(map[int]*domain.ApplicationGroupWithApps, len(applicationGroupEntityList))
|
||||||
for i, serviceEntity := range serviceEntityList {
|
for i, applicationGroupEntity := range applicationGroupEntityList {
|
||||||
serviceIdList[i] = serviceEntity.Id
|
applicationGroupIdList[i] = applicationGroupEntity.Id
|
||||||
description := ""
|
description := ""
|
||||||
if serviceEntity.Description != nil {
|
if applicationGroupEntity.Description != nil {
|
||||||
description = *serviceEntity.Description
|
description = *applicationGroupEntity.Description
|
||||||
}
|
}
|
||||||
resultService := &domain.ServiceWithApps{
|
resultApplicationGroup := &domain.ApplicationGroupWithApps{
|
||||||
Id: serviceEntity.Id,
|
Id: applicationGroupEntity.Id,
|
||||||
Name: serviceEntity.Name,
|
Name: applicationGroupEntity.Name,
|
||||||
Description: description,
|
Description: description,
|
||||||
Apps: make([]*domain.ApplicationSimple, 0),
|
Apps: make([]*domain.ApplicationSimple, 0),
|
||||||
}
|
}
|
||||||
r := resultByDomainId[serviceEntity.DomainId]
|
r := resultByDomainId[applicationGroupEntity.DomainId]
|
||||||
r.Services = append(r.Services, resultService)
|
r.ApplicationGroup = append(r.ApplicationGroup, resultApplicationGroup)
|
||||||
resultServiceByServiceId[serviceEntity.Id] = resultService
|
resultApplicationGroupById[applicationGroupEntity.Id] = resultApplicationGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationEntityList, err := s.applicationRep.GetApplicationByServiceIdList(ctx, serviceIdList)
|
applicationEntityList, err := s.applicationRep.GetApplicationByApplicationGroupIdList(ctx, applicationGroupIdList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "get application by service_id")
|
return nil, errors.WithMessagef(err, "get application by application_group_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, applicationEntity := range applicationEntityList {
|
for _, applicationEntity := range applicationEntityList {
|
||||||
resultService := resultServiceByServiceId[applicationEntity.ServiceId]
|
resultApplicationGroup := resultApplicationGroupById[applicationEntity.ApplicationGroupId]
|
||||||
description := ""
|
description := ""
|
||||||
if applicationEntity.Description != nil {
|
if applicationEntity.Description != nil {
|
||||||
description = *applicationEntity.Description
|
description = *applicationEntity.Description
|
||||||
}
|
}
|
||||||
resultService.Apps = append(resultService.Apps, &domain.ApplicationSimple{
|
resultApplicationGroup.Apps = append(resultApplicationGroup.Apps, &domain.ApplicationSimple{
|
||||||
Id: applicationEntity.Id,
|
Id: applicationEntity.Id,
|
||||||
Name: applicationEntity.Name,
|
Name: applicationEntity.Name,
|
||||||
Type: applicationEntity.Type,
|
Type: applicationEntity.Type,
|
||||||
@@ -170,16 +170,16 @@ func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.Do
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error) {
|
func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error) {
|
||||||
existed, err := s.applicationRep.GetApplicationByNameAndServiceId(ctx, req.Name, req.ServiceId)
|
existed, err := s.applicationRep.GetApplicationByNameAndApplicationGroupId(ctx, req.Name, req.ApplicationGroupId)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, domain.ErrApplicationNotFound):
|
case errors.Is(err, domain.ErrApplicationNotFound):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return nil, errors.WithMessage(err, "get application by name and service_id")
|
return nil, errors.WithMessage(err, "get application by name and application_group_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.serviceRep.GetServiceById(ctx, req.ServiceId)
|
_, err = s.groupRep.GetApplicationGroupById(ctx, req.ApplicationGroupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get service by id")
|
return nil, errors.WithMessage(err, "get application group by id")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Id == 0 {
|
if req.Id == 0 {
|
||||||
@@ -187,12 +187,12 @@ func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCre
|
|||||||
return nil, domain.ErrApplicationDuplicateName
|
return nil, domain.ErrApplicationDuplicateName
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.applicationRep.GetApplicationByNameAndServiceId(ctx, req.Name, req.ServiceId)
|
_, err = s.applicationRep.GetApplicationByNameAndApplicationGroupId(ctx, req.Name, req.ApplicationGroupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get application by name and service_id")
|
return nil, errors.WithMessage(err, "get application by name and application_group_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
app, err := s.applicationRep.CreateApplication(ctx, req.Name, req.Description, req.ServiceId, req.Type)
|
app, err := s.applicationRep.CreateApplication(ctx, req.Name, req.Description, req.ApplicationGroupId, req.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "create application")
|
return nil, errors.WithMessage(err, "create application")
|
||||||
}
|
}
|
||||||
@@ -283,12 +283,12 @@ func (s Application) convertApplication(req entity.Application) domain.Applicati
|
|||||||
}
|
}
|
||||||
|
|
||||||
return domain.Application{
|
return domain.Application{
|
||||||
Id: req.Id,
|
Id: req.Id,
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Description: desc,
|
Description: desc,
|
||||||
ServiceId: req.ServiceId,
|
ApplicationGroupId: req.ApplicationGroupId,
|
||||||
Type: req.Type,
|
Type: req.Type,
|
||||||
CreatedAt: req.CreatedAt,
|
CreatedAt: req.CreatedAt,
|
||||||
UpdatedAt: req.UpdatedAt,
|
UpdatedAt: req.UpdatedAt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"isp-system-service/domain"
|
||||||
|
"isp-system-service/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IApplicationGroupRep interface {
|
||||||
|
GetApplicationGroupById(ctx context.Context, id int) (*entity.ApplicationGroup, error)
|
||||||
|
GetApplicationGroupByIdList(ctx context.Context, idList []int) ([]entity.ApplicationGroup, error)
|
||||||
|
GetApplicationGroupByDomainId(ctx context.Context, domainIdList []int) ([]entity.ApplicationGroup, error)
|
||||||
|
GetSApplicationGroupByNameAndDomainId(ctx context.Context, name string, domainId int) (*entity.ApplicationGroup, error)
|
||||||
|
CreateApplicationGroup(ctx context.Context, name string, desc string, domainId int) (*entity.ApplicationGroup, error)
|
||||||
|
UpdateApplicationGroup(ctx context.Context, id int, name string, description string) (*entity.ApplicationGroup, error)
|
||||||
|
DeleteApplicationGroup(ctx context.Context, idList []int) (int, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type IApplicationGroupDomainRep interface {
|
||||||
|
GetDomainById(ctx context.Context, id int) (*entity.Domain, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ApplicationGroup struct {
|
||||||
|
domainRep IApplicationGroupDomainRep
|
||||||
|
groupRep IApplicationGroupRep
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewApplicationGroup(
|
||||||
|
domainRep IApplicationGroupDomainRep,
|
||||||
|
groupRep IApplicationGroupRep,
|
||||||
|
) ApplicationGroup {
|
||||||
|
return ApplicationGroup{
|
||||||
|
domainRep: domainRep,
|
||||||
|
groupRep: groupRep,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ApplicationGroup) GetById(ctx context.Context, id int) (*domain.ApplicationGroup, error) {
|
||||||
|
applicationGroupEntity, err := s.groupRep.GetApplicationGroupById(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessagef(err, "get application group by id")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := s.convertApplicationGroup(*applicationGroupEntity)
|
||||||
|
return &result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ApplicationGroup) GetByIdList(ctx context.Context, idList []int) ([]domain.ApplicationGroup, error) {
|
||||||
|
applicationGroupEntity, err := s.groupRep.GetApplicationGroupByIdList(ctx, idList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get system by id list")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make([]domain.ApplicationGroup, len(applicationGroupEntity))
|
||||||
|
for i := range applicationGroupEntity {
|
||||||
|
result[i] = s.convertApplicationGroup(applicationGroupEntity[i])
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ApplicationGroup) GetByDomainId(ctx context.Context, domainId int) ([]domain.ApplicationGroup, error) {
|
||||||
|
applicationGroupEntity, err := s.groupRep.GetApplicationGroupByDomainId(ctx, []int{domainId})
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get system by id list")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make([]domain.ApplicationGroup, len(applicationGroupEntity))
|
||||||
|
for i := range applicationGroupEntity {
|
||||||
|
result[i] = s.convertApplicationGroup(applicationGroupEntity[i])
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ApplicationGroup) CreateUpdate(ctx context.Context, req domain.ApplicationGroupCreateUpdateRequest) (*domain.ApplicationGroup, error) {
|
||||||
|
req.DomainId = 1 // Хардкодом проставляем domainId = 1
|
||||||
|
|
||||||
|
existed, err := s.groupRep.GetSApplicationGroupByNameAndDomainId(ctx, req.Name, req.DomainId)
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, domain.ErrApplicationGroupNotFound):
|
||||||
|
case err != nil:
|
||||||
|
return nil, errors.WithMessage(err, "get application group by name and domain_id")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = s.domainRep.GetDomainById(ctx, req.DomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get domain by id")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Id == 0 {
|
||||||
|
if existed != nil {
|
||||||
|
return nil, domain.ErrDomainDuplicateName
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationGroupEntity, err := s.groupRep.CreateApplicationGroup(ctx, req.Name, req.Description, req.DomainId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "create application group")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := s.convertApplicationGroup(*applicationGroupEntity)
|
||||||
|
return &result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if existed != nil && existed.Id != req.Id {
|
||||||
|
return nil, domain.ErrDomainDuplicateName
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = s.groupRep.GetApplicationGroupById(ctx, req.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get application group by id")
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationGroupEntity, err := s.groupRep.UpdateApplicationGroup(ctx, req.Id, req.Name, req.Description)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "update application group")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := s.convertApplicationGroup(*applicationGroupEntity)
|
||||||
|
return &result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ApplicationGroup) Delete(ctx context.Context, idList []int) (int, error) {
|
||||||
|
result, err := s.groupRep.DeleteApplicationGroup(ctx, idList)
|
||||||
|
if err != nil {
|
||||||
|
return 0, errors.WithMessage(err, "delete application group")
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ApplicationGroup) convertApplicationGroup(req entity.ApplicationGroup) domain.ApplicationGroup {
|
||||||
|
desc := ""
|
||||||
|
if req.Description != nil {
|
||||||
|
desc = *req.Description
|
||||||
|
}
|
||||||
|
result := domain.ApplicationGroup{
|
||||||
|
Id: req.Id,
|
||||||
|
Name: req.Name,
|
||||||
|
Description: desc,
|
||||||
|
DomainId: req.DomainId,
|
||||||
|
CreatedAt: req.CreatedAt,
|
||||||
|
UpdatedAt: req.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package baseline
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"isp-system-service/conf"
|
|
||||||
"isp-system-service/entity"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Transaction interface {
|
|
||||||
CreateDomain(ctx context.Context, name string, desc string, systemId int) (*entity.Domain, error)
|
|
||||||
CreateService(ctx context.Context, name string, desc string, domainId int) (*entity.Service, error)
|
|
||||||
CreateApplication(ctx context.Context, name string, desc string, serviceId 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)
|
|
||||||
GetTokenById(ctx context.Context, token string) (*entity.Token, error)
|
|
||||||
TryLock(ctx context.Context, key string) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type TxRunner interface {
|
|
||||||
BaselineTx(ctx context.Context, tx func(ctx context.Context, tx Transaction) error) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
cfg conf.Baseline
|
|
||||||
txRunner TxRunner
|
|
||||||
logger log.Logger
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(cfg conf.Baseline, txRunner TxRunner, logger log.Logger) Service {
|
|
||||||
return Service{
|
|
||||||
cfg: cfg,
|
|
||||||
txRunner: txRunner,
|
|
||||||
logger: logger,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) Do(ctx context.Context) error {
|
|
||||||
ctx = log.ToContext(ctx, log.String("worker", "baseline"))
|
|
||||||
if s.cfg.InitialAdminUiToken == "" {
|
|
||||||
s.logger.Info(ctx, "initial admin ui token is empty, skip baseline")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
err := s.txRunner.BaselineTx(ctx, s.transaction)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "run baseline transaction")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) transaction(ctx context.Context, tx Transaction) error {
|
|
||||||
locked, err := tx.TryLock(ctx, "isp-system-service.baseline")
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "try lock isp-system-service.baseline")
|
|
||||||
}
|
|
||||||
if !locked {
|
|
||||||
s.logger.Info(ctx, "baseline is locked, skip baseline")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
token, err := tx.GetTokenById(ctx, s.cfg.InitialAdminUiToken)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "get token by id")
|
|
||||||
}
|
|
||||||
if token != nil {
|
|
||||||
s.logger.Info(ctx, "initial admin ui token is exist, skip baseline")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
s.logger.Info(ctx, "initial admin ui token is empty, run baseline")
|
|
||||||
|
|
||||||
domain, err := tx.CreateDomain(ctx, "root", "", 1)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "create domain")
|
|
||||||
}
|
|
||||||
|
|
||||||
service, err := tx.CreateService(ctx, "rootService", "", domain.Id)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "create service")
|
|
||||||
}
|
|
||||||
|
|
||||||
app, err := tx.CreateApplication(ctx, "admin", "", service.Id, "SYSTEM")
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "create application")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = tx.SaveToken(ctx, s.cfg.InitialAdminUiToken, app.Id, -1)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "save token")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = tx.UpsertAccessList(ctx, entity.AccessList{
|
|
||||||
AppId: app.Id,
|
|
||||||
Method: "admin/auth/login",
|
|
||||||
Value: true,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "upsert access list")
|
|
||||||
}
|
|
||||||
|
|
||||||
s.logger.Info(ctx, "baseline done")
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -17,22 +17,22 @@ type AccessListRep interface {
|
|||||||
GetAccessListByAppIdAndMethod(ctx context.Context, appId int, method string) (*entity.AccessList, error)
|
GetAccessListByAppIdAndMethod(ctx context.Context, appId int, method string) (*entity.AccessList, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
type ApplicationGroup struct {
|
||||||
tokenRep TokenRep
|
tokenRep TokenRep
|
||||||
accessListRep AccessListRep
|
accessListRep AccessListRep
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(
|
func NewApplicationGroup(
|
||||||
tokenRep TokenRep,
|
tokenRep TokenRep,
|
||||||
accessListRep AccessListRep,
|
accessListRep AccessListRep,
|
||||||
) Service {
|
) ApplicationGroup {
|
||||||
return Service{
|
return ApplicationGroup{
|
||||||
tokenRep: tokenRep,
|
tokenRep: tokenRep,
|
||||||
accessListRep: accessListRep,
|
accessListRep: accessListRep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Service) Authenticate(ctx context.Context, token string) (*domain.AuthData, error) {
|
func (s ApplicationGroup) Authenticate(ctx context.Context, token string) (*domain.AuthData, error) {
|
||||||
authData, err := s.tokenRep.AuthDataByToken(ctx, token)
|
authData, err := s.tokenRep.AuthDataByToken(ctx, token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get auth data by token")
|
return nil, errors.WithMessage(err, "get auth data by token")
|
||||||
@@ -44,14 +44,14 @@ func (s Service) Authenticate(ctx context.Context, token string) (*domain.AuthDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &domain.AuthData{
|
return &domain.AuthData{
|
||||||
SystemId: authData.SystemId,
|
SystemId: authData.SystemId,
|
||||||
DomainId: authData.DomainId,
|
DomainId: authData.DomainId,
|
||||||
ServiceId: authData.ServiceId,
|
ApplicationGroupId: authData.ApplicationGroupIdId,
|
||||||
ApplicationId: authData.AppId,
|
ApplicationId: authData.AppId,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Service) Authorize(ctx context.Context, appId int, endpoint string) (bool, error) {
|
func (s ApplicationGroup) Authorize(ctx context.Context, appId int, endpoint string) (bool, error) {
|
||||||
accessList, err := s.accessListRep.GetAccessListByAppIdAndMethod(ctx, appId, endpoint)
|
accessList, err := s.accessListRep.GetAccessListByAppIdAndMethod(ctx, appId, endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.WithMessage(err, "get access list by app_id and method")
|
return false, errors.WithMessage(err, "get access list by app_id and method")
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-system-service/domain"
|
|
||||||
"isp-system-service/entity"
|
|
||||||
)
|
|
||||||
|
|
||||||
type IServiceServiceRep interface {
|
|
||||||
GetServiceById(ctx context.Context, id int) (*entity.Service, error)
|
|
||||||
GetServiceByIdList(ctx context.Context, idList []int) ([]entity.Service, error)
|
|
||||||
GetServiceByDomainId(ctx context.Context, domainIdList []int) ([]entity.Service, error)
|
|
||||||
GetServiceByNameAndDomainId(ctx context.Context, name string, domainId int) (*entity.Service, error)
|
|
||||||
CreateService(ctx context.Context, name string, desc string, domainId int) (*entity.Service, error)
|
|
||||||
UpdateService(ctx context.Context, id int, name string, description string) (*entity.Service, error)
|
|
||||||
DeleteService(ctx context.Context, idList []int) (int, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type IServiceDomainRep interface {
|
|
||||||
GetDomainById(ctx context.Context, id int) (*entity.Domain, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
domainRep IServiceDomainRep
|
|
||||||
serviceRep IServiceServiceRep
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(
|
|
||||||
domainRep IServiceDomainRep,
|
|
||||||
serviceRep IServiceServiceRep,
|
|
||||||
) Service {
|
|
||||||
return Service{
|
|
||||||
domainRep: domainRep,
|
|
||||||
serviceRep: serviceRep,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) GetById(ctx context.Context, id int) (*domain.Service, error) {
|
|
||||||
serviceEntity, err := s.serviceRep.GetServiceById(ctx, id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessagef(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.serviceRep.GetServiceByIdList(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.serviceRep.GetServiceByDomainId(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) {
|
|
||||||
existed, err := s.serviceRep.GetServiceByNameAndDomainId(ctx, req.Name, req.DomainId)
|
|
||||||
switch {
|
|
||||||
case errors.Is(err, domain.ErrServiceNotFound):
|
|
||||||
case err != nil:
|
|
||||||
return nil, errors.WithMessage(err, "get service by name and domain_id")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = s.domainRep.GetDomainById(ctx, req.DomainId)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "get domain by id")
|
|
||||||
}
|
|
||||||
|
|
||||||
if req.Id == 0 {
|
|
||||||
if existed != nil {
|
|
||||||
return nil, domain.ErrDomainDuplicateName
|
|
||||||
}
|
|
||||||
|
|
||||||
serviceEntity, err := s.serviceRep.CreateService(ctx, req.Name, req.Description, req.DomainId)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "create service")
|
|
||||||
}
|
|
||||||
|
|
||||||
result := s.convertService(*serviceEntity)
|
|
||||||
return &result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if existed != nil && existed.Id != req.Id {
|
|
||||||
return nil, domain.ErrDomainDuplicateName
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = s.serviceRep.GetServiceById(ctx, req.Id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "get service by id")
|
|
||||||
}
|
|
||||||
|
|
||||||
serviceEntity, err := s.serviceRep.UpdateService(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.serviceRep.DeleteService(ctx, idList)
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.WithMessage(err, "delete service")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) convertService(req entity.Service) domain.Service {
|
|
||||||
desc := ""
|
|
||||||
if req.Description != nil {
|
|
||||||
desc = *req.Description
|
|
||||||
}
|
|
||||||
result := domain.Service{
|
|
||||||
Id: req.Id,
|
|
||||||
Name: req.Name,
|
|
||||||
Description: desc,
|
|
||||||
DomainId: req.DomainId,
|
|
||||||
CreatedAt: req.CreatedAt,
|
|
||||||
UpdatedAt: req.UpdatedAt,
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
+19
-19
@@ -21,7 +21,7 @@ type ITokenApplicationRep interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ITokenServiceRep interface {
|
type ITokenServiceRep interface {
|
||||||
GetServiceById(ctx context.Context, id int) (*entity.Service, error)
|
GetApplicationGroupById(ctx context.Context, id int) (*entity.ApplicationGroup, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ITokenDomainRep interface {
|
type ITokenDomainRep interface {
|
||||||
@@ -46,13 +46,13 @@ type ITokenTxRunner interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Token struct {
|
type Token struct {
|
||||||
jwt ITokenSource
|
jwt ITokenSource
|
||||||
appEnrich ITokenAppEnrich
|
appEnrich ITokenAppEnrich
|
||||||
tx ITokenTxRunner
|
tx ITokenTxRunner
|
||||||
appRep ITokenApplicationRep
|
appRep ITokenApplicationRep
|
||||||
domainRep ITokenDomainRep
|
domainRep ITokenDomainRep
|
||||||
serviceRep ITokenServiceRep
|
groupRep ITokenServiceRep
|
||||||
tokenRep ITokenTokenRep
|
tokenRep ITokenTokenRep
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewToken(
|
func NewToken(
|
||||||
@@ -61,17 +61,17 @@ func NewToken(
|
|||||||
tx ITokenTxRunner,
|
tx ITokenTxRunner,
|
||||||
appRep ITokenApplicationRep,
|
appRep ITokenApplicationRep,
|
||||||
domainRep ITokenDomainRep,
|
domainRep ITokenDomainRep,
|
||||||
serviceRep ITokenServiceRep,
|
groupRep ITokenServiceRep,
|
||||||
tokenRep ITokenTokenRep,
|
tokenRep ITokenTokenRep,
|
||||||
) Token {
|
) Token {
|
||||||
return Token{
|
return Token{
|
||||||
appEnrich: appEnrich,
|
appEnrich: appEnrich,
|
||||||
jwt: jwtGenerate,
|
jwt: jwtGenerate,
|
||||||
tx: tx,
|
tx: tx,
|
||||||
appRep: appRep,
|
appRep: appRep,
|
||||||
domainRep: domainRep,
|
domainRep: domainRep,
|
||||||
serviceRep: serviceRep,
|
groupRep: groupRep,
|
||||||
tokenRep: tokenRep,
|
tokenRep: tokenRep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,12 +95,12 @@ func (s Token) Create(ctx context.Context, req domain.TokenCreateRequest) (*doma
|
|||||||
return nil, errors.WithMessagef(err, "get application by id")
|
return nil, errors.WithMessagef(err, "get application by id")
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceEntity, err := s.serviceRep.GetServiceById(ctx, applicationEntity.ServiceId)
|
applicationGroupIdEntity, err := s.groupRep.GetApplicationGroupById(ctx, applicationEntity.ApplicationGroupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "get service by id")
|
return nil, errors.WithMessagef(err, "get application groupId by id")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.domainRep.GetDomainById(ctx, serviceEntity.DomainId)
|
_, err = s.domainRep.GetDomainById(ctx, applicationGroupIdEntity.DomainId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "get domain by id")
|
return nil, errors.WithMessagef(err, "get domain by id")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func NewTokenSource() TokenSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s TokenSource) CreateApplicationToken() (string, error) {
|
func (s TokenSource) CreateApplicationToken() (string, error) {
|
||||||
cryptoRand := make([]byte, 128) //nolint:mnd
|
cryptoRand := make([]byte, 128) //nolint:gomnd
|
||||||
_, err := rand.Read(cryptoRand)
|
_, err := rand.Read(cryptoRand)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.WithMessage(err, "crypto/rand read")
|
return "", errors.WithMessage(err, "crypto/rand read")
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
package tests_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"github.com/stretchr/testify/suite"
|
|
||||||
"github.com/txix-open/isp-kit/dbx"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
|
||||||
"github.com/txix-open/isp-kit/test"
|
|
||||||
"github.com/txix-open/isp-kit/test/dbt"
|
|
||||||
"github.com/txix-open/isp-kit/test/fake"
|
|
||||||
"github.com/txix-open/isp-kit/test/grpct"
|
|
||||||
"isp-system-service/assembly"
|
|
||||||
"isp-system-service/conf"
|
|
||||||
"isp-system-service/service/baseline"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestBaselineSuite(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
suite.Run(t, &BaselineSuite{})
|
|
||||||
}
|
|
||||||
|
|
||||||
type BaselineSuite struct {
|
|
||||||
suite.Suite
|
|
||||||
test *test.Test
|
|
||||||
testDb *dbt.TestDb
|
|
||||||
baseline baseline.Service
|
|
||||||
api *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *BaselineSuite) SetupSuite() {
|
|
||||||
s.test, _ = test.New(s.T())
|
|
||||||
|
|
||||||
s.testDb = dbt.New(s.test, dbx.WithMigrationRunner("../migrations", s.test.Logger()))
|
|
||||||
|
|
||||||
locator := assembly.NewLocator(s.testDb, s.test.Logger())
|
|
||||||
config := locator.Config(conf.Remote{
|
|
||||||
Baseline: conf.Baseline{
|
|
||||||
InitialAdminUiToken: fake.It[string](),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
s.baseline = config.Baseline
|
|
||||||
_, s.api = grpct.TestServer(s.test, config.Handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *BaselineSuite) TestBaselineSuccess() {
|
|
||||||
err := s.baseline.Do(context.Background())
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
err = s.baseline.Do(context.Background())
|
|
||||||
s.Require().NoError(err)
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package tests_test
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/txix-open/isp-kit/test/dbt"
|
"github.com/txix-open/isp-kit/test/dbt"
|
||||||
@@ -15,9 +15,9 @@ func InsertDomain(db *dbt.TestDb, value entity.Domain) {
|
|||||||
db.Must().ExecNamed(q, value)
|
db.Must().ExecNamed(q, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertService(db *dbt.TestDb, value entity.Service) {
|
func InsertApplicationGroup(db *dbt.TestDb, value entity.ApplicationGroup) {
|
||||||
q := `
|
q := `
|
||||||
INSERT INTO service
|
INSERT INTO application_group
|
||||||
(id, name, description, domain_id, created_at, updated_at)
|
(id, name, description, domain_id, created_at, updated_at)
|
||||||
VALUES
|
VALUES
|
||||||
(:id, :name, :description, :domain_id, :created_at, :updated_at)
|
(:id, :name, :description, :domain_id, :created_at, :updated_at)
|
||||||
@@ -28,7 +28,7 @@ func InsertService(db *dbt.TestDb, value entity.Service) {
|
|||||||
func InsertApplication(db *dbt.TestDb, value entity.Application) {
|
func InsertApplication(db *dbt.TestDb, value entity.Application) {
|
||||||
q := `
|
q := `
|
||||||
INSERT INTO application
|
INSERT INTO application
|
||||||
(id, name, description, service_id, created_at, updated_at)
|
(id, name, description, application_group_id, created_at, updated_at)
|
||||||
VALUES
|
VALUES
|
||||||
(:id, :name, :description, :service_id, :created_at, :updated_at)
|
(:id, :name, :description, :service_id, :created_at, :updated_at)
|
||||||
`
|
`
|
||||||
+27
-17
@@ -1,8 +1,8 @@
|
|||||||
package tests_test
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/txix-open/isp-kit/dbx"
|
"github.com/txix-open/isp-kit/dbx/migration"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -16,10 +16,10 @@ import (
|
|||||||
"isp-system-service/conf"
|
"isp-system-service/conf"
|
||||||
"isp-system-service/domain"
|
"isp-system-service/domain"
|
||||||
"isp-system-service/entity"
|
"isp-system-service/entity"
|
||||||
|
"isp-system-service/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSecureSuite(t *testing.T) {
|
func TestSecureSuite(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
suite.Run(t, &SecureSuite{})
|
suite.Run(t, &SecureSuite{})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,21 +34,31 @@ type SecureSuite struct {
|
|||||||
func (s *SecureSuite) SetupSuite() {
|
func (s *SecureSuite) SetupSuite() {
|
||||||
s.test, s.require = test.New(s.T())
|
s.test, s.require = test.New(s.T())
|
||||||
|
|
||||||
s.testDb = dbt.New(s.test, dbx.WithMigrationRunner("../migrations", s.test.Logger()))
|
s.testDb = dbt.New(s.test)
|
||||||
|
migrations.Initialize.SetParams("../migrations", s.testDb.Schema())
|
||||||
|
|
||||||
|
db, err := s.testDb.DB()
|
||||||
|
s.require.NoError(err)
|
||||||
|
|
||||||
|
logger := s.test.Logger()
|
||||||
|
|
||||||
|
err = migration.NewRunner(migration.DialectPostgreSQL, "../migrations", logger).Run(context.Background(), db.DB.DB)
|
||||||
|
|
||||||
|
s.require.NoError(err)
|
||||||
|
|
||||||
locator := assembly.NewLocator(s.testDb, s.test.Logger())
|
locator := assembly.NewLocator(s.testDb, s.test.Logger())
|
||||||
config := locator.Config(conf.Remote{})
|
handler := locator.Handler(conf.Remote{})
|
||||||
_, s.api = grpct.TestServer(s.test, config.Handler)
|
_, s.api = grpct.TestServer(s.test, handler)
|
||||||
|
|
||||||
createdTime := time.Now().UTC()
|
createdTime := time.Now().UTC()
|
||||||
InsertDomain(s.testDb, entity.Domain{
|
InsertDomain(s.testDb, entity.Domain{
|
||||||
Id: 3, Name: "test_domain", SystemId: 1, CreatedAt: createdTime, UpdatedAt: createdTime,
|
Id: 3, Name: "test_domain", SystemId: 1, CreatedAt: createdTime, UpdatedAt: createdTime,
|
||||||
})
|
})
|
||||||
InsertService(s.testDb, entity.Service{
|
InsertApplicationGroup(s.testDb, entity.ApplicationGroup{
|
||||||
Id: 5, Name: "test_service", DomainId: 3, CreatedAt: createdTime, UpdatedAt: createdTime,
|
Id: 5, Name: "test_application_group", DomainId: 3, CreatedAt: createdTime, UpdatedAt: createdTime,
|
||||||
})
|
})
|
||||||
InsertApplication(s.testDb, entity.Application{
|
InsertApplication(s.testDb, entity.Application{
|
||||||
Id: 7, Name: "test_application", ServiceId: 5, CreatedAt: createdTime, UpdatedAt: createdTime,
|
Id: 7, Name: "test_application", ApplicationGroupId: 5, CreatedAt: createdTime, UpdatedAt: createdTime,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,10 +79,10 @@ func (s *SecureSuite) TestAuthenticate_Success() {
|
|||||||
Authenticated: true,
|
Authenticated: true,
|
||||||
ErrorReason: "",
|
ErrorReason: "",
|
||||||
AuthData: &domain.AuthData{
|
AuthData: &domain.AuthData{
|
||||||
SystemId: 1,
|
SystemId: 1,
|
||||||
DomainId: 3,
|
DomainId: 3,
|
||||||
ServiceId: 5,
|
ApplicationGroupId: 5,
|
||||||
ApplicationId: 7,
|
ApplicationId: 7,
|
||||||
},
|
},
|
||||||
}, result)
|
}, result)
|
||||||
}
|
}
|
||||||
@@ -110,10 +120,10 @@ func (s *SecureSuite) TestAuthenticate_NotExpired() {
|
|||||||
Authenticated: true,
|
Authenticated: true,
|
||||||
ErrorReason: "",
|
ErrorReason: "",
|
||||||
AuthData: &domain.AuthData{
|
AuthData: &domain.AuthData{
|
||||||
SystemId: 1,
|
SystemId: 1,
|
||||||
DomainId: 3,
|
DomainId: 3,
|
||||||
ServiceId: 5,
|
ApplicationGroupId: 5,
|
||||||
ApplicationId: 7,
|
ApplicationId: 7,
|
||||||
},
|
},
|
||||||
}, result)
|
}, result)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package transaction
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"isp-system-service/service/baseline"
|
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/db"
|
"github.com/txix-open/isp-kit/db"
|
||||||
"isp-system-service/repository"
|
"isp-system-service/repository"
|
||||||
@@ -83,25 +82,3 @@ func (m Manager) TokenRevokeTx(ctx context.Context, msgTx func(ctx context.Conte
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type baselineTx struct {
|
|
||||||
repository.Locker
|
|
||||||
repository.Domain
|
|
||||||
repository.Service
|
|
||||||
repository.Application
|
|
||||||
repository.AccessList
|
|
||||||
repository.Token
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Manager) BaselineTx(ctx context.Context, txTx func(ctx context.Context, tx baseline.Transaction) error) error {
|
|
||||||
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),
|
|
||||||
Service: repository.NewService(tx),
|
|
||||||
Application: repository.NewApplication(tx),
|
|
||||||
AccessList: repository.NewAccessList(tx),
|
|
||||||
Token: repository.NewToken(tx),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user