models

package
v0.0.0-...-bdd2e6f Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoogleTranslator = "google"
)

Variables

View Source
var TranslatorPool = &sync.Pool{
	New: func() interface{} {
		t := config.GetTranslator()
		switch t {
		case GoogleTranslator:
			return google.NewGoogleTranslate()
		}

		return google.NewGoogleTranslate()
	},
}

Functions

This section is empty.

Types

type Favorite

type Favorite struct {
	ID     int
	UserID int
	WordID int
}

func (*Favorite) Insert

func (f *Favorite) Insert() (sql.Result, error)

type Favorites

type Favorites struct {
	UserID int
	Words  []*words.Word
}

func (*Favorites) GetFavorites

func (fs *Favorites) GetFavorites() ([]*words.Word, error)

type Response

type Response struct {
	Code      int         `json:"code"`
	Timestamp int64       `json:"timestamp"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data"`
}

todo: 状态码定义

func NewResponse

func NewResponse(code int, message string, data interface{}) *Response

type Translator

type Translator interface {
	Translate(string) (*words.Word, error)
	Pronounce(string) ([]byte, error)
}

type User

type User struct {
	ID       int
	Name     string `form:"name"`
	Password string `form:"pass"`
}

func (*User) Insert

func (u *User) Insert() (sql.Result, error)

func (*User) Verify

func (u *User) Verify() error

Verify 用于登陆场景

type UserClaims

type UserClaims struct {
	jwt.StandardClaims

	ID   int    `json:"id"`
	Name string `json:"name"`
}

func NewUserClaims

func NewUserClaims(id int, name string) UserClaims

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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