movie

package
v0.0.0-...-6ecc318 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMovieNotFound     = errors.New("movie not found")
	ErrPermissionDeny    = errors.New("permission deny")
	ErrUpdateMovieFailed = errors.New("update movie failed")
)

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	Name        string   `validate:"required" json:"name"`
	Rate        float64  `validate:"required" json:"rate"`
	Directors   []string `validate:"required" json:"directors"`
	Writers     []string `validate:"required" json:"writers"`
	Casts       []string `validate:"required" json:"casts"`
	Genres      []string `validate:"required" json:"genres"`
	MovieLength int      `validate:"required" json:"movie_length"`
	ReleaseTime string   `validate:"required" json:"release_time"`
}

type FindRequest

type FindRequest struct {
	Name        string   `json:"name"`
	Rate        float64  `json:"rate"`
	Directors   []string `json:"directors"`
	Writers     []string `json:"writers"`
	Genres      []string `json:"genres"`
	Casts       []string `json:"casts"`
	MovieLength int      `json:"movie_length"`
	ReleaseTime string   `json:"release_time"`
	CreatedByID string   `json:"created_by_id"`
	Offset      int      `json:"offset"`
	Limit       int      `json:"limit"`
	Selects     []string `json:"selects"`
	SortBy      []string `json:"sort_by"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(srv service) *Handler

func (*Handler) CreateMovie

func (h *Handler) CreateMovie(w http.ResponseWriter, r *http.Request)

func (*Handler) DeleteMovieById

func (h *Handler) DeleteMovieById(w http.ResponseWriter, r *http.Request)

func (*Handler) GetAllMovies

func (h *Handler) GetAllMovies(w http.ResponseWriter, r *http.Request)

func (*Handler) GetMovieById

func (h *Handler) GetMovieById(w http.ResponseWriter, r *http.Request)

func (*Handler) Routes

func (h *Handler) Routes() []router.Route

func (*Handler) Update

func (h *Handler) Update(w http.ResponseWriter, r *http.Request)

type MongoDBRepository

type MongoDBRepository struct {
	// contains filtered or unexported fields
}

func NewMongoDBRepository

func NewMongoDBRepository(s *mgo.Session) *MongoDBRepository

func (*MongoDBRepository) Create

func (m *MongoDBRepository) Create(ctx context.Context, movie Movie) (string, error)

func (*MongoDBRepository) DeleteById

func (m *MongoDBRepository) DeleteById(ctx context.Context, id string) error

func (*MongoDBRepository) GetAllMovies

func (m *MongoDBRepository) GetAllMovies(ctx context.Context, req FindRequest) ([]*Movie, error)

func (*MongoDBRepository) GetMovieById

func (m *MongoDBRepository) GetMovieById(ctx context.Context, id string) (*Movie, error)

func (*MongoDBRepository) GetMovieByName

func (m *MongoDBRepository) GetMovieByName(ctx context.Context, name string) (*Movie, error)

func (*MongoDBRepository) Update

func (m *MongoDBRepository) Update(ctx context.Context, movie *Movie) error

type Movie

type Movie struct {
	ID           string     `bson:"_id"`
	Name         string     `bson:"name"`
	Rate         float64    `bson:"rate"`
	Directors    []string   `bson:"directors"`
	Writers      []string   `bson:"writers"`
	TrailersPath []string   `bson:"trailers_path"`
	ImagesPath   []string   `bson:"images_path"`
	Casts        []string   `bson:"casts"`
	Genres       []string   `bson:"genres"`
	Storyline    string     `bson:"storyline"`
	UserReviews  []string   `bson:"user_reviews"`
	MovieLength  int        `bson:"movie_length"`
	ReleaseTime  string     `bson:"release_time"`
	CreatedAt    *time.Time `bson:"created_at"`
	UpdatedAt    *time.Time `bson:"updated_at"`
	UserId       string     `bson:"user_id"`
}

func (*Movie) ConvertMovieToMovieResponse

func (m *Movie) ConvertMovieToMovieResponse() *types.MovieInfo

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repo repository) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, req CreateRequest) (string, error)

func (*Service) CreateMovie

func (s *Service) CreateMovie(m types.MovieInfo) error

CreateMovie for crawler use

func (*Service) DeleteById

func (s *Service) DeleteById(ctx context.Context, id string) error

func (*Service) GetAllMovies

func (s *Service) GetAllMovies(ctx context.Context, req FindRequest) ([]*types.MovieInfo, error)

func (*Service) GetMovieById

func (s *Service) GetMovieById(ctx context.Context, id string) (*types.MovieInfo, error)

func (*Service) GetMovieByName

func (s *Service) GetMovieByName(name string) (*types.MovieInfo, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, id string, req UpdateRequest) error

type UpdateRequest

type UpdateRequest struct {
	Name         string   `json:"name"`
	Rate         float64  `json:"rate"`
	Directors    []string `json:"directors"`
	Writers      []string `json:"writers"`
	TrailersPath []string `json:"trailers_path"`
	ImagesPath   []string `json:"images_path"`
	Genres       []string `json:"genres"`
	Casts        []string `json:"casts"`
	Storyline    string   `json:"storyline"`
	UserReviews  []string `json:"user_reviews"`
	MovieLength  int      `json:"movie_length"`
	ReleaseTime  string   `json:"release_time"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL