Documentation ¶
Index ¶
- func NewMockRepository() *mockRepository
- func ValidateAddUserRoleRequest(c *auth.AddUserRoleRequest) error
- func ValidateCreateRequest(c *auth.CreateUserRequest) error
- func ValidateUpdateRequest(u *auth.UpdateUserRequest) error
- func ValidateUpdateUserRoleRequest(c *auth.UpdateUserRoleRequest) error
- type API
- type Repository
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMockRepository ¶
func NewMockRepository() *mockRepository
func ValidateAddUserRoleRequest ¶
func ValidateAddUserRoleRequest(c *auth.AddUserRoleRequest) error
ValidateAddUserRoleRequest validates the AddUserRoleRequest fields.
func ValidateCreateRequest ¶
func ValidateCreateRequest(c *auth.CreateUserRequest) error
ValidateCreateRequest validates the CreateUserRequest fields.
func ValidateUpdateRequest ¶
func ValidateUpdateRequest(u *auth.UpdateUserRequest) error
Validate validates the UpdateUserRequest fields.
func ValidateUpdateUserRoleRequest ¶
func ValidateUpdateUserRoleRequest(c *auth.UpdateUserRoleRequest) error
ValidateUpdateUserRoleRequest validates the AddUserRoleRequest fields.
Types ¶
type Repository ¶
type Repository interface { // Get returns the user with the specified user UUID. Get(ctx context.Context, Uuid string) (entity.User, error) // Count returns the number of users. Count(ctx context.Context) (int64, error) // Query returns the list of users with the given offset and limit. Query(ctx context.Context, query string, offset, limit int64) ([]entity.User, int, error) // Create saves a new user in the storage. Create(ctx context.Context, user entity.User) (string, error) // Update updates the user with given UUID in the storage. Update(ctx context.Context, user entity.User) error // Delete removes the user from the storage. Delete(ctx context.Context, user entity.User) error // AddUserRole add a role to user AddUserRole(ctx context.Context, userRole entity.UserRole) (string, error) // GetUserRole reads the user role with the specified ID from the database. GetUserRole(ctx context.Context, Uuid string) (entity.UserRole, error) // UpdateUserRole updates the user role UpdateUserRole(ctx context.Context, userRole entity.UserRole) error // DeleteUserRole delete the user role DeleteUserRole(ctx context.Context, userRole entity.UserRole) error // GetUserRole reads the user role with the specified ID from the database. AllUserRole(ctx context.Context) ([]entity.UserRole, error) // FindOne returns the one of users with the given condition FindOne(ctx context.Context, condition string, params ...interface{}) (entity.User, error) }
Repository encapsulates the logic to access users from the data source.
func NewRepository ¶
func NewRepository(db *db.DB) Repository
NewRepository creates a new user repository
type Service ¶
type Service interface { Get(ctx context.Context, Uuid string) (*auth.User, error) Query(ctx context.Context, query string, offset, limit int64) (*auth.ListUsersResponse, error) Count(ctx context.Context) (int64, error) Create(ctx context.Context, req *auth.CreateUserRequest) (*auth.User, error) Update(ctx context.Context, req *auth.UpdateUserRequest) (*auth.User, error) Delete(ctx context.Context, Uuid string) (*auth.User, error) // GetByUsername returns the users if username found GetByUsername(ctx context.Context, username string) (*auth.User, error) AddUserRole(ctx context.Context, req *auth.AddUserRoleRequest) (*auth.User, error) UpdateUserRole(ctx context.Context, req *auth.UpdateUserRoleRequest) (*auth.User, error) DeleteUserRole(ctx context.Context, req *auth.DeleteUserRoleRequest) (*auth.User, error) ListUserRoles(ctx context.Context) ([]entity.UserRole, error) }
Service encapsulates use case logic for users.
func NewService ¶
func NewService(repo Repository, domainsRepo domains.Repository, rolesRepo roles.Repository) Service
NewService creates a new user service.
Click to show internal directories.
Click to hide internal directories.