[hw-8] add: repo layer

This commit is contained in:
3ybactuk
2025-07-25 23:04:31 +03:00
committed by 3ybacTuK
parent c1e8934646
commit 6420eaf3d7
25 changed files with 4194 additions and 6 deletions

View File

@@ -0,0 +1,9 @@
package entity
type Comment struct {
ID int64
UserID int64
SKU int64
CreatedAt string
Text string
}

View File

@@ -0,0 +1,22 @@
package model
import (
"fmt"
"time"
)
type Comment struct {
ID int64 `validate:"gt=0"`
UserID int64 `validate:"gt=0"`
SKU int64 `validate:"gt=0"`
CreatedAt time.Time
Text string `validate:"lte=255,gt=0"`
}
func (c *Comment) Validate() error {
if err := validate.Struct(c); err != nil {
return fmt.Errorf("invalid requested values: %w", err)
}
return nil
}

View File

@@ -0,0 +1,5 @@
package model
import "errors"
var ErrCommentNotFound = errors.New("comment not found")

View File

@@ -0,0 +1,9 @@
package model
import "github.com/go-playground/validator/v10"
var validate *validator.Validate
func init() {
validate = validator.New()
}

View File

@@ -0,0 +1,3 @@
package service
// TODO