39 lines
1.3 KiB
Go

package user
import (
"context"
)
// Repository định nghĩa các phương thức làm việc với dữ liệu người dùng
type Repository interface {
// Create tạo mới người dùng
Create(ctx context.Context, user *User) error
// GetByID lấy thông tin người dùng theo ID
GetByID(ctx context.Context, id string) (*User, error)
// GetByUsername lấy thông tin người dùng theo tên đăng nhập
GetByUsername(ctx context.Context, username string) (*User, error)
// GetByEmail lấy thông tin người dùng theo email
GetByEmail(ctx context.Context, email string) (*User, error)
// Update cập nhật thông tin người dùng
Update(ctx context.Context, user *User) error
// Delete xóa người dùng
Delete(ctx context.Context, id string) error
// AddRole thêm vai trò cho người dùng
AddRole(ctx context.Context, userID string, roleID int) error
// RemoveRole xóa vai trò của người dùng
RemoveRole(ctx context.Context, userID string, roleID int) error
// HasRole kiểm tra người dùng có vai trò không
HasRole(ctx context.Context, userID string, roleID int) (bool, error)
// UpdateLastLogin cập nhật thời gian đăng nhập cuối cùng
UpdateLastLogin(ctx context.Context, userID string) error
}