Restructurization
This commit is contained in:
parent
f9acb885a8
commit
d7d8ac5091
@ -1,22 +1,22 @@
|
||||
package http
|
||||
package basket
|
||||
|
||||
import "time"
|
||||
|
||||
type GetBasketRequest struct {
|
||||
type GetBasketRequestDTO struct {
|
||||
BasketID string `json:"basket_id"`
|
||||
}
|
||||
|
||||
type GetBasketResponse struct {
|
||||
type GetBasketResponseDTO struct {
|
||||
ID string `json:"id"`
|
||||
State string `json:"state"`
|
||||
CreatedAt time.Duration `json:"created_at"`
|
||||
UpdatedAt time.Duration `json:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
type GetBasketItemsRequest struct {
|
||||
type GetBasketItemsRequestDTO struct {
|
||||
}
|
||||
|
||||
type GetBasketItemsResponse struct {
|
||||
type GetBasketItemsResponseDTO struct {
|
||||
ID string `json:"id"`
|
||||
BasketID string `json:"basket_id"`
|
||||
ProductID int `json:"product_id"`
|
||||
@ -26,10 +26,10 @@ type GetBasketItemsResponse struct {
|
||||
UpdatedAt time.Duration `json:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
type BasketCheckoutRequest struct {
|
||||
type BasketCheckoutRequestDTO struct {
|
||||
BasketID string `json:"basket_id"`
|
||||
}
|
||||
|
||||
type BasketCheckoutResponse struct {
|
||||
type BasketCheckoutResponseDTO struct {
|
||||
ID string `json:"basket_id"`
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
package model
|
||||
package basket
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgtype"
|
||||
)
|
||||
|
||||
type BasketModel struct {
|
||||
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"`
|
||||
}
|
||||
|
||||
type BasketItemModel struct {
|
||||
type BasketItemEntity struct {
|
||||
ID string `db:"id" json:"id"`
|
||||
BasketID string `db:"basket_id" json:"basket_id"`
|
||||
ProductID int `db:"product_id" json:"product_id"`
|
22
basket/model/model.go
Normal file
22
basket/model/model.go
Normal file
@ -0,0 +1,22 @@
|
||||
package basket
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgtype"
|
||||
)
|
||||
|
||||
type BasketModel 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"`
|
||||
}
|
||||
|
||||
type BasketItemModel struct {
|
||||
// ID string `db:"id" json:"id"`
|
||||
BasketID string `db:"basket_id" json:"basket_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"`
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package http
|
||||
package catalog
|
||||
|
||||
import (
|
||||
"time"
|
@ -1,8 +1,8 @@
|
||||
package model
|
||||
package catalog
|
||||
|
||||
import "github.com/jackc/pgtype"
|
||||
|
||||
type ProductModel struct {
|
||||
type ProductEntity struct {
|
||||
ID int `db:"id"`
|
||||
PID string `db:"pid"`
|
||||
Name string `db:"name"`
|
12
catalog/model/model.go
Normal file
12
catalog/model/model.go
Normal file
@ -0,0 +1,12 @@
|
||||
package catalog
|
||||
|
||||
import "github.com/jackc/pgtype"
|
||||
|
||||
type ProductModel struct {
|
||||
// ID int `db:"id"`
|
||||
PID string `db:"pid"`
|
||||
Name string `db:"name"`
|
||||
Price float64 `db:"price"`
|
||||
CreatedAt pgtype.Timestamp `db:"created_at"`
|
||||
UpdatedAt pgtype.Timestamp `db:"updated_at,omitempty"`
|
||||
}
|
9
common/dto/error.go
Normal file
9
common/dto/error.go
Normal file
@ -0,0 +1,9 @@
|
||||
package common
|
||||
|
||||
type ErrorResponseDTO struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
func Error(err string) *ErrorResponseDTO { // FIXME Can DTOs have functions?
|
||||
return &ErrorResponseDTO{err}
|
||||
}
|
5
common/dto/health.go
Normal file
5
common/dto/health.go
Normal file
@ -0,0 +1,5 @@
|
||||
package common
|
||||
|
||||
type HealthResponseDTO struct {
|
||||
Status string `json:"status"`
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package http
|
||||
|
||||
type ErrorResponse struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
func Error(err string) *ErrorResponse {
|
||||
return &ErrorResponse{err}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package http
|
||||
|
||||
type HealthResponse struct {
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package http
|
||||
|
||||
type UpdateOrderStatusRequest struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type UpdateOrderStatusResponse struct {
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package http
|
||||
|
||||
type ProductPriceRequest struct {
|
||||
ProductId int `json:"product_id"`
|
||||
}
|
||||
|
||||
type ProductPriceResponse struct {
|
||||
Price int `json:"price"`
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package http
|
||||
package identity
|
||||
|
||||
type AuthLoginRequest struct {
|
||||
type AuthLoginRequestDTO struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type AuthLoginResponse struct {
|
||||
type AuthLoginResponseDTO struct {
|
||||
Token string `json:"jwt_token"`
|
||||
}
|
8
order/dto/dto.go
Normal file
8
order/dto/dto.go
Normal file
@ -0,0 +1,8 @@
|
||||
package order
|
||||
|
||||
type UpdateOrderStatusRequestDTO struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type UpdateOrderStatusResponseDTO struct {
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
package model
|
||||
package order
|
||||
|
||||
import "github.com/jackc/pgtype"
|
||||
|
||||
type OrderModel struct {
|
||||
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"`
|
||||
}
|
||||
|
||||
type OrderItemModel struct {
|
||||
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"`
|
20
order/model/model.go
Normal file
20
order/model/model.go
Normal file
@ -0,0 +1,20 @@
|
||||
package order
|
||||
|
||||
import "github.com/jackc/pgtype"
|
||||
|
||||
type OrderModel 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"`
|
||||
}
|
||||
|
||||
type OrderItemModel 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"`
|
||||
}
|
9
pricing/dto/dto.go
Normal file
9
pricing/dto/dto.go
Normal file
@ -0,0 +1,9 @@
|
||||
package pricing
|
||||
|
||||
type ProductPriceRequestDTO struct {
|
||||
ProductId int `json:"product_id"`
|
||||
}
|
||||
|
||||
type ProductPriceResponseDTO struct {
|
||||
Price int `json:"price"`
|
||||
}
|
7
pricing/entity/entity.go
Normal file
7
pricing/entity/entity.go
Normal file
@ -0,0 +1,7 @@
|
||||
package pricing
|
||||
|
||||
type ProductPriceEntity struct {
|
||||
ID int `db:"id"`
|
||||
PID string `db:"pid"`
|
||||
Price int `db:"price"`
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
package pricing
|
||||
|
||||
type ProductPriceModel struct {
|
||||
ID int `db:"id"`
|
||||
// ID int `db:"id"`
|
||||
PID string `db:"pid"`
|
||||
Price int `db:"price"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user