package server

import (
	"context"

	"juwan-backend/app/chat/rpc/internal/logic"
	"juwan-backend/app/chat/rpc/internal/svc"
	"juwan-backend/app/chat/rpc/pb"
)

type ChatServiceServer struct {
	svcCtx *svc.ServiceContext
	pb.UnimplementedChatServiceServer
}

func NewChatServiceServer(svcCtx *svc.ServiceContext) *ChatServiceServer {
	return &ChatServiceServer{
		svcCtx: svcCtx,
	}
}

func (s *ChatServiceServer) AddChatSessions(ctx context.Context, in *pb.AddChatSessionsReq) (*pb.AddChatSessionsResp, error) {
	l := logic.NewAddChatSessionsLogic(ctx, s.svcCtx)
	return l.AddChatSessions(in)
}

func (s *ChatServiceServer) UpdateChatSessions(ctx context.Context, in *pb.UpdateChatSessionsReq) (*pb.UpdateChatSessionsResp, error) {
	l := logic.NewUpdateChatSessionsLogic(ctx, s.svcCtx)
	return l.UpdateChatSessions(in)
}

func (s *ChatServiceServer) DelChatSessions(ctx context.Context, in *pb.DelChatSessionsReq) (*pb.DelChatSessionsResp, error) {
	l := logic.NewDelChatSessionsLogic(ctx, s.svcCtx)
	return l.DelChatSessions(in)
}

func (s *ChatServiceServer) GetChatSessionsById(ctx context.Context, in *pb.GetChatSessionsByIdReq) (*pb.GetChatSessionsByIdResp, error) {
	l := logic.NewGetChatSessionsByIdLogic(ctx, s.svcCtx)
	return l.GetChatSessionsById(in)
}

func (s *ChatServiceServer) SearchChatSessions(ctx context.Context, in *pb.SearchChatSessionsReq) (*pb.SearchChatSessionsResp, error) {
	l := logic.NewSearchChatSessionsLogic(ctx, s.svcCtx)
	return l.SearchChatSessions(in)
}

func (s *ChatServiceServer) AddParticipant(ctx context.Context, in *pb.AddParticipantReq) (*pb.AddParticipantResp, error) {
	l := logic.NewAddParticipantLogic(ctx, s.svcCtx)
	return l.AddParticipant(in)
}

func (s *ChatServiceServer) RemoveParticipant(ctx context.Context, in *pb.RemoveParticipantReq) (*pb.RemoveParticipantResp, error) {
	l := logic.NewRemoveParticipantLogic(ctx, s.svcCtx)
	return l.RemoveParticipant(in)
}

func (s *ChatServiceServer) AddChatMessages(ctx context.Context, in *pb.AddChatMessagesReq) (*pb.AddChatMessagesResp, error) {
	l := logic.NewAddChatMessagesLogic(ctx, s.svcCtx)
	return l.AddChatMessages(in)
}

func (s *ChatServiceServer) DelChatMessages(ctx context.Context, in *pb.DelChatMessagesReq) (*pb.DelChatMessagesResp, error) {
	l := logic.NewDelChatMessagesLogic(ctx, s.svcCtx)
	return l.DelChatMessages(in)
}

func (s *ChatServiceServer) GetChatMessagesById(ctx context.Context, in *pb.GetChatMessagesByIdReq) (*pb.GetChatMessagesByIdResp, error) {
	l := logic.NewGetChatMessagesByIdLogic(ctx, s.svcCtx)
	return l.GetChatMessagesById(in)
}

func (s *ChatServiceServer) SearchChatMessages(ctx context.Context, in *pb.SearchChatMessagesReq) (*pb.SearchChatMessagesResp, error) {
	l := logic.NewSearchChatMessagesLogic(ctx, s.svcCtx)
	return l.SearchChatMessages(in)
}
