model

package
v0.0.0-...-fdc4385 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserNotFound indicates user not found in database
	UserNotFound modelError = iota + 1

	// InvalidUserOrPassword ...
	InvalidUserOrPassword

	// UserNotCreated ...
	UserNotCreated

	// SignJWTFailed ...
	SignJWTFailed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppError

type AppError interface {
	error
	Code() int32
}

AppError ...

type Token

type Token struct {
	gorm.Model
	Value string
}

Token user token model

type TokenRepo

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

TokenRepo ...

func GetTokenRepo

func GetTokenRepo() *TokenRepo

GetTokenRepo ...

func (*TokenRepo) Create

func (repo *TokenRepo) Create(u *User) (*Token, error)

Create ...

func (*TokenRepo) Delete

func (repo *TokenRepo) Delete(t *Token) bool

Delete ...

func (*TokenRepo) Validate

func (repo *TokenRepo) Validate(token string) (bool, error)

Validate ...

type User

type User struct {
	gorm.Model `json:"gormModel"`
	Email      string `gorm:"unique_index;not null" json:"email"`
	Password   string `gorm:"not null" json:"password"`
	Name       string `json:"name"`
}

User user model

type UserList

type UserList struct {
	PageIndex, PageSize, TotalPages int32
	Data                            []*User
}

UserList ...

type UserRepo

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

UserRepo ...

func GetUserRepo

func GetUserRepo() *UserRepo

GetUserRepo ...

func (*UserRepo) Create

func (repo *UserRepo) Create(u *User) (*User, error)

Create ...

func (*UserRepo) GetUserByEmail

func (repo *UserRepo) GetUserByEmail(email string) (*User, error)

GetUserByEmail ...

func (*UserRepo) GetUserByEmailAndPassword

func (repo *UserRepo) GetUserByEmailAndPassword(email, password string) (*User, error)

GetUserByEmailAndPassword ...

func (*UserRepo) GetUserByID

func (repo *UserRepo) GetUserByID(id uint64) (*User, error)

GetUserByID ...

func (*UserRepo) GetUserList

func (repo *UserRepo) GetUserList(n, s int32) (*UserList, error)

GetUserList ...

n page number
s page size

func (*UserRepo) Migrate

func (repo *UserRepo) Migrate()

Migrate ...

Jump to

Keyboard shortcuts

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