services

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserService

type UserService struct {
	DB *gorm.DB
}

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.

func (*UserService) Update

func (s *UserService) Update(id uint, updates map[string]interface{}) (*models.User, error)

Update updates a user's fields by ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL