users

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	Client *sqlx.DB
}

func New

func New(client *sqlx.DB) *User

func (*User) AuthExistUsername

func (y *User) AuthExistUsername(username string) bool

func (*User) AuthWithPassword

func (y *User) AuthWithPassword(res UserResponse, password string) bool

func (*User) Create

func (y *User) Create(u UserCreateRequest) (id int64, err error)

func (*User) FindAll

func (y *User) FindAll(page, limit int) (res []UserResponse, err error)

func (*User) FindById

func (y *User) FindById(id int) (res UserResponse, err error)

func (*User) FindByUsername

func (y *User) FindByUsername(username string) (res UserResponse, err error)

func (*User) FindFirst

func (y *User) FindFirst() (res UserResponse, err error)

func (*User) FindLast

func (y *User) FindLast() (res UserResponse, err error)

func (*User) UpdateDisableAccount

func (y *User) UpdateDisableAccount(id int, description string) (err error)

func (*User) UpdateEnableAccount

func (y *User) UpdateEnableAccount(id int) (err error)

func (*User) UpdateLevelUser

func (y *User) UpdateLevelUser(id, level int) (err error)

func (*User) UpdatePassword

func (y *User) UpdatePassword(id int, password string) (err error)

type UserCreateRequest

type UserCreateRequest struct {
	Username          string `db:"username"`
	Password          string `db:"password"`
	Active            bool   `json:"active" db:"active"`
	ActiveDescription string `json:"active_description,omitempty" db:"active_description"`
	Level             int    `json:"level" db:"level"`
}

type UserResponse

type UserResponse struct {
	Id                int       `json:"id" db:"id"`
	Username          string    `json:"username" db:"username"`
	Password          string    `json:"-" db:"password"`
	Active            bool      `json:"active" db:"active"`
	ActiveDescription *string   `json:"-" db:"active_description"`
	CreatedAt         time.Time `json:"created_at" db:"created_at"`
	UpdatedAt         time.Time `json:"-" db:"updated_at"`
	Level             int       `json:"-" db:"level"`
}

Jump to

Keyboard shortcuts

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