diff --git a/service/access_list.go b/service/access_list.go index 2b80b33..8fd7bfd 100644 --- a/service/access_list.go +++ b/service/access_list.go @@ -9,14 +9,10 @@ import ( "github.com/pkg/errors" ) -type AccessListAccessListRep interface { +type AccessListRepo interface { GetAccessListByAppId(ctx context.Context, appId int) ([]entity.AccessList, error) } -type AccessListApplicationRep interface { // nolint:iface - GetApplicationById(ctx context.Context, id int) (*entity.Application, error) -} - type AccessListSetOneTx interface { UpsertAccessList(ctx context.Context, e entity.AccessList) (int, error) } @@ -35,29 +31,29 @@ type AccessListTxRunner interface { type AccessList struct { tx AccessListTxRunner - accessListRep AccessListAccessListRep - applicationRep AccessListApplicationRep + accessListRepo AccessListRepo + appRepo ApplicationRepo } func NewAccessList( tx AccessListTxRunner, - accessListRep AccessListAccessListRep, - applicationRep AccessListApplicationRep, + accessListRepo AccessListRepo, + appRepo ApplicationRepo, ) AccessList { return AccessList{ tx: tx, - accessListRep: accessListRep, - applicationRep: applicationRep, + accessListRepo: accessListRepo, + appRepo: appRepo, } } func (s AccessList) GetById(ctx context.Context, appId int) ([]domain.MethodInfo, error) { - _, err := s.applicationRep.GetApplicationById(ctx, appId) + _, err := s.appRepo.GetApplicationById(ctx, appId) if err != nil { return nil, errors.WithMessage(err, "get application by id") } - accessList, err := s.accessListRep.GetAccessListByAppId(ctx, appId) + accessList, err := s.accessListRepo.GetAccessListByAppId(ctx, appId) if err != nil { return nil, errors.WithMessagef(err, "get access list by app_id") } @@ -74,7 +70,7 @@ func (s AccessList) GetById(ctx context.Context, appId int) ([]domain.MethodInfo } func (s AccessList) SetOne(ctx context.Context, request domain.AccessListSetOneRequest) (*domain.AccessListSetOneResponse, error) { - _, err := s.applicationRep.GetApplicationById(ctx, request.AppId) + _, err := s.appRepo.GetApplicationById(ctx, request.AppId) if err != nil { return nil, errors.WithMessage(err, "get application by id") } @@ -102,7 +98,7 @@ func (s AccessList) SetOne(ctx context.Context, request domain.AccessListSetOneR } func (s AccessList) SetList(ctx context.Context, req domain.AccessListSetListRequest) ([]domain.MethodInfo, error) { - _, err := s.applicationRep.GetApplicationById(ctx, req.AppId) + _, err := s.appRepo.GetApplicationById(ctx, req.AppId) if err != nil { return nil, errors.WithMessage(err, "get application by id") } @@ -144,7 +140,7 @@ func (s AccessList) SetList(ctx context.Context, req domain.AccessListSetListReq return nil, errors.WithMessage(err, "transaction access list set list") } - accessList, err := s.accessListRep.GetAccessListByAppId(ctx, req.AppId) + accessList, err := s.accessListRepo.GetAccessListByAppId(ctx, req.AppId) if err != nil { return nil, errors.WithMessagef(err, "get access list by app_id") } diff --git a/service/application.go b/service/application.go index 74cd6a3..9a56032 100644 --- a/service/application.go +++ b/service/application.go @@ -9,28 +9,11 @@ import ( "github.com/pkg/errors" ) -type ApplicationApplicationRep interface { - GetApplicationById(ctx context.Context, id int) (*entity.Application, error) - GetApplicationByIdList(ctx context.Context, idList []int) ([]entity.Application, error) - GetApplicationByServiceIdList(ctx context.Context, serviceIdList []int) ([]entity.Application, error) - GetApplicationByNameAndServiceId(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) - UpdateApplication(ctx context.Context, id int, name string, description string) (*entity.Application, error) -} - -type ApplicationTokenRep interface { // nolint:iface - GetTokenByAppIdList(ctx context.Context, appIdList []int) ([]entity.Token, error) -} - type ApplicationServiceRep interface { GetServiceById(ctx context.Context, id int) (*entity.Service, error) GetServiceByDomainId(ctx context.Context, domainIdList []int) ([]entity.Service, error) } -type ApplicationDomainRep interface { - GetDomainBySystemId(ctx context.Context, systemId int) ([]entity.Domain, error) -} - type ApplicationDeleteTx interface { DeleteApplicationByIdList(ctx context.Context, idList []int) (int, error) } @@ -40,31 +23,31 @@ type ApplicationTxRunner interface { } type Application struct { - txRunner ApplicationTxRunner - applicationRep ApplicationApplicationRep - domainRep ApplicationDomainRep - serviceRep ApplicationServiceRep - tokenRep ApplicationTokenRep + txRunner ApplicationTxRunner + appRepo ApplicationRepo + domainRepo DomainRepo + serviceRepo ApplicationServiceRep + tokenRepo TokenRepo } func NewApplication( txRunner ApplicationTxRunner, - applicationRep ApplicationApplicationRep, - domainRep ApplicationDomainRep, - serviceRep ApplicationServiceRep, - tokenRep ApplicationTokenRep, + applicationRepo ApplicationRepo, + domainRepo DomainRepo, + serviceRepo ApplicationServiceRep, + tokenRepo TokenRepo, ) Application { return Application{ - txRunner: txRunner, - applicationRep: applicationRep, - domainRep: domainRep, - serviceRep: serviceRep, - tokenRep: tokenRep, + txRunner: txRunner, + appRepo: applicationRepo, + domainRepo: domainRepo, + serviceRepo: serviceRepo, + tokenRepo: tokenRepo, } } func (s Application) GetById(ctx context.Context, appId int) (*domain.ApplicationWithTokens, error) { - application, err := s.applicationRep.GetApplicationById(ctx, appId) + application, err := s.appRepo.GetApplicationById(ctx, appId) if err != nil { return nil, errors.WithMessage(err, "get application by id") } @@ -78,7 +61,7 @@ func (s Application) GetById(ctx context.Context, appId int) (*domain.Applicatio } func (s Application) GetByIdList(ctx context.Context, idList []int) ([]*domain.ApplicationWithTokens, error) { - res, err := s.applicationRep.GetApplicationByIdList(ctx, idList) + res, err := s.appRepo.GetApplicationByIdList(ctx, idList) if err != nil { return nil, errors.WithMessage(err, "get application by id list") } @@ -87,7 +70,7 @@ func (s Application) GetByIdList(ctx context.Context, idList []int) ([]*domain.A } func (s Application) GetByServiceId(ctx context.Context, id int) ([]*domain.ApplicationWithTokens, error) { - arr, err := s.applicationRep.GetApplicationByServiceIdList(ctx, []int{id}) + arr, err := s.appRepo.GetApplicationByServiceIdList(ctx, []int{id}) if err != nil { return nil, errors.WithMessage(err, "get application by service_id") } @@ -96,7 +79,7 @@ func (s Application) GetByServiceId(ctx context.Context, id int) ([]*domain.Appl } func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithService, error) { - domainEntityList, err := s.domainRep.GetDomainBySystemId(ctx, systemId) + domainEntityList, err := s.domainRepo.GetDomainBySystemId(ctx, systemId) if err != nil { return nil, errors.WithMessage(err, "get domains by system_id") } @@ -123,7 +106,7 @@ func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.Do result[i] = r } - serviceEntityList, err := s.serviceRep.GetServiceByDomainId(ctx, domainIdList) + serviceEntityList, err := s.serviceRepo.GetServiceByDomainId(ctx, domainIdList) if err != nil { return nil, errors.WithMessage(err, "get service by domain_id") } @@ -147,7 +130,7 @@ func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.Do resultServiceByServiceId[serviceEntity.Id] = resultService } - applicationEntityList, err := s.applicationRep.GetApplicationByServiceIdList(ctx, serviceIdList) + applicationEntityList, err := s.appRepo.GetApplicationByServiceIdList(ctx, serviceIdList) if err != nil { return nil, errors.WithMessagef(err, "get application by service_id") } @@ -171,14 +154,14 @@ func (s Application) SystemTree(ctx context.Context, systemId int) ([]*domain.Do } 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.appRepo.GetApplicationByNameAndServiceId(ctx, req.Name, req.ServiceId) switch { case errors.Is(err, domain.ErrApplicationNotFound): case err != nil: return nil, errors.WithMessage(err, "get application by name and service_id") } - _, err = s.serviceRep.GetServiceById(ctx, req.ServiceId) + _, err = s.serviceRepo.GetServiceById(ctx, req.ServiceId) if err != nil { return nil, errors.WithMessage(err, "get service by id") } @@ -188,12 +171,12 @@ func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCre return nil, domain.ErrApplicationDuplicateName } - _, err = s.applicationRep.GetApplicationByNameAndServiceId(ctx, req.Name, req.ServiceId) + _, err = s.appRepo.GetApplicationByNameAndServiceId(ctx, req.Name, req.ServiceId) if err != nil { return nil, errors.WithMessage(err, "get application by name and service_id") } - app, err := s.applicationRep.CreateApplication(ctx, req.Name, req.Description, req.ServiceId, req.Type) + app, err := s.appRepo.CreateApplication(ctx, req.Name, req.Description, req.ServiceId, req.Type) if err != nil { return nil, errors.WithMessage(err, "create application") } @@ -210,12 +193,12 @@ func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCre return nil, domain.ErrApplicationDuplicateName } - _, err = s.applicationRep.GetApplicationById(ctx, req.Id) + _, err = s.appRepo.GetApplicationById(ctx, req.Id) if err != nil { return nil, errors.WithMessage(err, "get application by id") } - app, err := s.applicationRep.UpdateApplication(ctx, req.Id, req.Name, req.Description) + app, err := s.appRepo.UpdateApplication(ctx, req.Id, req.Name, req.Description) if err != nil { return nil, errors.WithMessage(err, "update application") } @@ -264,7 +247,7 @@ func (s Application) EnrichWithTokens(ctx context.Context, apps []entity.Applica result[i] = awt } - tokens, err := s.tokenRep.GetTokenByAppIdList(ctx, appIdList) + tokens, err := s.tokenRepo.GetTokenByAppIdList(ctx, appIdList) if err != nil { return nil, errors.WithMessage(err, "get token by app_id list") } diff --git a/service/domain.go b/service/domain.go index 4914ca4..a5a3305 100644 --- a/service/domain.go +++ b/service/domain.go @@ -8,22 +8,11 @@ import ( "isp-system-service/entity" ) -type DomainDomainRep interface { - GetDomainById(ctx context.Context, id int) (*entity.Domain, error) - GetDomainBySystemId(ctx context.Context, systemId int) ([]entity.Domain, error) - GetDomainByNameAndSystemId(ctx context.Context, name string, systemId int) (*entity.Domain, error) - CreateDomain(ctx context.Context, name string, desc string, systemId int) (*entity.Domain, error) - UpdateDomain(ctx context.Context, id int, name string, description string) (*entity.Domain, error) - DeleteDomain(ctx context.Context, idList []int) (int, error) -} - type Domain struct { - repo DomainDomainRep + repo DomainRepo } -func NewDomain( - repo DomainDomainRep, -) Domain { +func NewDomain(repo DomainRepo) Domain { return Domain{ repo: repo, } diff --git a/service/interfaces.go b/service/interfaces.go new file mode 100644 index 0000000..064ebf3 --- /dev/null +++ b/service/interfaces.go @@ -0,0 +1,38 @@ +package service + +import ( + "context" + "isp-system-service/entity" +) + +type TokenRepo interface { + GetTokenByAppIdList(ctx context.Context, appIdList []int) ([]entity.Token, error) +} + +type DomainRepo interface { + GetDomainById(ctx context.Context, id int) (*entity.Domain, error) + GetDomainBySystemId(ctx context.Context, systemId int) ([]entity.Domain, error) + GetDomainByNameAndSystemId(ctx context.Context, name string, systemId int) (*entity.Domain, error) + CreateDomain(ctx context.Context, name string, desc string, systemId int) (*entity.Domain, error) + UpdateDomain(ctx context.Context, id int, name string, description string) (*entity.Domain, error) + DeleteDomain(ctx context.Context, idList []int) (int, error) +} + +type ApplicationRepo interface { + GetApplicationById(ctx context.Context, id int) (*entity.Application, error) + GetApplicationByIdList(ctx context.Context, idList []int) ([]entity.Application, error) + GetApplicationByServiceIdList(ctx context.Context, serviceIdList []int) ([]entity.Application, error) + GetApplicationByNameAndServiceId(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) + UpdateApplication(ctx context.Context, id int, name string, description string) (*entity.Application, error) +} + +type ServiceRepo 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) +} diff --git a/service/service.go b/service/service.go index b504858..f370978 100644 --- a/service/service.go +++ b/service/service.go @@ -8,37 +8,23 @@ import ( "isp-system-service/entity" ) -type ServiceServiceRep 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 ServiceDomainRep interface { // nolint:iface - GetDomainById(ctx context.Context, id int) (*entity.Domain, error) -} - type Service struct { - domainRep ServiceDomainRep - serviceRep ServiceServiceRep + domainRepo DomainRepo + serviceRepo ServiceRepo } func NewService( - domainRep ServiceDomainRep, - serviceRep ServiceServiceRep, + domainRepo DomainRepo, + serviceRepo ServiceRepo, ) Service { return Service{ - domainRep: domainRep, - serviceRep: serviceRep, + domainRepo: domainRepo, + serviceRepo: serviceRepo, } } func (s Service) GetById(ctx context.Context, id int) (*domain.Service, error) { - serviceEntity, err := s.serviceRep.GetServiceById(ctx, id) + serviceEntity, err := s.serviceRepo.GetServiceById(ctx, id) if err != nil { return nil, errors.WithMessagef(err, "get service by id") } @@ -48,7 +34,7 @@ func (s Service) GetById(ctx context.Context, id int) (*domain.Service, error) { } func (s Service) GetByIdList(ctx context.Context, idList []int) ([]domain.Service, error) { - serviceEntity, err := s.serviceRep.GetServiceByIdList(ctx, idList) + serviceEntity, err := s.serviceRepo.GetServiceByIdList(ctx, idList) if err != nil { return nil, errors.WithMessage(err, "get system by id list") } @@ -61,7 +47,7 @@ func (s Service) GetByIdList(ctx context.Context, idList []int) ([]domain.Servic } func (s Service) GetByDomainId(ctx context.Context, domainId int) ([]domain.Service, error) { - serviceEntity, err := s.serviceRep.GetServiceByDomainId(ctx, []int{domainId}) + serviceEntity, err := s.serviceRepo.GetServiceByDomainId(ctx, []int{domainId}) if err != nil { return nil, errors.WithMessage(err, "get system by id list") } @@ -76,14 +62,14 @@ func (s Service) GetByDomainId(ctx context.Context, domainId int) ([]domain.Serv func (s Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdateRequest) (*domain.Service, error) { req.DomainId = 1 // temporary use only 1 domain, soon domain entity will be removed - existed, err := s.serviceRep.GetServiceByNameAndDomainId(ctx, req.Name, req.DomainId) + existed, err := s.serviceRepo.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) + _, err = s.domainRepo.GetDomainById(ctx, req.DomainId) if err != nil { return nil, errors.WithMessage(err, "get domain by id") } @@ -93,7 +79,7 @@ func (s Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdat return nil, domain.ErrDomainDuplicateName } - serviceEntity, err := s.serviceRep.CreateService(ctx, req.Name, req.Description, req.DomainId) + serviceEntity, err := s.serviceRepo.CreateService(ctx, req.Name, req.Description, req.DomainId) if err != nil { return nil, errors.WithMessage(err, "create service") } @@ -106,12 +92,12 @@ func (s Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdat return nil, domain.ErrDomainDuplicateName } - _, err = s.serviceRep.GetServiceById(ctx, req.Id) + _, err = s.serviceRepo.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) + serviceEntity, err := s.serviceRepo.UpdateService(ctx, req.Id, req.Name, req.Description) if err != nil { return nil, errors.WithMessage(err, "update service") } @@ -121,7 +107,7 @@ func (s Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdat } func (s Service) Delete(ctx context.Context, idList []int) (int, error) { - result, err := s.serviceRep.DeleteService(ctx, idList) + result, err := s.serviceRepo.DeleteService(ctx, idList) if err != nil { return 0, errors.WithMessage(err, "delete service") } diff --git a/service/token.go b/service/token.go index 70674fe..b975794 100644 --- a/service/token.go +++ b/service/token.go @@ -3,35 +3,20 @@ package service import ( "context" - "github.com/pkg/errors" "isp-system-service/domain" "isp-system-service/entity" + + "github.com/pkg/errors" ) type ApplicationTokenCreator interface { CreateApplicationToken() (string, error) } -type TokenAppEnrich interface { +type TokenAppEnricher interface { EnrichWithTokens(ctx context.Context, apps []entity.Application) ([]*domain.ApplicationWithTokens, error) } -type TokenApplicationRep interface { // nolint:iface - GetApplicationById(ctx context.Context, id int) (*entity.Application, error) -} - -type TokenServiceRep interface { - GetServiceById(ctx context.Context, id int) (*entity.Service, error) -} - -type TokenDomainRep interface { // nolint:iface - GetDomainById(ctx context.Context, id int) (*entity.Domain, error) -} - -type TokenTokenRep interface { // nolint:iface - GetTokenByAppIdList(ctx context.Context, appIdList []int) ([]entity.Token, error) -} - type TokenCreateTx interface { SaveToken(ctx context.Context, token string, appId int, expireTime int) (*entity.Token, error) } @@ -46,37 +31,37 @@ type TokenTxRunner interface { } type Token struct { - jwt ApplicationTokenCreator - appEnrich TokenAppEnrich - tx TokenTxRunner - appRep TokenApplicationRep - domainRep TokenDomainRep - serviceRep TokenServiceRep - tokenRep TokenTokenRep + jwt ApplicationTokenCreator + appEnrich TokenAppEnricher + tx TokenTxRunner + appRepo ApplicationRepo + domainRepo DomainRepo + serviceRepo ServiceRepo + tokenRepo TokenRepo } func NewToken( jwtGenerate ApplicationTokenCreator, - appEnrich TokenAppEnrich, + appEnrich TokenAppEnricher, tx TokenTxRunner, - appRep TokenApplicationRep, - domainRep TokenDomainRep, - serviceRep TokenServiceRep, - tokenRep TokenTokenRep, + appRepo ApplicationRepo, + domainRepo DomainRepo, + serviceRepo ServiceRepo, + tokenRepo TokenRepo, ) Token { return Token{ - appEnrich: appEnrich, - jwt: jwtGenerate, - tx: tx, - appRep: appRep, - domainRep: domainRep, - serviceRep: serviceRep, - tokenRep: tokenRep, + appEnrich: appEnrich, + jwt: jwtGenerate, + tx: tx, + appRepo: appRepo, + domainRepo: domainRepo, + serviceRepo: serviceRepo, + tokenRepo: tokenRepo, } } func (s Token) GetByAppId(ctx context.Context, appId int) ([]domain.Token, error) { - tokenEntity, err := s.tokenRep.GetTokenByAppIdList(ctx, []int{appId}) + tokenEntity, err := s.tokenRepo.GetTokenByAppIdList(ctx, []int{appId}) if err != nil { return nil, errors.WithMessage(err, "get token by app_id list") } @@ -90,17 +75,17 @@ func (s Token) GetByAppId(ctx context.Context, appId int) ([]domain.Token, error } func (s Token) Create(ctx context.Context, req domain.TokenCreateRequest) (*domain.ApplicationWithTokens, error) { - applicationEntity, err := s.appRep.GetApplicationById(ctx, req.AppId) + applicationEntity, err := s.appRepo.GetApplicationById(ctx, req.AppId) if err != nil { return nil, errors.WithMessagef(err, "get application by id") } - serviceEntity, err := s.serviceRep.GetServiceById(ctx, applicationEntity.ServiceId) + serviceEntity, err := s.serviceRepo.GetServiceById(ctx, applicationEntity.ServiceId) if err != nil { return nil, errors.WithMessagef(err, "get service by id") } - _, err = s.domainRep.GetDomainById(ctx, serviceEntity.DomainId) + _, err = s.domainRepo.GetDomainById(ctx, serviceEntity.DomainId) if err != nil { return nil, errors.WithMessagef(err, "get domain by id") } @@ -131,7 +116,7 @@ func (s Token) Create(ctx context.Context, req domain.TokenCreateRequest) (*doma } func (s Token) Revoke(ctx context.Context, req domain.TokenRevokeRequest) (*domain.ApplicationWithTokens, error) { - app, err := s.appRep.GetApplicationById(ctx, req.AppId) + app, err := s.appRepo.GetApplicationById(ctx, req.AppId) if err != nil { return nil, errors.WithMessagef(err, "get application by id") } @@ -150,7 +135,7 @@ func (s Token) Revoke(ctx context.Context, req domain.TokenRevokeRequest) (*doma } func (s Token) RevokeByAppId(ctx context.Context, appId int) (*domain.DeleteResponse, error) { - tokens, err := s.tokenRep.GetTokenByAppIdList(ctx, []int{appId}) + tokens, err := s.tokenRepo.GetTokenByAppIdList(ctx, []int{appId}) if err != nil { return nil, errors.WithMessage(err, "get token by app_id list") } diff --git a/service/token_source.go b/service/token_source.go index 03fe570..938b52e 100644 --- a/service/token_source.go +++ b/service/token_source.go @@ -7,8 +7,7 @@ import ( "github.com/pkg/errors" ) -type TokenSource struct { -} +type TokenSource struct{} func NewTokenSource() TokenSource { return TokenSource{} diff --git a/transaction/manager.go b/transaction/manager.go index 628608f..0f6cd0f 100644 --- a/transaction/manager.go +++ b/transaction/manager.go @@ -37,7 +37,7 @@ type accessListSetListTx struct { repository.AccessList } -func (m Manager) AccessListSetListTx(ctx context.Context, msgTx func(ctx context.Context, tx service.IAccessListSetListTx) error) error { +func (m Manager) AccessListSetListTx(ctx context.Context, msgTx func(ctx context.Context, tx service.AccessListSetListTx) error) error { return m.db.RunInTransaction(ctx, func(ctx context.Context, tx *db.Tx) error { accessListRep := repository.NewAccessList(tx) return msgTx(ctx, accessListSetListTx{ @@ -63,7 +63,7 @@ type tokenCreateTx struct { repository.Token } -func (m Manager) TokenCreateTx(ctx context.Context, msgTx func(ctx context.Context, tx service.ITokenCreateTx) error) error { +func (m Manager) TokenCreateTx(ctx context.Context, msgTx func(ctx context.Context, tx service.TokenCreateTx) error) error { return m.db.RunInTransaction(ctx, func(ctx context.Context, tx *db.Tx) error { tokenRep := repository.NewToken(tx) return msgTx(ctx, tokenCreateTx{ @@ -76,7 +76,7 @@ type tokenRevokeTx struct { repository.Token } -func (m Manager) TokenRevokeTx(ctx context.Context, msgTx func(ctx context.Context, tx service.ITokenRevokeTx) error) error { +func (m Manager) TokenRevokeTx(ctx context.Context, msgTx func(ctx context.Context, tx service.TokenRevokeTx) error) error { return m.db.RunInTransaction(ctx, func(ctx context.Context, tx *db.Tx) error { tokenRep := repository.NewToken(tx) return msgTx(ctx, tokenRevokeTx{