users

package
v0.0.0-...-b2c9b18 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	C *ctx.Context
}

Handler is a container for handlers and app data

func NewHandler

func NewHandler(c *ctx.Context) *Handler

func (*Handler) DeleteUser

func (h *Handler) DeleteUser(c echo.Context) error

DeleteUser is a DELETE /users/{id} handler

func (*Handler) GetAllUsers

func (h *Handler) GetAllUsers(c echo.Context) error

GetAllUsers is a GET /users handler

func (*Handler) GetUser

func (h *Handler) GetUser(c echo.Context) error

GetUser is a GET /users/{id} handler

func (*Handler) PostUser

func (h *Handler) PostUser(c echo.Context) error

CreateUser is a POST /users handler

func (*Handler) PutUser

func (h *Handler) PutUser(c echo.Context) error

PutUser is a PUT /users/{id} handler

type PostBody

type PostBody struct {
	Email         string  `json:"email"`
	Password      string  `json:"password"`
	DisplayName   string  `json:"displayName"`
	PasswordURL   *string `json:"passwordUrl"`
	PasswordEtime uint64  `json:"passwordEtime"`
}

PostBody represents payload data format

type User

type User struct {
	ID            uint64         `xorm:"'id' pk autoincr unique notnull" json:"id"`
	Email         string         `xorm:"'email' text index not null unique" json:"email"`
	DisplayName   string         `xorm:"'display_name' text" json:"displayName"`
	Password      string         `xorm:"'password' text not null" json:"-"`
	PasswordEtime uint64         `xorm:"'password_etime'" json:"passwordEtime"`
	PasswordURL   sql.NullString `xorm:"'password_url' text unique" json:"passwordUrl"`
	Created       uint64         `xorm:"created" json:"created"`
	Updated       uint64         `xorm:"updated" json:"updated"`
}

User is an entity (here are DB definitions)

func FindAll

func FindAll(orm *xorm.Engine) ([]User, error)

FindAll users in database

func NewUser

func NewUser(b *PostBody) *User

NewUser creates user from request body returns *User with data from body returns nil if error occurred

func (*User) Delete

func (u *User) Delete(orm *xorm.Engine) error

Delete user from database

func (*User) FindOne

func (u *User) FindOne(orm *xorm.Engine) error

FindOne finds in database first user with matched struct fields

func (*User) Save

func (u *User) Save(orm *xorm.Engine) error

Save user to database

func (*User) TableName

func (u *User) TableName() string

TableName used by xorm to set table name for entity

func (*User) Update

func (u *User) Update(orm *xorm.Engine) error

Update user in database

Jump to

Keyboard shortcuts

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