diff --git a/basket/entity/basket.go b/basket/entity/basket.go index 22a2b5b..8ffc96a 100644 --- a/basket/entity/basket.go +++ b/basket/entity/basket.go @@ -1,22 +1,20 @@ package basket -import ( - "github.com/jackc/pgtype" -) +import "time" type BasketEntity struct { - ID string `db:"id" json:"id"` - State string `db:"state" json:"state"` - CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"` - UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"` + ID string `db:"id" json:"id"` + State string `db:"state" json:"state"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt *time.Time `db:"updated_at" json:"updated_at,omitempty"` } type BasketItemEntity struct { - ID string `db:"id" json:"id"` - BasketID string `db:"basket_id" json:"basket_id"` - ProductID string `db:"product_id" json:"product_id"` - Quantity int `db:"quantity" json:"quantity"` - Price float64 `db:"price" json:"price"` - CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"` - UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"` + ID string `db:"id" json:"id"` + BasketID string `db:"basket_id" json:"basket_id"` + ProductID string `db:"product_id" json:"product_id"` + Quantity int `db:"quantity" json:"quantity"` + Price float64 `db:"price" json:"price"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt *time.Time `db:"updated_at" json:"updated_at,omitempty"` } diff --git a/basket/model/basket.go b/basket/model/basket.go index 998cc77..d895015 100644 --- a/basket/model/basket.go +++ b/basket/model/basket.go @@ -5,16 +5,16 @@ import ( ) type Basket struct { - State string `db:"state" json:"state"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"` + State string `db:"state" json:"state"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt *time.Time `db:"updated_at" json:"updated_at,omitempty"` } type BasketItem struct { - BasketID string `db:"basket_id" json:"basket_id"` - ProductID string `db:"product_id" json:"product_id"` - Quantity int `db:"quantity" json:"quantity"` - Price float64 `db:"price" json:"price"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"` + BasketID string `db:"basket_id" json:"basket_id"` + ProductID string `db:"product_id" json:"product_id"` + Quantity int `db:"quantity" json:"quantity"` + Price float64 `db:"price" json:"price"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt *time.Time `db:"updated_at" json:"updated_at,omitempty"` } diff --git a/catalog/entity/product.go b/catalog/entity/product.go index fc3f40d..4672f1f 100644 --- a/catalog/entity/product.go +++ b/catalog/entity/product.go @@ -3,10 +3,10 @@ package catalog import "time" type Product struct { - ID string `json:"id", db:"id"` - Slug string `json:"slug", db:"slug"` - Name string `json:"name", db:"name"` - Price float64 `json:"price", db:"price"` - CreatedAt time.Time `json:"created_at", db:"created_at"` - UpdatedAt *time.Time `json:"updated_at", db:"updated_at, omitempty"` + ID string `json:"id" db:"id"` + Slug string `json:"slug" db:"slug"` + Name string `json:"name" db:"name"` + Price float64 `json:"price" db:"price"` + CreatedAt time.Time `json:"created_at" db:"created_at"` + UpdatedAt *time.Time `json:"updated_at" db:"updated_at, omitempty"` } diff --git a/identity/dto/headers.go b/identity/dto/header.go similarity index 100% rename from identity/dto/headers.go rename to identity/dto/header.go diff --git a/identity/entity/user.go b/identity/entity/user.go index 8a69b23..bd519ea 100644 --- a/identity/entity/user.go +++ b/identity/entity/user.go @@ -8,12 +8,5 @@ type User struct { Username string `db:"username" json:"username"` Password string `db:"password" json:"password"` CreatedAt time.Time `db:"created_at" json:"created_at"` - UpdatedAt *time.Time `db:"updated_at,omitempty" json:"updated_at,omitempty"` // FIXME: zero-value issue + UpdatedAt *time.Time `db:"updated_at,omitempty" json:"updated_at,omitempty"` } - -// var TestUser = &User{ -// ID: 1, -// Username: "test", -// Password: "test", -// CreateDate: time.Now(), -// } diff --git a/order/entity/order.go b/order/entity/order.go index dd3e862..83bb22a 100644 --- a/order/entity/order.go +++ b/order/entity/order.go @@ -1,20 +1,22 @@ package order -import "github.com/jackc/pgtype" +import ( + "time" +) type OrderEntity struct { - ID string `db:"id" json:"id"` - State string `db:"state" json:"state"` - CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"` - UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"` + ID string `db:"id" json:"id"` + State string `db:"state" json:"state"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt *time.Time `db:"updated_at" json:"updated_at,omitempty"` } type OrderItemEntity struct { - ID string `db:"id" json:"id"` - OrderID string `db:"order_id" json:"order_id"` - ProductID int `db:"product_id" json:"product_id"` - Quantity int `db:"quantity" json:"quantity"` - Price float64 `db:"price" json:"price"` - CreatedAt pgtype.Timestamp `db:"created_at" json:"created_at"` - UpdatedAt pgtype.Timestamp `db:"updated_at" json:"updated_at,omitempty"` + ID string `db:"id" json:"id"` + OrderID string `db:"order_id" json:"order_id"` + ProductID int `db:"product_id" json:"product_id"` + Quantity int `db:"quantity" json:"quantity"` + Price float64 `db:"price" json:"price"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt *time.Time `db:"updated_at" json:"updated_at,omitempty"` } diff --git a/order/model/order.go b/order/model/order.go index c88cd3b..93a297f 100644 --- a/order/model/order.go +++ b/order/model/order.go @@ -3,16 +3,16 @@ package order import "time" type Order struct { - State string `db:"state" json:"state"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"` + State string `db:"state" json:"state"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt *time.Time `db:"updated_at" json:"updated_at,omitempty"` } type OrderItem struct { - OrderID string `db:"order_id" json:"order_id"` - ProductID int `db:"product_id" json:"product_id"` - Quantity int `db:"quantity" json:"quantity"` - Price float64 `db:"price" json:"price"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty"` + OrderID string `db:"order_id" json:"order_id"` + ProductID int `db:"product_id" json:"product_id"` + Quantity int `db:"quantity" json:"quantity"` + Price float64 `db:"price" json:"price"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt *time.Time `db:"updated_at" json:"updated_at,omitempty"` }