feat: added new repository implementation, small improvements

This commit is contained in:
ITQ
2025-11-11 21:35:06 +03:00
parent 9d58fe0b41
commit a2345bedac
13 changed files with 395 additions and 25 deletions
+6 -4
View File
@@ -4,6 +4,8 @@ import (
"errors"
"fmt"
"strings"
"github.com/google/uuid"
)
var (
@@ -13,9 +15,9 @@ var (
)
type Order struct {
ID string
Item string
Quantity int32
ID uuid.UUID `db:"id" json:"id"`
Item string `db:"item" json:"item"`
Quantity int32 `db:"quantity" json:"quantity"`
}
func (o *Order) Validate() error {
@@ -25,7 +27,7 @@ func (o *Order) Validate() error {
if o.Quantity <= 0 {
return fmt.Errorf("%w: quantity must be positive", ErrInvalidOrderData)
}
if o.ID == "" {
if o.ID.String() == "" {
return fmt.Errorf("%w: ID cannot be empty", ErrInvalidOrderData)
}
return nil