user

package
v0.0.0-...-42c4776 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: Apache-2.0 Imports: 18 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,
	{Path: "/api/v1/usertokens", Method: "POST", NeedAuth: false}:               utc.post,
	{Path: "/api/v1/users/:user_id/categories", Method: "GET", NeedAuth: true}:  ucc.getAll,
	{Path: "/api/v1/users/:user_id/categories", Method: "POST", NeedAuth: true}: ucc.post,
}

Functions

func NewResponseUser

func NewResponseUser(userId int, givenName, familyName, email string) *responseUser

func NewResponseUserCategories

func NewResponseUserCategories(models []UserCategory) []responseUserCategory

func NewResponseUserCategory

func NewResponseUserCategory(id, number int, name string, colorId int) *responseUserCategory

func NewResponseUsers

func NewResponseUsers(models []User) []responseUser

Types

type DeleteResponse

type DeleteResponse struct {
	myhttp.ResponseBase
}

type GetAllResponse

type GetAllResponse struct {
	myhttp.ResponseBase
	Users []responseUser `json:"users"`
}

type GetAllUserCategoryResponse

type GetAllUserCategoryResponse struct {
	*myhttp.ResponseBase
	Categories []responseUserCategory `json:"categories"`
}

func NewGetAllUserCategoryResponse

func NewGetAllUserCategoryResponse(res *myhttp.ResponseBase, categories []responseUserCategory) *GetAllUserCategoryResponse

type GetResponse

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

type PostResponse

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

type PostUserCategoryResponse

type PostUserCategoryResponse struct {
	*myhttp.ResponseBase
	Category *responseUserCategory `json:"category"`
}

func NewPostUserCategoryResponse

func NewPostUserCategoryResponse(res *myhttp.ResponseBase, category *responseUserCategory) *PostUserCategoryResponse

type PostUserTokenResponse

type PostUserTokenResponse struct {
	*myhttp.ResponseBase
	*UserToken
}

func NewPostUserTokenResponse

func NewPostUserTokenResponse(res *myhttp.ResponseBase, usertoken *UserToken) *PostUserTokenResponse

type PutResponse

type PutResponse struct {
	myhttp.ResponseBase
	User *responseUser `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 UserCategory

type UserCategory struct {
	Id        int          `json:"id"`
	Number    int          `json:"number"`
	Name      string       `json:"name"`
	ColorId   int          `json:"color_id"`
	UserId    int          `json:"user_id"`
	CreatedAt time.Time    `json:"createdat"`
	UpdatedAt sql.NullTime `json:"updatedat"`
}

func NewUserCategory

func NewUserCategory(
	id int,
	number int,
	name string,
	colorId int,
	userId int,
	createdAt time.Time,
	updatedAt sql.NullTime,
) *UserCategory

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) FindByIdentifier

func (r *UserRepository) FindByIdentifier(ctx context.Context, identifier string, password 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
}

User

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) (*responseUser, error)

func (*UserService) GetAll

func (s *UserService) GetAll(ctx context.Context) ([]responseUser, 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

type UserToken

type UserToken struct {
	Id        int          `json:"id"`
	UserId    int          `json:"user_id"`
	Token     string       `json:"token"`
	ExpiredAt time.Time    `json:"expiredat"`
	CreatedAt time.Time    `json:"createdat"`
	UpdatedAt sql.NullTime `json:"updatedat"`
}

func NewUserToken

func NewUserToken(
	id int,
	userId int,
	token string,
	expiredAt time.Time,
	createdAt time.Time,
	updatedAt sql.NullTime,
) UserToken

type UserTokenRepository

type UserTokenRepository struct {
}

func (*UserTokenRepository) Create

func (r *UserTokenRepository) Create(ctx context.Context, m *UserToken) (int, error)

UserTokenRepository

type UserTokenRequest

type UserTokenRequest struct {
	Identifier string `json:"identifier"`
	Secret     string `json:"secret"`
}

UserToken

func NewUserTokenRequest

func NewUserTokenRequest(
	identifier string,
	secret string,
) UserTokenRequest

Jump to

Keyboard shortcuts

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