Documentation ¶
Index ¶
- Variables
- type FindAllUsersParams
- type LoginParams
- type LoginResponse
- type Service
- func (s *Service) CreateUser(ctx context.Context, params *TransactionParams) (*Users, *types.Error)
- func (s *Service) GetByToken(ctx context.Context, token string) (*Users, *types.Error)
- func (s *Service) GetUser(ctx context.Context, userID int) (*Users, *types.Error)
- func (s *Service) ListUsers(ctx context.Context, params *FindAllUsersParams) ([]*Users, int, *types.Error)
- func (s *Service) Login(ctx context.Context, phone string, password string) (*LoginResponse, *types.Error)
- type ServiceInterface
- type Storage
- type TransactionParams
- type Users
- type VerifyParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWrongPassword = errors.New("wrong password") ErrWrongPhone = errors.New("wrong phone") ErrPhoneAlreadyExists = errors.New("Phone Already Exists") )
Errors
Functions ¶
This section is empty.
Types ¶
type FindAllUsersParams ¶
type FindAllUsersParams struct { ID int `json:"id"` Page int `json:"page"` Limit int `json:"limit"` Phone string `json:"phone"` Name string `json:"name"` Token string `json:"token"` }
FindAllUsersParams params for find all
type LoginParams ¶
LoginParams represent the http request data for login user
type LoginResponse ¶
type LoginResponse struct { SessionID string `json:"sessionId"` Claims interface{} `json:"claims"` }
LoginResponse represents the response of login function
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the domain logic implementation of user Service interface
func NewService ¶
NewService creates a new user AppService
func (*Service) CreateUser ¶
CreateUser create user
func (*Service) GetByToken ¶
GetByToken get user by its token
type ServiceInterface ¶
type ServiceInterface interface { ListUsers(ctx context.Context, params *FindAllUsersParams) ([]*Users, int, *types.Error) GetUser(ctx context.Context, userID int) (*Users, *types.Error) CreateUser(ctx context.Context, params *TransactionParams) (*Users, *types.Error) Login(ctx context.Context, phone string, password string) (*LoginResponse, *types.Error) GetByToken(ctx context.Context, token string) (*Users, *types.Error) }
ServiceInterface represents the user service interface
type Storage ¶
type Storage interface { FindAll(ctx context.Context, params *FindAllUsersParams) ([]*Users, *types.Error) FindByID(ctx context.Context, userID int) (*Users, *types.Error) FindByPhone(ctx context.Context, phone string) (*Users, *types.Error) FindByToken(ctx context.Context, token string) (*Users, *types.Error) Insert(ctx context.Context, user *Users) (*Users, *types.Error) Update(ctx context.Context, user *Users) (*Users, *types.Error) Delete(ctx context.Context, userID int) *types.Error }
Storage represents the user storage interface
type TransactionParams ¶
type TransactionParams struct { RoleID int `json:"roleId"` Name string `json:"name"` Phone string `json:"phone"` Password string }
TransactionParams params for transaction
type Users ¶
type Users struct { ID int `json:"id" db:"id"` RoleID int `json:"roleId" db:"roleId"` Name string `json:"name" db:"name"` Phone string `json:"phone" db:"phone"` Password string `json:"password" db:"password"` Token *string `json:"token" db:"token"` TokenExpiredAt *time.Time `json:"tokenExpiredAt" db:"tokenExpiredAt"` CreatedAt time.Time `json:"createdAt" db:"createdAt"` UpdatedAt *time.Time `json:"updatedAt" db:"updatedAt"` }
Users user
Click to show internal directories.
Click to hide internal directories.