From 97f17f26d6e73017f2f2508b77a8f2a67deb9948 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 7 Jul 2023 10:38:11 +0000 Subject: [PATCH 1/4] feat: details to init kafka topics log --- pkg/kafka/kafka.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kafka/kafka.go b/pkg/kafka/kafka.go index 94e9555..1b4aac2 100644 --- a/pkg/kafka/kafka.go +++ b/pkg/kafka/kafka.go @@ -66,7 +66,7 @@ func Initialize(ctx context.Context, brokers, topics []string) error { for _, topic := range topics { isExist, err := kafka.TopicExists(ctx, topic) if err != nil { - lastInitializeErr = fmt.Errorf("failed to check is topic <%s> exist on of : %w", topic, err) + lastInitializeErr = fmt.Errorf("failed to check is topic <%s> exist on brokers <%+q>: %w", topic, brokers, err) continue } @@ -75,7 +75,7 @@ func Initialize(ctx context.Context, brokers, topics []string) error { } if err := kafka.CreateTopic(ctx, topic); err != nil { - lastInitializeErr = fmt.Errorf("failed to create topic <%s> on of : %w", topic, err) + lastInitializeErr = fmt.Errorf("failed to create topic <%s> on brokers <%+q>: %w", topic, brokers, err) } } From 7b219ea7351408cc368596264edf0f59e9e0a427 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 25 Jul 2023 16:24:42 +0000 Subject: [PATCH 2/4] Update 2 files --- internal/service/account/account.go | 4 +++- internal/service/wallet/wallet.go | 13 ++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/internal/service/account/account.go b/internal/service/account/account.go index fce6250..5b287b3 100644 --- a/internal/service/account/account.go +++ b/internal/service/account/account.go @@ -22,6 +22,8 @@ type accountRepository interface { UpdateName(ctx context.Context, userID string, name *models.Name) (*models.Account, errors.Error) } +const defaultCurrency = "RUB" + type authClient interface { GetUser(ctx context.Context, userID string) (*models.User, errors.Error) } @@ -175,7 +177,7 @@ func (receiver *Service) CreateAccountByUserID(ctx context.Context, userID strin return nil, err } - createdAccount, err := receiver.repository.Insert(ctx, &models.Account{UserID: user.ID}) + createdAccount, err := receiver.repository.Insert(ctx, &models.Account{UserID: user.ID, Wallet: models.Wallet{Currency: defaultCurrency}}) if err != nil { receiver.logger.Error("failed to create account on of ", zap.Error(err), diff --git a/internal/service/wallet/wallet.go b/internal/service/wallet/wallet.go index 41444e6..9b6b8c9 100644 --- a/internal/service/wallet/wallet.go +++ b/internal/service/wallet/wallet.go @@ -2,7 +2,6 @@ package wallet import ( "context" - "fmt" "log" "go.uber.org/zap" @@ -11,6 +10,8 @@ import ( "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" ) +const defaultCurrency = "RUB" + type accountRepository interface { ChangeWallet(ctx context.Context, userID string, wallet *models.Wallet) (*models.Account, errors.Error) FindByUserID(ctx context.Context, id string) (*models.Account, errors.Error) @@ -65,10 +66,7 @@ func New(deps Deps) *Service { func (receiver *Service) ReplenishAccountWallet(ctx context.Context, request *models.ReplenishAccountWallet) (*models.Account, errors.Error) { if validate.IsStringEmpty(request.Account.Wallet.Currency) { - return nil, errors.New( - fmt.Errorf("currency of account <%s> is empty of ", request.Account.UserID), - errors.ErrInternalError, - ) + request.Account.Wallet.Currency = defaultCurrency } cash := request.Cash @@ -161,10 +159,7 @@ func (receiver *Service) ReplenishAccountWallet(ctx context.Context, request *mo func (receiver *Service) WithdrawAccountWalletMoney(ctx context.Context, request *models.WithdrawAccountWallet) (*models.Account, errors.Error) { if validate.IsStringEmpty(request.Account.Wallet.Currency) { - return nil, errors.New( - fmt.Errorf("currency of account <%s> is empty of ", request.Account.UserID), - errors.ErrInternalError, - ) + request.Account.Wallet.Currency = defaultCurrency } cash, err := receiver.currencyClient.Translate(ctx, &models.TranslateCurrency{ From 2039de809e78ced26c095e0d705fc01cf918d0a5 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 2 Aug 2023 14:28:31 +0000 Subject: [PATCH 3/4] feat(broker/tariff): add amount & type --- .golangci.yaml | 1 - internal/interface/swagger/api.gen.go | 30 ++--- internal/interface/swagger/models.gen.go | 2 +- internal/models/tariff.go | 47 +++++-- internal/proto/broker/models.pb.go | 121 ++++++++++++++---- internal/proto/customer/service.pb.go | 2 +- internal/proto/customer/service_grpc.pb.go | 12 +- internal/proto/discount/audit.model.pb.go | 2 +- internal/proto/discount/discount.model.pb.go | 2 +- internal/proto/discount/service.pb.go | 2 +- internal/proto/discount/service_grpc.pb.go | 52 +++++--- .../api/annotations/annotations.pb.go | 2 +- .../googleapis/api/annotations/http.pb.go | 2 +- internal/proto/payment_callback/service.pb.go | 2 +- .../proto/payment_callback/service_grpc.pb.go | 17 ++- internal/proto/treasurer/payment.model.pb.go | 2 +- internal/proto/treasurer/service.pb.go | 2 +- internal/proto/treasurer/service_grpc.pb.go | 62 +++++---- internal/utils/transfer/privilege.go | 6 +- internal/utils/transfer/privilege_test.go | 20 +-- internal/utils/transfer/tariff_test.go | 8 +- proto/broker/models.proto | 9 +- 22 files changed, 281 insertions(+), 124 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 13cf4aa..cc89ece 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -16,7 +16,6 @@ linters: - bidichk - bodyclose - containedctx - - depguard - dogsled - dupword - durationcheck diff --git a/internal/interface/swagger/api.gen.go b/internal/interface/swagger/api.gen.go index 8f439c6..49bcd48 100644 --- a/internal/interface/swagger/api.gen.go +++ b/internal/interface/swagger/api.gen.go @@ -1,6 +1,6 @@ // Package swagger provides primitives to interact with the openapi HTTP API. // -// Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT. +// Code generated by github.com/deepmap/oapi-codegen version v1.13.0 DO NOT EDIT. package swagger import ( @@ -79,7 +79,7 @@ type ServerInterfaceWrapper struct { func (w *ServerInterfaceWrapper) DeleteAccount(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.DeleteAccount(ctx) @@ -90,7 +90,7 @@ func (w *ServerInterfaceWrapper) DeleteAccount(ctx echo.Context) error { func (w *ServerInterfaceWrapper) GetAccount(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.GetAccount(ctx) @@ -101,7 +101,7 @@ func (w *ServerInterfaceWrapper) GetAccount(ctx echo.Context) error { func (w *ServerInterfaceWrapper) ChangeAccount(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.ChangeAccount(ctx) @@ -112,7 +112,7 @@ func (w *ServerInterfaceWrapper) ChangeAccount(ctx echo.Context) error { func (w *ServerInterfaceWrapper) AddAccount(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.AddAccount(ctx) @@ -130,7 +130,7 @@ func (w *ServerInterfaceWrapper) DeleteDirectAccount(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err)) } - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.DeleteDirectAccount(ctx, userId) @@ -148,7 +148,7 @@ func (w *ServerInterfaceWrapper) GetDirectAccount(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err)) } - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.GetDirectAccount(ctx, userId) @@ -166,7 +166,7 @@ func (w *ServerInterfaceWrapper) SetAccountVerificationStatus(ctx echo.Context) return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err)) } - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.SetAccountVerificationStatus(ctx, userId) @@ -202,7 +202,7 @@ func (w *ServerInterfaceWrapper) PaginationAccounts(ctx echo.Context) error { func (w *ServerInterfaceWrapper) RemoveFromCart(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Parameter object where we will unmarshal all parameters from the context var params RemoveFromCartParams @@ -222,7 +222,7 @@ func (w *ServerInterfaceWrapper) RemoveFromCart(ctx echo.Context) error { func (w *ServerInterfaceWrapper) Add2cart(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Parameter object where we will unmarshal all parameters from the context var params Add2cartParams @@ -242,7 +242,7 @@ func (w *ServerInterfaceWrapper) Add2cart(ctx echo.Context) error { func (w *ServerInterfaceWrapper) PayCart(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.PayCart(ctx) @@ -262,7 +262,7 @@ func (w *ServerInterfaceWrapper) GetCurrencies(ctx echo.Context) error { func (w *ServerInterfaceWrapper) UpdateCurrencies(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.UpdateCurrencies(ctx) @@ -273,7 +273,7 @@ func (w *ServerInterfaceWrapper) UpdateCurrencies(ctx echo.Context) error { func (w *ServerInterfaceWrapper) GetHistory(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Parameter object where we will unmarshal all parameters from the context var params GetHistoryParams @@ -300,7 +300,7 @@ func (w *ServerInterfaceWrapper) GetHistory(ctx echo.Context) error { func (w *ServerInterfaceWrapper) ChangeCurrency(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.ChangeCurrency(ctx) @@ -311,7 +311,7 @@ func (w *ServerInterfaceWrapper) ChangeCurrency(ctx echo.Context) error { func (w *ServerInterfaceWrapper) RequestMoney(ctx echo.Context) error { var err error - ctx.Set(BearerScopes, []string{""}) + ctx.Set(BearerScopes, []string{}) // Invoke the callback with all the unmarshalled arguments err = w.Handler.RequestMoney(ctx) diff --git a/internal/interface/swagger/models.gen.go b/internal/interface/swagger/models.gen.go index 1f96932..acaaaaa 100644 --- a/internal/interface/swagger/models.gen.go +++ b/internal/interface/swagger/models.gen.go @@ -1,6 +1,6 @@ // Package swagger provides primitives to interact with the openapi HTTP API. // -// Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT. +// Code generated by github.com/deepmap/oapi-codegen version v1.13.0 DO NOT EDIT. package swagger import ( diff --git a/internal/models/tariff.go b/internal/models/tariff.go index 79b2a22..e664a6f 100644 --- a/internal/models/tariff.go +++ b/internal/models/tariff.go @@ -1,11 +1,15 @@ package models -import "time" +import ( + "time" + + "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker" +) type Tariff struct { ID string `json:"_id"` Name string `json:"name"` - Price int64 `json:"price"` + Price int64 `json:"price,omitempty"` IsCustom bool `json:"isCustom"` Privileges []Privilege `json:"privileges"` Deleted bool `json:"isDeleted"` @@ -15,12 +19,35 @@ type Tariff struct { } type Privilege struct { - ID string `json:"_id"` - Name string `json:"name"` - PrivilegeID string `json:"privilegeId"` - ServiceKey string `json:"serviceKey"` - Description string `json:"description"` - Type string `json:"type"` - Value string `json:"value"` - Price int64 `json:"price"` + ID string `json:"_id"` + Name string `json:"name"` + PrivilegeID string `json:"privilegeId"` + ServiceKey string `json:"serviceKey"` + Description string `json:"description"` + Amount uint64 `json:"amount"` + Type PrivilegeType `json:"type"` + Value string `json:"value"` + Price uint64 `json:"price"` } + +type PrivilegeType string + +const ( + PrivilegeTypeCount = "count" + PrivilegeTypeDay = "day" + PrivilegeTypeFull = "full" +) + +var ( + PrivilegeTypeMap = map[broker.PrivilegeType]PrivilegeType{ + broker.PrivilegeType_Full: PrivilegeTypeFull, + broker.PrivilegeType_Day: PrivilegeTypeDay, + broker.PrivilegeType_Count: PrivilegeTypeCount, + } + + PrivilegeBrokerTypeMap = map[PrivilegeType]broker.PrivilegeType{ + PrivilegeTypeFull: broker.PrivilegeType_Full, + PrivilegeTypeDay: broker.PrivilegeType_Day, + PrivilegeTypeCount: broker.PrivilegeType_Count, + } +) diff --git a/internal/proto/broker/models.pb.go b/internal/proto/broker/models.pb.go index 55e57ed..9060da6 100644 --- a/internal/proto/broker/models.pb.go +++ b/internal/proto/broker/models.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: broker/models.proto @@ -20,15 +20,65 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type PrivilegeType int32 + +const ( + PrivilegeType_Full PrivilegeType = 0 + PrivilegeType_Day PrivilegeType = 1 + PrivilegeType_Count PrivilegeType = 2 +) + +// Enum value maps for PrivilegeType. +var ( + PrivilegeType_name = map[int32]string{ + 0: "Full", + 1: "Day", + 2: "Count", + } + PrivilegeType_value = map[string]int32{ + "Full": 0, + "Day": 1, + "Count": 2, + } +) + +func (x PrivilegeType) Enum() *PrivilegeType { + p := new(PrivilegeType) + *p = x + return p +} + +func (x PrivilegeType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (PrivilegeType) Descriptor() protoreflect.EnumDescriptor { + return file_broker_models_proto_enumTypes[0].Descriptor() +} + +func (PrivilegeType) Type() protoreflect.EnumType { + return &file_broker_models_proto_enumTypes[0] +} + +func (x PrivilegeType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use PrivilegeType.Descriptor instead. +func (PrivilegeType) EnumDescriptor() ([]byte, []int) { + return file_broker_models_proto_rawDescGZIP(), []int{0} +} + type PrivilegeMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - PrivilegeID string `protobuf:"bytes,1,opt,name=PrivilegeID,proto3" json:"PrivilegeID,omitempty"` - ServiceKey string `protobuf:"bytes,2,opt,name=ServiceKey,proto3" json:"ServiceKey,omitempty"` - Type string `protobuf:"bytes,3,opt,name=Type,proto3" json:"Type,omitempty"` - Value string `protobuf:"bytes,4,opt,name=Value,proto3" json:"Value,omitempty"` + PrivilegeID string `protobuf:"bytes,1,opt,name=PrivilegeID,proto3" json:"PrivilegeID,omitempty"` + ServiceKey string `protobuf:"bytes,2,opt,name=ServiceKey,proto3" json:"ServiceKey,omitempty"` + Type PrivilegeType `protobuf:"varint,3,opt,name=Type,proto3,enum=broker.PrivilegeType" json:"Type,omitempty"` + Value string `protobuf:"bytes,4,opt,name=Value,proto3" json:"Value,omitempty"` + Amount uint64 `protobuf:"varint,5,opt,name=Amount,proto3" json:"Amount,omitempty"` } func (x *PrivilegeMessage) Reset() { @@ -77,11 +127,11 @@ func (x *PrivilegeMessage) GetServiceKey() string { return "" } -func (x *PrivilegeMessage) GetType() string { +func (x *PrivilegeMessage) GetType() PrivilegeType { if x != nil { return x.Type } - return "" + return PrivilegeType_Full } func (x *PrivilegeMessage) GetValue() string { @@ -91,6 +141,13 @@ func (x *PrivilegeMessage) GetValue() string { return "" } +func (x *PrivilegeMessage) GetAmount() uint64 { + if x != nil { + return x.Amount + } + return 0 +} + type TariffMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -150,23 +207,29 @@ var File_broker_models_proto protoreflect.FileDescriptor var file_broker_models_proto_rawDesc = []byte{ 0x0a, 0x13, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x22, 0x7e, 0x0a, - 0x10, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x49, 0x44, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, - 0x65, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4b, 0x65, - 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x61, 0x0a, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x22, 0xad, 0x01, + 0x0a, 0x10, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x49, + 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, + 0x67, 0x65, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4b, + 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x4b, 0x65, 0x79, 0x12, 0x29, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x69, 0x76, + 0x69, 0x6c, 0x65, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x61, 0x0a, 0x0d, 0x54, 0x61, 0x72, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0a, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0a, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, - 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x2a, 0x2d, 0x0a, 0x0d, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x44, + 0x61, 0x79, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0x02, 0x42, + 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -181,18 +244,21 @@ func file_broker_models_proto_rawDescGZIP() []byte { return file_broker_models_proto_rawDescData } +var file_broker_models_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_broker_models_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_broker_models_proto_goTypes = []interface{}{ - (*PrivilegeMessage)(nil), // 0: broker.PrivilegeMessage - (*TariffMessage)(nil), // 1: broker.TariffMessage + (PrivilegeType)(0), // 0: broker.PrivilegeType + (*PrivilegeMessage)(nil), // 1: broker.PrivilegeMessage + (*TariffMessage)(nil), // 2: broker.TariffMessage } var file_broker_models_proto_depIdxs = []int32{ - 0, // 0: broker.TariffMessage.Privileges:type_name -> broker.PrivilegeMessage - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 0, // 0: broker.PrivilegeMessage.Type:type_name -> broker.PrivilegeType + 1, // 1: broker.TariffMessage.Privileges:type_name -> broker.PrivilegeMessage + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_broker_models_proto_init() } @@ -231,13 +297,14 @@ func file_broker_models_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_broker_models_proto_rawDesc, - NumEnums: 0, + NumEnums: 1, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_broker_models_proto_goTypes, DependencyIndexes: file_broker_models_proto_depIdxs, + EnumInfos: file_broker_models_proto_enumTypes, MessageInfos: file_broker_models_proto_msgTypes, }.Build() File_broker_models_proto = out.File diff --git a/internal/proto/customer/service.pb.go b/internal/proto/customer/service.pb.go index 09f8f8a..510635d 100644 --- a/internal/proto/customer/service.pb.go +++ b/internal/proto/customer/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: customer/service.proto diff --git a/internal/proto/customer/service_grpc.pb.go b/internal/proto/customer/service_grpc.pb.go index 53e1376..74454d3 100644 --- a/internal/proto/customer/service_grpc.pb.go +++ b/internal/proto/customer/service_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: customer/service.proto package customer @@ -15,6 +19,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + CustomerService_InsertHistory_FullMethodName = "/customer.CustomerService/InsertHistory" +) + // CustomerServiceClient is the client API for CustomerService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -32,7 +40,7 @@ func NewCustomerServiceClient(cc grpc.ClientConnInterface) CustomerServiceClient func (c *customerServiceClient) InsertHistory(ctx context.Context, in *History, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/customer.CustomerService/InsertHistory", in, out, opts...) + err := c.cc.Invoke(ctx, CustomerService_InsertHistory_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -75,7 +83,7 @@ func _CustomerService_InsertHistory_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/customer.CustomerService/InsertHistory", + FullMethod: CustomerService_InsertHistory_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(CustomerServiceServer).InsertHistory(ctx, req.(*History)) diff --git a/internal/proto/discount/audit.model.pb.go b/internal/proto/discount/audit.model.pb.go index 32dafb0..7c2347e 100644 --- a/internal/proto/discount/audit.model.pb.go +++ b/internal/proto/discount/audit.model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: discount/audit.model.proto diff --git a/internal/proto/discount/discount.model.pb.go b/internal/proto/discount/discount.model.pb.go index a852324..c0fce2b 100644 --- a/internal/proto/discount/discount.model.pb.go +++ b/internal/proto/discount/discount.model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: discount/discount.model.proto diff --git a/internal/proto/discount/service.pb.go b/internal/proto/discount/service.pb.go index 17cd2ef..84ea7d9 100644 --- a/internal/proto/discount/service.pb.go +++ b/internal/proto/discount/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: discount/service.proto diff --git a/internal/proto/discount/service_grpc.pb.go b/internal/proto/discount/service_grpc.pb.go index 0341573..e9161fb 100644 --- a/internal/proto/discount/service_grpc.pb.go +++ b/internal/proto/discount/service_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: discount/service.proto package discount @@ -15,6 +19,18 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + DiscountService_GetAllDiscounts_FullMethodName = "/discount.DiscountService/GetAllDiscounts" + DiscountService_GetUserDiscounts_FullMethodName = "/discount.DiscountService/GetUserDiscounts" + DiscountService_DetermineDiscounts_FullMethodName = "/discount.DiscountService/DetermineDiscounts" + DiscountService_ApplyDiscounts_FullMethodName = "/discount.DiscountService/ApplyDiscounts" + DiscountService_GetDiscountByID_FullMethodName = "/discount.DiscountService/GetDiscountByID" + DiscountService_CreateDiscount_FullMethodName = "/discount.DiscountService/CreateDiscount" + DiscountService_ReplaceDiscount_FullMethodName = "/discount.DiscountService/ReplaceDiscount" + DiscountService_UpdateDiscount_FullMethodName = "/discount.DiscountService/UpdateDiscount" + DiscountService_DeleteDiscount_FullMethodName = "/discount.DiscountService/DeleteDiscount" +) + // DiscountServiceClient is the client API for DiscountService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -40,7 +56,7 @@ func NewDiscountServiceClient(cc grpc.ClientConnInterface) DiscountServiceClient func (c *discountServiceClient) GetAllDiscounts(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Discounts, error) { out := new(Discounts) - err := c.cc.Invoke(ctx, "/discount.DiscountService/GetAllDiscounts", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_GetAllDiscounts_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -49,7 +65,7 @@ func (c *discountServiceClient) GetAllDiscounts(ctx context.Context, in *emptypb func (c *discountServiceClient) GetUserDiscounts(ctx context.Context, in *GetDiscountByIDRequest, opts ...grpc.CallOption) (*Discounts, error) { out := new(Discounts) - err := c.cc.Invoke(ctx, "/discount.DiscountService/GetUserDiscounts", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_GetUserDiscounts_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -58,7 +74,7 @@ func (c *discountServiceClient) GetUserDiscounts(ctx context.Context, in *GetDis func (c *discountServiceClient) DetermineDiscounts(ctx context.Context, in *ApplyDiscountRequest, opts ...grpc.CallOption) (*Discounts, error) { out := new(Discounts) - err := c.cc.Invoke(ctx, "/discount.DiscountService/DetermineDiscounts", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_DetermineDiscounts_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -67,7 +83,7 @@ func (c *discountServiceClient) DetermineDiscounts(ctx context.Context, in *Appl func (c *discountServiceClient) ApplyDiscounts(ctx context.Context, in *ApplyDiscountRequest, opts ...grpc.CallOption) (*ApplyDiscountResponse, error) { out := new(ApplyDiscountResponse) - err := c.cc.Invoke(ctx, "/discount.DiscountService/ApplyDiscounts", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_ApplyDiscounts_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -76,7 +92,7 @@ func (c *discountServiceClient) ApplyDiscounts(ctx context.Context, in *ApplyDis func (c *discountServiceClient) GetDiscountByID(ctx context.Context, in *GetDiscountByIDRequest, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/GetDiscountByID", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_GetDiscountByID_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -85,7 +101,7 @@ func (c *discountServiceClient) GetDiscountByID(ctx context.Context, in *GetDisc func (c *discountServiceClient) CreateDiscount(ctx context.Context, in *CreateDiscountRequest, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/CreateDiscount", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_CreateDiscount_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -94,7 +110,7 @@ func (c *discountServiceClient) CreateDiscount(ctx context.Context, in *CreateDi func (c *discountServiceClient) ReplaceDiscount(ctx context.Context, in *DiscountOptional, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/ReplaceDiscount", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_ReplaceDiscount_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -103,7 +119,7 @@ func (c *discountServiceClient) ReplaceDiscount(ctx context.Context, in *Discoun func (c *discountServiceClient) UpdateDiscount(ctx context.Context, in *DiscountOptional, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/UpdateDiscount", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_UpdateDiscount_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -112,7 +128,7 @@ func (c *discountServiceClient) UpdateDiscount(ctx context.Context, in *Discount func (c *discountServiceClient) DeleteDiscount(ctx context.Context, in *GetDiscountByIDRequest, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/DeleteDiscount", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_DeleteDiscount_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -187,7 +203,7 @@ func _DiscountService_GetAllDiscounts_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/GetAllDiscounts", + FullMethod: DiscountService_GetAllDiscounts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).GetAllDiscounts(ctx, req.(*emptypb.Empty)) @@ -205,7 +221,7 @@ func _DiscountService_GetUserDiscounts_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/GetUserDiscounts", + FullMethod: DiscountService_GetUserDiscounts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).GetUserDiscounts(ctx, req.(*GetDiscountByIDRequest)) @@ -223,7 +239,7 @@ func _DiscountService_DetermineDiscounts_Handler(srv interface{}, ctx context.Co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/DetermineDiscounts", + FullMethod: DiscountService_DetermineDiscounts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).DetermineDiscounts(ctx, req.(*ApplyDiscountRequest)) @@ -241,7 +257,7 @@ func _DiscountService_ApplyDiscounts_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/ApplyDiscounts", + FullMethod: DiscountService_ApplyDiscounts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).ApplyDiscounts(ctx, req.(*ApplyDiscountRequest)) @@ -259,7 +275,7 @@ func _DiscountService_GetDiscountByID_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/GetDiscountByID", + FullMethod: DiscountService_GetDiscountByID_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).GetDiscountByID(ctx, req.(*GetDiscountByIDRequest)) @@ -277,7 +293,7 @@ func _DiscountService_CreateDiscount_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/CreateDiscount", + FullMethod: DiscountService_CreateDiscount_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).CreateDiscount(ctx, req.(*CreateDiscountRequest)) @@ -295,7 +311,7 @@ func _DiscountService_ReplaceDiscount_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/ReplaceDiscount", + FullMethod: DiscountService_ReplaceDiscount_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).ReplaceDiscount(ctx, req.(*DiscountOptional)) @@ -313,7 +329,7 @@ func _DiscountService_UpdateDiscount_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/UpdateDiscount", + FullMethod: DiscountService_UpdateDiscount_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).UpdateDiscount(ctx, req.(*DiscountOptional)) @@ -331,7 +347,7 @@ func _DiscountService_DeleteDiscount_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/DeleteDiscount", + FullMethod: DiscountService_DeleteDiscount_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).DeleteDiscount(ctx, req.(*GetDiscountByIDRequest)) diff --git a/internal/proto/google.golang.org/genproto/googleapis/api/annotations/annotations.pb.go b/internal/proto/google.golang.org/genproto/googleapis/api/annotations/annotations.pb.go index 1946360..8b79d64 100644 --- a/internal/proto/google.golang.org/genproto/googleapis/api/annotations/annotations.pb.go +++ b/internal/proto/google.golang.org/genproto/googleapis/api/annotations/annotations.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: google/api/annotations.proto diff --git a/internal/proto/google.golang.org/genproto/googleapis/api/annotations/http.pb.go b/internal/proto/google.golang.org/genproto/googleapis/api/annotations/http.pb.go index e1c9a0c..dcc8cce 100644 --- a/internal/proto/google.golang.org/genproto/googleapis/api/annotations/http.pb.go +++ b/internal/proto/google.golang.org/genproto/googleapis/api/annotations/http.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: google/api/http.proto diff --git a/internal/proto/payment_callback/service.pb.go b/internal/proto/payment_callback/service.pb.go index f477716..735e6ef 100644 --- a/internal/proto/payment_callback/service.pb.go +++ b/internal/proto/payment_callback/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: callback/service.proto diff --git a/internal/proto/payment_callback/service_grpc.pb.go b/internal/proto/payment_callback/service_grpc.pb.go index e47ffb6..c4291fd 100644 --- a/internal/proto/payment_callback/service_grpc.pb.go +++ b/internal/proto/payment_callback/service_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: callback/service.proto package payment_callback @@ -15,6 +19,11 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + PaymentCallbackService_OnSuccess_FullMethodName = "/payment_callback.PaymentCallbackService/OnSuccess" + PaymentCallbackService_OnFailure_FullMethodName = "/payment_callback.PaymentCallbackService/OnFailure" +) + // PaymentCallbackServiceClient is the client API for PaymentCallbackService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -33,7 +42,7 @@ func NewPaymentCallbackServiceClient(cc grpc.ClientConnInterface) PaymentCallbac func (c *paymentCallbackServiceClient) OnSuccess(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/payment_callback.PaymentCallbackService/OnSuccess", in, out, opts...) + err := c.cc.Invoke(ctx, PaymentCallbackService_OnSuccess_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -42,7 +51,7 @@ func (c *paymentCallbackServiceClient) OnSuccess(ctx context.Context, in *Event, func (c *paymentCallbackServiceClient) OnFailure(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/payment_callback.PaymentCallbackService/OnFailure", in, out, opts...) + err := c.cc.Invoke(ctx, PaymentCallbackService_OnFailure_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -89,7 +98,7 @@ func _PaymentCallbackService_OnSuccess_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/payment_callback.PaymentCallbackService/OnSuccess", + FullMethod: PaymentCallbackService_OnSuccess_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(PaymentCallbackServiceServer).OnSuccess(ctx, req.(*Event)) @@ -107,7 +116,7 @@ func _PaymentCallbackService_OnFailure_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/payment_callback.PaymentCallbackService/OnFailure", + FullMethod: PaymentCallbackService_OnFailure_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(PaymentCallbackServiceServer).OnFailure(ctx, req.(*Event)) diff --git a/internal/proto/treasurer/payment.model.pb.go b/internal/proto/treasurer/payment.model.pb.go index 04fce31..99c77ac 100644 --- a/internal/proto/treasurer/payment.model.pb.go +++ b/internal/proto/treasurer/payment.model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: treasurer/payment.model.proto diff --git a/internal/proto/treasurer/service.pb.go b/internal/proto/treasurer/service.pb.go index 395df13..b4400b6 100644 --- a/internal/proto/treasurer/service.pb.go +++ b/internal/proto/treasurer/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: treasurer/service.proto diff --git a/internal/proto/treasurer/service_grpc.pb.go b/internal/proto/treasurer/service_grpc.pb.go index d10d4c8..3688ec2 100644 --- a/internal/proto/treasurer/service_grpc.pb.go +++ b/internal/proto/treasurer/service_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: treasurer/service.proto package treasurer @@ -14,6 +18,20 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + TreasurerService_GetPaymentLinkBankCard_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkBankCard" + TreasurerService_GetPaymentLinkYooMoney_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkYooMoney" + TreasurerService_GetPaymentLinkQIWI_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkQIWI" + TreasurerService_GetPaymentLinkSberPay_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSberPay" + TreasurerService_GetPaymentLinkAlfaClick_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkAlfaClick" + TreasurerService_GetPaymentLinkTinkoff_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkTinkoff" + TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B" + TreasurerService_GetPaymentLinkSBP_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSBP" + TreasurerService_GetPaymentLinkMobile_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkMobile" + TreasurerService_GetPaymentLinkCash_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkCash" + TreasurerService_GetPaymentLinkInstallments_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkInstallments" +) + // TreasurerServiceClient is the client API for TreasurerService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -41,7 +59,7 @@ func NewTreasurerServiceClient(cc grpc.ClientConnInterface) TreasurerServiceClie func (c *treasurerServiceClient) GetPaymentLinkBankCard(ctx context.Context, in *GetBankCardPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkBankCard", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkBankCard_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -50,7 +68,7 @@ func (c *treasurerServiceClient) GetPaymentLinkBankCard(ctx context.Context, in func (c *treasurerServiceClient) GetPaymentLinkYooMoney(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkYooMoney", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkYooMoney_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -59,7 +77,7 @@ func (c *treasurerServiceClient) GetPaymentLinkYooMoney(ctx context.Context, in func (c *treasurerServiceClient) GetPaymentLinkQIWI(ctx context.Context, in *GetPhonePaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkQIWI", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkQIWI_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -68,7 +86,7 @@ func (c *treasurerServiceClient) GetPaymentLinkQIWI(ctx context.Context, in *Get func (c *treasurerServiceClient) GetPaymentLinkSberPay(ctx context.Context, in *GetPhonePaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSberPay", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSberPay_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -77,7 +95,7 @@ func (c *treasurerServiceClient) GetPaymentLinkSberPay(ctx context.Context, in * func (c *treasurerServiceClient) GetPaymentLinkAlfaClick(ctx context.Context, in *GetLoginPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkAlfaClick", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkAlfaClick_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -86,7 +104,7 @@ func (c *treasurerServiceClient) GetPaymentLinkAlfaClick(ctx context.Context, in func (c *treasurerServiceClient) GetPaymentLinkTinkoff(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkTinkoff", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkTinkoff_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -95,7 +113,7 @@ func (c *treasurerServiceClient) GetPaymentLinkTinkoff(ctx context.Context, in * func (c *treasurerServiceClient) GetPaymentLinkSberbankB2B(ctx context.Context, in *GetB2BPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -104,7 +122,7 @@ func (c *treasurerServiceClient) GetPaymentLinkSberbankB2B(ctx context.Context, func (c *treasurerServiceClient) GetPaymentLinkSBP(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSBP", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSBP_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -113,7 +131,7 @@ func (c *treasurerServiceClient) GetPaymentLinkSBP(ctx context.Context, in *GetP func (c *treasurerServiceClient) GetPaymentLinkMobile(ctx context.Context, in *GetPhonePaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkMobile", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkMobile_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -122,7 +140,7 @@ func (c *treasurerServiceClient) GetPaymentLinkMobile(ctx context.Context, in *G func (c *treasurerServiceClient) GetPaymentLinkCash(ctx context.Context, in *GetPhonePaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkCash", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkCash_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -131,7 +149,7 @@ func (c *treasurerServiceClient) GetPaymentLinkCash(ctx context.Context, in *Get func (c *treasurerServiceClient) GetPaymentLinkInstallments(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkInstallments", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkInstallments_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -214,7 +232,7 @@ func _TreasurerService_GetPaymentLinkBankCard_Handler(srv interface{}, ctx conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkBankCard", + FullMethod: TreasurerService_GetPaymentLinkBankCard_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkBankCard(ctx, req.(*GetBankCardPaymentLinkRequest)) @@ -232,7 +250,7 @@ func _TreasurerService_GetPaymentLinkYooMoney_Handler(srv interface{}, ctx conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkYooMoney", + FullMethod: TreasurerService_GetPaymentLinkYooMoney_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkYooMoney(ctx, req.(*GetPaymentLinkBody)) @@ -250,7 +268,7 @@ func _TreasurerService_GetPaymentLinkQIWI_Handler(srv interface{}, ctx context.C } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkQIWI", + FullMethod: TreasurerService_GetPaymentLinkQIWI_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkQIWI(ctx, req.(*GetPhonePaymentLinkRequest)) @@ -268,7 +286,7 @@ func _TreasurerService_GetPaymentLinkSberPay_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSberPay", + FullMethod: TreasurerService_GetPaymentLinkSberPay_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkSberPay(ctx, req.(*GetPhonePaymentLinkRequest)) @@ -286,7 +304,7 @@ func _TreasurerService_GetPaymentLinkAlfaClick_Handler(srv interface{}, ctx cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkAlfaClick", + FullMethod: TreasurerService_GetPaymentLinkAlfaClick_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkAlfaClick(ctx, req.(*GetLoginPaymentLinkRequest)) @@ -304,7 +322,7 @@ func _TreasurerService_GetPaymentLinkTinkoff_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkTinkoff", + FullMethod: TreasurerService_GetPaymentLinkTinkoff_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkTinkoff(ctx, req.(*GetPaymentLinkBody)) @@ -322,7 +340,7 @@ func _TreasurerService_GetPaymentLinkSberbankB2B_Handler(srv interface{}, ctx co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B", + FullMethod: TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkSberbankB2B(ctx, req.(*GetB2BPaymentLinkRequest)) @@ -340,7 +358,7 @@ func _TreasurerService_GetPaymentLinkSBP_Handler(srv interface{}, ctx context.Co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSBP", + FullMethod: TreasurerService_GetPaymentLinkSBP_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkSBP(ctx, req.(*GetPaymentLinkBody)) @@ -358,7 +376,7 @@ func _TreasurerService_GetPaymentLinkMobile_Handler(srv interface{}, ctx context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkMobile", + FullMethod: TreasurerService_GetPaymentLinkMobile_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkMobile(ctx, req.(*GetPhonePaymentLinkRequest)) @@ -376,7 +394,7 @@ func _TreasurerService_GetPaymentLinkCash_Handler(srv interface{}, ctx context.C } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkCash", + FullMethod: TreasurerService_GetPaymentLinkCash_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkCash(ctx, req.(*GetPhonePaymentLinkRequest)) @@ -394,7 +412,7 @@ func _TreasurerService_GetPaymentLinkInstallments_Handler(srv interface{}, ctx c } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkInstallments", + FullMethod: TreasurerService_GetPaymentLinkInstallments_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkInstallments(ctx, req.(*GetPaymentLinkBody)) diff --git a/internal/utils/transfer/privilege.go b/internal/utils/transfer/privilege.go index 5b02970..9abdca1 100644 --- a/internal/utils/transfer/privilege.go +++ b/internal/utils/transfer/privilege.go @@ -13,8 +13,9 @@ func PrivilegeProtoToModel(privilege *broker.PrivilegeMessage) *models.Privilege return &models.Privilege{ PrivilegeID: privilege.GetPrivilegeID(), ServiceKey: privilege.GetServiceKey(), - Type: privilege.GetType(), + Type: models.PrivilegeTypeMap[privilege.GetType()], Value: privilege.GetValue(), + Amount: privilege.GetAmount(), } } @@ -36,8 +37,9 @@ func PrivilegeModelToProto(privilege *models.Privilege) *broker.PrivilegeMessage return &broker.PrivilegeMessage{ PrivilegeID: privilege.PrivilegeID, ServiceKey: privilege.ServiceKey, - Type: privilege.Type, + Type: models.PrivilegeBrokerTypeMap[privilege.Type], Value: privilege.Value, + Amount: privilege.Amount, } } diff --git a/internal/utils/transfer/privilege_test.go b/internal/utils/transfer/privilege_test.go index 81ada29..db9a5aa 100644 --- a/internal/utils/transfer/privilege_test.go +++ b/internal/utils/transfer/privilege_test.go @@ -15,7 +15,8 @@ func TestPrivilegeModelToProto(t *testing.T) { &broker.PrivilegeMessage{ PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Amount: 10, + Type: broker.PrivilegeType_Count, Value: "12", }, transfer.PrivilegeModelToProto(&models.Privilege{ @@ -24,9 +25,10 @@ func TestPrivilegeModelToProto(t *testing.T) { PrivilegeID: "12", ServiceKey: "key-1", Description: "description", - Type: "type", + Type: models.PrivilegeTypeCount, Value: "12", Price: 20, + Amount: 10, }), ) }) @@ -43,7 +45,7 @@ func TestPrivilegeArrayModelToProto(t *testing.T) { { PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: broker.PrivilegeType_Full, Value: "12", }, }, @@ -54,7 +56,7 @@ func TestPrivilegeArrayModelToProto(t *testing.T) { PrivilegeID: "12", ServiceKey: "key-1", Description: "description", - Type: "type", + Type: models.PrivilegeTypeFull, Value: "12", Price: 20, }, @@ -69,14 +71,16 @@ func TestPrivilegeProtoToModel(t *testing.T) { &models.Privilege{ PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: models.PrivilegeTypeDay, Value: "12", + Amount: 12, }, transfer.PrivilegeProtoToModel(&broker.PrivilegeMessage{ PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: broker.PrivilegeType_Day, Value: "12", + Amount: 12, }), ) }) @@ -93,7 +97,7 @@ func TestPrivilegeArrayProtoToModel(t *testing.T) { { PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: models.PrivilegeTypeCount, Value: "12", }, {}, @@ -102,7 +106,7 @@ func TestPrivilegeArrayProtoToModel(t *testing.T) { { PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: broker.PrivilegeType_Count, Value: "12", }, nil, diff --git a/internal/utils/transfer/tariff_test.go b/internal/utils/transfer/tariff_test.go index 557d3e7..c43af17 100644 --- a/internal/utils/transfer/tariff_test.go +++ b/internal/utils/transfer/tariff_test.go @@ -48,7 +48,7 @@ func TestTariffMessageProtoToTariffModel(t *testing.T) { { PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: models.PrivilegeTypeCount, Value: "12", }, }, @@ -59,7 +59,7 @@ func TestTariffMessageProtoToTariffModel(t *testing.T) { { PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: broker.PrivilegeType_Count, Value: "12", }, }, @@ -81,7 +81,7 @@ func TestTariffModelToProtoMessage(t *testing.T) { { PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: broker.PrivilegeType_Count, Value: "12", }, }, @@ -91,7 +91,7 @@ func TestTariffModelToProtoMessage(t *testing.T) { { PrivilegeID: "12", ServiceKey: "key-1", - Type: "type", + Type: models.PrivilegeTypeCount, Value: "12", }, }, diff --git a/proto/broker/models.proto b/proto/broker/models.proto index 49440ee..93335f3 100644 --- a/proto/broker/models.proto +++ b/proto/broker/models.proto @@ -7,11 +7,18 @@ option go_package = "./broker"; message PrivilegeMessage { string PrivilegeID = 1; string ServiceKey = 2; - string Type = 3; + PrivilegeType Type = 3; string Value = 4; + uint64 Amount = 5; } message TariffMessage { repeated PrivilegeMessage Privileges = 1; string UserID = 2; } + +enum PrivilegeType { + Full = 0; + Day = 1; + Count = 2; +} \ No newline at end of file From f60f070239da3b9695cce4244dc8d3f7e9a54b41 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Fri, 18 Aug 2023 18:50:41 +0000 Subject: [PATCH 4/4] Update 2 files --- internal/service/cart/cart.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/service/cart/cart.go b/internal/service/cart/cart.go index a67b946..f9e3814 100644 --- a/internal/service/cart/cart.go +++ b/internal/service/cart/cart.go @@ -149,13 +149,18 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str return err } + receiver.logger.Debug("account for buy cart", zap.Any("trtr", account)) + tariffs, err := receiver.hubadminClient.GetTariffs(ctx, accessToken, account.Cart) if err != nil { receiver.logger.Error("failed to get tarrifs on of ", zap.Strings("cart", account.Cart), zap.Error(err)) return err } + receiver.logger.Debug("tariffs for buy cart", zap.Any("trtr", tariffs)) + tariffsAmount := utils.CalculateCartPurchasesAmount(tariffs) + receiver.logger.Debug("tariffsAmount for buy cart", zap.Any("trtr", tariffsAmount)) response, err := receiver.discountClient.Apply(ctx, &discount.ApplyDiscountRequest{ UserInformation: &discount.UserInformation{ @@ -172,6 +177,8 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str return err } + receiver.logger.Debug("applyed discounts for buy cart", zap.Any("trtr", response)) + if account.Wallet.Money < int64(response.Price) { receiver.logger.Error("insufficient funds on of ") return errors.New(fmt.Errorf("insufficient funds: %d", int64(response.Price)-account.Wallet.Money), errors.ErrInsufficientFunds)