user

package
v0.0.0-...-b1757e7 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 5 Imported by: 0

README

this package is for user management

Documentation

Index

Constants

View Source
const (
	AppName = "user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateUserRequest

type CreateUserRequest struct {
	Username string            `json:"username" gorm:"column:username"`
	Password string            `json:"password" gorm:"column:password"`
	Role     Role              `json:"role"`
	Label    map[string]string `json:"label" gorm:"serializer:json"`
	IsHashed bool              `json:"is_hashed" gorm:"column:is_hashed"`
}

func NewCreateUserRequest

func NewCreateUserRequest() *CreateUserRequest

func (*CreateUserRequest) PasswordHash

func (req *CreateUserRequest) PasswordHash()

func (*CreateUserRequest) Validate

func (req *CreateUserRequest) Validate() error

type DeleteUserRequest

type DeleteUserRequest struct {
	Id int64 `json:"id"`
}

type QueryBy

type QueryBy int
const (
	QUERY_BY_ID QueryBy = iota
	QUERY_BY_USERNAME
)

type QueryUserRequest

type QueryUserRequest struct {
	Queryby    QueryBy `json:"query_by"`
	QueryValue string  `json:"query_value"`
}

func NewQueryUserRequestById

func NewQueryUserRequestById(id string) *QueryUserRequest

func NewQueryUserRequestByUsername

func NewQueryUserRequestByUsername(username string) *QueryUserRequest

type Role

type Role int
const (
	ROLE_AUTHOR Role = iota
	ROLE_ADMIN
	ROLE_AUDITOR
)

type Service

type Service interface {
	CreateUser(context.Context, *CreateUserRequest) (*User, error)
	DeleteUser(context.Context, *DeleteUserRequest) error
	QueryUser(context.Context, *QueryUserRequest) (*User, error)
}

type User

type User struct {
	Id        int64 `json:"id"`
	CreatedAt int64 `json:"created_at"` //not datetime as it increases complexity (timezones, etc.)
	UpdatedAt int64 `json:"updated_at"`
	*CreateUserRequest
}

User represents the user entity

func NewUser

func NewUser(req *CreateUserRequest) *User

func (*User) String

func (u *User) String() string

func (*User) TableName

func (u *User) TableName() string

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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