ulflow_phattt2901 f4ef71b63b
Some checks failed
CI Pipeline / Security Scan (push) Failing after 5m24s
CI Pipeline / Lint (push) Failing after 5m30s
CI Pipeline / Test (push) Has been skipped
CI Pipeline / Build (push) Has been skipped
CI Pipeline / Notification (push) Successful in 1s
feat: implement user authentication system with JWT and role-based access control
2025-05-24 11:24:19 +07:00

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
}