package repository import ( "context" "time" "messenger/internal/models" ) type UserRepository interface { Create(ctx context.Context, user *models.User) error FindByID(ctx context.Context, id int64) (*models.User, error) FindByLogin(ctx context.Context, login string) (*models.User, error) SearchByLogin(ctx context.Context, query string, limit int) ([]*models.User, error) UpdateLastSeen(ctx context.Context, userID int64) error UpdateRole(ctx context.Context, userID int64, role models.UserRole) error Delete(ctx context.Context, userID int64) error Exists(ctx context.Context, login string) (bool, error) } type ProfileRepository interface { Create(ctx context.Context, profile *models.Profile) error FindByUserID(ctx context.Context, userID int64) (*models.Profile, error) Update(ctx context.Context, profile *models.Profile) error UpdateAvatar(ctx context.Context, userID int64, avatarURL *string) error } type ChatRepository interface { Create(ctx context.Context, chat *models.Chat) error FindByID(ctx context.Context, id int64) (*models.Chat, error) GetUserChats(ctx context.Context, userID int64) ([]*models.Chat, error) UpdateTitle(ctx context.Context, chatID int64, title string) error Delete(ctx context.Context, chatID int64) error // Member operations AddMember(ctx context.Context, chatID, userID int64, role models.MemberRole) error RemoveMember(ctx context.Context, chatID, userID int64) error GetMembers(ctx context.Context, chatID int64) ([]*models.ChatMember, error) GetMemberRole(ctx context.Context, chatID, userID int64) (*models.MemberRole, error) UpdateMemberRole(ctx context.Context, chatID, userID int64, role models.MemberRole) error IsMember(ctx context.Context, chatID, userID int64) (bool, error) // Private chat specific FindPrivateChat(ctx context.Context, userID1, userID2 int64) (*models.Chat, error) } type MessageRepository interface { Create(ctx context.Context, message *models.Message) error FindByID(ctx context.Context, id int64) (*models.Message, error) GetChatHistory(ctx context.Context, chatID int64, limit int, before time.Time) ([]*models.Message, error) GetLastMessage(ctx context.Context, chatID int64) (*models.Message, error) MarkAsRead(ctx context.Context, messageID int64) error Delete(ctx context.Context, messageID int64) error Update(ctx context.Context, message *models.Message) error GetUnreadCount(ctx context.Context, chatID, userID int64) (int, error) } type AttachmentRepository interface { Create(ctx context.Context, attachment *models.Attachment) error FindByID(ctx context.Context, id int64) (*models.Attachment, error) UpdateMessageID(ctx context.Context, attachmentID, messageID int64) error Delete(ctx context.Context, attachmentID int64) error GetByMessageID(ctx context.Context, messageID int64) (*models.Attachment, error) }