[hw-8] add: comment service

This commit is contained in:
3ybacTuK
2025-07-26 23:47:18 +03:00
parent 6420eaf3d7
commit 6e0d90a6d5
29 changed files with 1249 additions and 725 deletions

View File

@@ -1,22 +0,0 @@
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

@@ -3,3 +3,5 @@ package model
import "errors"
var ErrCommentNotFound = errors.New("comment not found")
var ErrCommentEditUserMismatch = errors.New("comment edit user mismatch")
var ErrCommentEditTimeout = errors.New("comment edit timeout")

View File

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