Documentation
¶
Index ¶
- type UserService
- func (s *UserService) Create(name, email, password string) (*models.User, error)
- func (s *UserService) Delete(id uint) error
- func (s *UserService) GetByID(id uint) (*models.User, error)
- func (s *UserService) HardDelete(id uint) error
- func (s *UserService) Restore(id uint) error
- func (s *UserService) Update(id uint, updates map[string]interface{}) (*models.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UserService ¶
UserService handles business logic for user operations.
func NewUserService ¶
func NewUserService(db *gorm.DB) *UserService
NewUserService creates a new UserService with the given database connection.
func (*UserService) Create ¶
func (s *UserService) Create(name, email, password string) (*models.User, error)
Create creates a new user after checking for duplicate email.
func (*UserService) Delete ¶
func (s *UserService) Delete(id uint) error
Delete soft-deletes a user by ID (sets deleted_at timestamp).
func (*UserService) GetByID ¶
func (s *UserService) GetByID(id uint) (*models.User, error)
GetByID retrieves a user by their ID.
func (*UserService) HardDelete ¶
func (s *UserService) HardDelete(id uint) error
HardDelete permanently removes a user from the database. This bypasses soft delete and cannot be undone.
func (*UserService) Restore ¶
func (s *UserService) Restore(id uint) error
Restore recovers a soft-deleted user by clearing their deleted_at timestamp.
Click to show internal directories.
Click to hide internal directories.