98f581ec97
- Updated cursor rules to emphasize the importance of dependency injection and logging practices. - Introduced a new user management domain, including entities, services, handlers, and validation. - Implemented user authentication features such as login, registration, and role-based access control. - Added Redis integration for token management and caching. - Enhanced API documentation with Swagger for user-related endpoints. - Updated configuration to support new JWT settings and Redis connection parameters.
36 lines
910 B
Go
36 lines
910 B
Go
package user
|
|
|
|
// ValidationService defines validation methods for user operations
|
|
type ValidationService interface {
|
|
IsValidRole(role UserRole) bool
|
|
IsValidStatus(status UserStatus) bool
|
|
}
|
|
|
|
// validationService implements the ValidationService interface
|
|
type validationService struct{}
|
|
|
|
// NewValidationService creates a new validation service
|
|
func NewValidationService() ValidationService {
|
|
return &validationService{}
|
|
}
|
|
|
|
// IsValidRole checks if a user role is valid
|
|
func (v *validationService) IsValidRole(role UserRole) bool {
|
|
switch role {
|
|
case UserRoleAdmin, UserRoleManager, UserRoleOperator, UserRoleViewer:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
// IsValidStatus checks if a user status is valid
|
|
func (v *validationService) IsValidStatus(status UserStatus) bool {
|
|
switch status {
|
|
case UserStatusActive, UserStatusInactive, UserStatusSuspended:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|