ch7.1
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"gitea.local.lab/Lbenedar/greenlight/internal/validator"
|
||||
)
|
||||
|
||||
type MovieModel struct {
|
||||
DB *sql.DB
|
||||
}
|
||||
|
||||
type Movie struct {
|
||||
ID int64 `json:"id"`
|
||||
CreatedAt time.Time `json:"-"`
|
||||
@@ -16,6 +21,40 @@ type Movie struct {
|
||||
Version int32 `json:"version"`
|
||||
}
|
||||
|
||||
func (m MovieModel) Insert(movie *Movie) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m MovieModel) Get(id int64) (*Movie, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m MovieModel) Update(movie *Movie) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m MovieModel) Delete(id int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type MockMovieModel struct{}
|
||||
|
||||
func (m MockMovieModel) Insert(movie *Movie) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m MockMovieModel) Get(id int64) (*Movie, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m MockMovieModel) Update(movie *Movie) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m MockMovieModel) Delete(id int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateMovie(v *validator.Validator, movie *Movie) {
|
||||
v.Check(movie.Title != "", "title", "must be provided")
|
||||
v.Check(len(movie.Title) <= 500, "title", "must not be more than 500 bytes long")
|
||||
|
||||
Reference in New Issue
Block a user