Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions registry/internal/core/ordering.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"eCommerce/registry/internal/api/requests"
"eCommerce/registry/internal/models"
"errors"
"time"

"github.com/segmentio/kafka-go"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.uber.org/zap"
"time"
)

type PurchaseController interface {
Expand Down Expand Up @@ -46,7 +47,7 @@ func (p *Purchaser) Order(userId primitive.ObjectID, r *requests.OrderRequest) (
order := new(models.Order)
order.UserId = userId
order.Status = models.OrderPending
order.Timestamp = time.Now().UTC()
order.Timestamp = time.Now().UTC() // Здесь есть некоторая проблема. Можешь порассуждать?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не совсем очевидно.
Думаю проблема в том, что потом для пользователя надо будет преобразовывать значение к его временной зоне.
И возможно здесь Timestamp не отражает, что он в UTC и лучше было бы использовать название TimestampUTC.

order.Items = r.Items
order.Updates = []models.OrderUpdate{
{
Expand Down
8 changes: 5 additions & 3 deletions registry/internal/core/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import (
"eCommerce/registry/internal/models"
"encoding/json"
"errors"
"io/ioutil"
"net/http"
"time"

"github.com/segmentio/kafka-go"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.uber.org/zap"
"io/ioutil"
"net/http"
"time"
)

type RegistryController interface {
Expand Down Expand Up @@ -183,6 +184,7 @@ func Identity(r *http.Request) (*models.Identity, error) {
return identity, nil
}

// А можешь пояснить, зачем столько вариантов?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для GET запросов неполучится из тела запроса uid получить, и я добавил для параметров.
Для swagger добавил куку, чтобы не вводить каждый раз uid и забыл убрать.
Для контекста нужно выше поднять, чтобы лишний раз не вытаскивать из запроса.

return nil, errors.New(`no identity`)
}

Expand Down
5 changes: 3 additions & 2 deletions registry/internal/data/order_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ package data
import (
"context"
"eCommerce/registry/internal/models"
"time"

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"
)

type RegistryRepository interface {
FindOrderId(id primitive.ObjectID) (*models.Order, error)
UpdateOrder(id primitive.ObjectID, updates []bson.E) (*models.Order, error)
UpdateOrderStatus(id primitive.ObjectID, status models.OrderStatus) (*models.Order, error)
Commit() error
Commit() error // Искал, куда ты хотел вставить этот метод, но не нашёл в коде)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, убрать надо

}

type MongoRegistryRepository struct {
Expand Down