repository

package
v0.0.0-...-256c714 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmailExists = errors.New("email already exists")
View Source
var ErrEmailNotFound = errors.New("email not found")
View Source
var ErrEmptyFields = errors.New("all fields are empty")
View Source
var ErrEmptySomeFields = errors.New("some fields are empty")
View Source
var ErrUserEqualsFriend = errors.New("user cannot be friend to himself")
View Source
var ErrUserExists = errors.New("user already exists")
View Source
var ErrUserNotFound = errors.New("user not found")

Functions

This section is empty.

Types

type FriendRepository

type FriendRepository interface {
	// AddFriend создает новую связь дружбы между двумя пользователями.
	AddFriend(ctx context.Context, friendship *model.Friendship) error

	// RemoveFriend удаляет существующую связь дружбы между двумя пользователями.
	RemoveFriend(ctx context.Context, friendship *model.Friendship) error

	// GetFriends возвращает список пользователей, являющихся друзьями указанного пользователя.
	GetFriends(ctx context.Context, user int64) ([]model.User, error)
}

FriendRepository определяет контракт для работы с дружескими связями между пользователями. Интерфейс может быть реализован с использованием любой СУБД или подхода к хранению данных.

type GormFriendRepository

type GormFriendRepository struct {
	DB *gorm.DB
}

GormFriendRepository — реализация FriendRepository на базе GORM ORM.

func NewGormFriendRepository

func NewGormFriendRepository(db *gorm.DB) *GormFriendRepository

NewGormFriendRepository создает новый экземпляр GormFriendRepository с переданной GORM-базой данных.

func (*GormFriendRepository) AddFriend

func (r *GormFriendRepository) AddFriend(ctx context.Context, friendship *model.Friendship) error

func (*GormFriendRepository) GetFriends

func (r *GormFriendRepository) GetFriends(ctx context.Context, user int64) ([]model.User, error)

func (*GormFriendRepository) RemoveFriend

func (r *GormFriendRepository) RemoveFriend(ctx context.Context, friendship *model.Friendship) error

type GormUserRepository

type GormUserRepository struct {
	DB *gorm.DB
}

func NewGormUserRepository

func NewGormUserRepository(db *gorm.DB) *GormUserRepository

func (*GormUserRepository) CheckIfExistsByEmail

func (r *GormUserRepository) CheckIfExistsByEmail(email string, ctx context.Context) error

func (*GormUserRepository) CheckIfExistsByID

func (r *GormUserRepository) CheckIfExistsByID(id int64, ctx context.Context) error

func (*GormUserRepository) CreateUser

func (r *GormUserRepository) CreateUser(user *model.User, ctx context.Context) error

func (*GormUserRepository) DeleteUser

func (r *GormUserRepository) DeleteUser(id int64, ctx context.Context) (int64, error)

func (*GormUserRepository) GetUserByID

func (r *GormUserRepository) GetUserByID(id int64, ctx context.Context) (*model.User, error)

func (*GormUserRepository) ListUsers

func (r *GormUserRepository) ListUsers(ctx context.Context) ([]model.User, error)

func (*GormUserRepository) UpdateUser

func (r *GormUserRepository) UpdateUser(user *model.User, ctx context.Context) error

type UserRepository

type UserRepository interface {
	CreateUser(user *model.User, ctx context.Context) error
	GetUserByID(id int64, ctx context.Context) (*model.User, error)
	ListUsers(ctx context.Context) ([]model.User, error)
	DeleteUser(id int64, ctx context.Context) (int64, error)
	UpdateUser(user *model.User, ctx context.Context) error

	CheckIfExistsByID(id int64, ctx context.Context) error
	CheckIfExistsByEmail(email string, ctx context.Context) error
}

Jump to

Keyboard shortcuts

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