Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateCreateRequest ¶
func ValidateCreateRequest(c *usersProto.CreateUserRequest) error
ValidateCreateRequest validates the CreateUserRequest fields.
func ValidateUpdateRequest ¶
func ValidateUpdateRequest(u *usersProto.UpdateUserRequest) error
Validate validates the UpdateUserRequest fields.
Types ¶
type API ¶
type API interface { grpcgw.Controller users.UserServiceServer }
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, offset, limit int64) ([]entity.User, int, error) // Create saves a new user in the storage. Create(ctx context.Context, user entity.User) error // Update updates the user with given UUID in the storage. Update(ctx context.Context, user entity.User) error // Delete removes the user with given UUID from the storage. Delete(ctx context.Context, uuid string) error // Where returns the list of users with the given condition Where(ctx context.Context, condition string, params ...interface{}) ([]entity.User, int, error) // WhereOne returns the one of users with the given condition WhereOne(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) (*usersProto.User, error) Query(ctx context.Context, offset, limit int64) (*usersProto.ListUsersResponse, error) Count(ctx context.Context) (int64, error) Create(ctx context.Context, input *usersProto.CreateUserRequest) (*usersProto.User, error) Update(ctx context.Context, input *usersProto.UpdateUserRequest) (*usersProto.User, error) Delete(ctx context.Context, uuid string) (*usersProto.User, error) // GetByUsername returns the users if username found GetByUsername(ctx context.Context, username string) (*usersProto.User, error) }
Service encapsulates use case logic for users.
func NewServiceForTest ¶
func NewServiceForTest() Service
NewServiceForTest creates a new user service for test.
Click to show internal directories.
Click to hide internal directories.