user

package module
v0.0.0-...-3670298 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Routes map[myrouter.RouteKey]func(w http.ResponseWriter, r *http.Request, ps common.QueryMap) = map[myrouter.RouteKey]func(w http.ResponseWriter, r *http.Request, ps common.QueryMap){
	{Path: "/api/v1/users", Method: "GET", NeedAuth: true}:             uc.getAll,
	{Path: "/api/v1/users/:user_id", Method: "GET", NeedAuth: true}:    uc.get,
	{Path: "/api/v1/users", Method: "POST", NeedAuth: true}:            uc.post,
	{Path: "/api/v1/users/:user_id", Method: "PUT", NeedAuth: true}:    uc.update,
	{Path: "/api/v1/users/:user_id", Method: "DELETE", NeedAuth: true}: uc.delete,
}

Functions

This section is empty.

Types

type DeleteResponse

type DeleteResponse struct {
	myhttp.ResponseBase
}

type GetAllResponse

type GetAllResponse struct {
	myhttp.ResponseBase
	Users []User `json:"zos"`
}

type GetResponse

type GetResponse struct {
	myhttp.ResponseBase
	User *User `json:"user"`
}

type PostResponse

type PostResponse struct {
	myhttp.ResponseBase
	User *User `json:"user"`
}

type PutResponse

type PutResponse struct {
	myhttp.ResponseBase
	User *User `json:"user"`
}

type User

type User struct {
	Id         int          `json:"id"`
	GivenName  string       `json:"given_name"`
	FamilyName string       `json:"family_name"`
	Email      string       `json:"email"`
	Password   string       `json:"password"`
	CreatedAt  time.Time    `json:"createdat"`
	UpdatedAt  sql.NullTime `json:"updatedat"`
}

func NewUser

func NewUser(
	id int,
	givenName string,
	familyName string,
	email string,
	password string,
	createdAt time.Time,
	updatedAt sql.NullTime,
) User

func (*User) FullName

func (u *User) FullName() string

type UserRepository

type UserRepository struct {
}

func (*UserRepository) Create

func (r *UserRepository) Create(ctx context.Context, u *User) (int, error)

func (*UserRepository) CreateTx

func (r *UserRepository) CreateTx(ctx context.Context, tx *sql.Tx, u *User) (int, error)

func (*UserRepository) Delete

func (r *UserRepository) Delete(ctx context.Context, id int) error

func (*UserRepository) Find

func (r *UserRepository) Find(ctx context.Context, id int) (*User, error)

func (*UserRepository) FindAll

func (r *UserRepository) FindAll(ctx context.Context) ([]User, error)

func (*UserRepository) FindByEmail

func (r *UserRepository) FindByEmail(ctx context.Context, email string) (*User, error)

func (*UserRepository) FindByEmailTx

func (r *UserRepository) FindByEmailTx(ctx context.Context, tx *sql.Tx, email string) (*User, error)

func (*UserRepository) Update

func (r *UserRepository) Update(ctx context.Context, u *User) error

type UserService

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

func (*UserService) Delete

func (s *UserService) Delete(ctx context.Context, id int) error

func (*UserService) Get

func (s *UserService) Get(ctx context.Context, id int) (*User, error)

func (*UserService) GetAll

func (s *UserService) GetAll(ctx context.Context) ([]User, error)

func (*UserService) Post

func (s *UserService) Post(ctx context.Context, u *User) (int, error)

func (*UserService) Update

func (s *UserService) Update(ctx context.Context, u *User) error

Jump to

Keyboard shortcuts

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