types

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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PolicySubjectAny = "*"
	PolicyObjectAny  = "*"
	PolicyActionAny  = "*"
)
View Source
const (
	PolicyActionCreate  = "create"
	PolicyActionUpdate  = "update"
	PolicyActionRead    = "read"
	PolicyActionReadAll = "read-all"
	PolicyActionDelete  = "delete"
)
View Source
const (
	PolicyObjectUser      = "user"
	PolicyObjectMovie     = "user"
	PolicyObjectWatchList = "watch_list"
)
View Source
const (
	UserContextKey contextKey = "user"
)

Variables

View Source
var ErrMovieNotFound = errors.New("Movie not found")

Functions

func ResponseJson

func ResponseJson(w http.ResponseWriter, data interface{}, resinfo ResponseInfo)

Types

type AllResponse

type AllResponse struct {
	NormalResponse NormalResponse `yaml:"normal"`
	UserResponse   UserResponse   `yaml:"user"`
	AuthResponse   AuthResponse   `yaml:"auth"`
	MovieResponse  MovieResponse  `yaml:"movie"`
}

func Load

func Load() *AllResponse

type AuthResponse

type AuthResponse struct {
	UserLocked    ResponseInfo `yaml:"user_locked"`
	EmailNotExist ResponseInfo `yaml:"email_not_exist"`
	PasswordWrong ResponseInfo `yaml:"password_wrong"`
	Unauthorized  ResponseInfo `yaml:"unauthorized"`
	TokenInvalid  ResponseInfo `yaml:"token_invalid"`
}

func Auth

func Auth() AuthResponse

type Gender

type Gender int
const (
	MALE   Gender = 1
	FEMALE Gender = 2
	OTHER  Gender = 3
)

type MovieInfo

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

type MovieResponse

type MovieResponse struct {
	Created      ResponseInfo `yaml:"created"`
	DeleteFailed ResponseInfo `yaml:"delete_failed"`
	NotFound     ResponseInfo `yaml:"not_found"`
}

func Movie

func Movie() MovieResponse

type NormalResponse

type NormalResponse struct {
	Success        ResponseInfo `yaml:"success"`
	NotFound       ResponseInfo `yaml:"not_found"`
	TimeOut        ResponseInfo `yaml:"timeout"`
	BadRequest     ResponseInfo `yaml:"bad_request"`
	Internal       ResponseInfo `yaml:"internal"`
	PermissionDeny ResponseInfo `yaml:"permission_deny"`
}

func Normal

func Normal() NormalResponse

type Response

type Response struct {
	Code    int         `json:"code"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"message"`
}

type ResponseInfo

type ResponseInfo struct {
	Status  int    `yaml:"status"`
	Code    int    `yaml:"code"`
	Message string `yaml:"message"`
}

type Role

type Role string
const (
	RoleAdmin  Role = "admin"
	RoleNormal Role = "normal"
)

type UserInfo

type UserInfo struct {
	ID        string    `json:"_id"`
	FirstName string    `json:"first_name"`
	LastName  string    `json:"last_name"`
	Gender    int       `json:"gender"`
	Email     string    `json:"email"`
	Role      string    `json:"role"`
	Password  string    `json:"password,omitempty"`
	Locked    bool      `json:"locked"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type UserResponse

type UserResponse struct {
	Created        ResponseInfo `yaml:"created"`
	DuplicateEmail ResponseInfo `yaml:"duplicate_email"`
	UpdateFailed   ResponseInfo `yaml:"update_failed"`
	CreateFailed   ResponseInfo `yaml:"create_failed"`
	DeleteFailed   ResponseInfo `yaml:"delete_failed"`
	UserNotFound   ResponseInfo `yaml:"user_not_found"`
}

func User

func User() UserResponse

Jump to

Keyboard shortcuts

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