add: chat service
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
package chatservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"juwan-backend/app/chat/rpc/pb"
|
||||
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type (
|
||||
ChatSessions = pb.ChatSessions
|
||||
AddChatSessionsReq = pb.AddChatSessionsReq
|
||||
AddChatSessionsResp = pb.AddChatSessionsResp
|
||||
UpdateChatSessionsReq = pb.UpdateChatSessionsReq
|
||||
UpdateChatSessionsResp = pb.UpdateChatSessionsResp
|
||||
DelChatSessionsReq = pb.DelChatSessionsReq
|
||||
DelChatSessionsResp = pb.DelChatSessionsResp
|
||||
GetChatSessionsByIdReq = pb.GetChatSessionsByIdReq
|
||||
GetChatSessionsByIdResp = pb.GetChatSessionsByIdResp
|
||||
SearchChatSessionsReq = pb.SearchChatSessionsReq
|
||||
SearchChatSessionsResp = pb.SearchChatSessionsResp
|
||||
AddParticipantReq = pb.AddParticipantReq
|
||||
AddParticipantResp = pb.AddParticipantResp
|
||||
RemoveParticipantReq = pb.RemoveParticipantReq
|
||||
RemoveParticipantResp = pb.RemoveParticipantResp
|
||||
ChatMessages = pb.ChatMessages
|
||||
AddChatMessagesReq = pb.AddChatMessagesReq
|
||||
AddChatMessagesResp = pb.AddChatMessagesResp
|
||||
DelChatMessagesReq = pb.DelChatMessagesReq
|
||||
DelChatMessagesResp = pb.DelChatMessagesResp
|
||||
GetChatMessagesByIdReq = pb.GetChatMessagesByIdReq
|
||||
GetChatMessagesByIdResp = pb.GetChatMessagesByIdResp
|
||||
SearchChatMessagesReq = pb.SearchChatMessagesReq
|
||||
SearchChatMessagesResp = pb.SearchChatMessagesResp
|
||||
|
||||
ChatService interface {
|
||||
AddChatSessions(ctx context.Context, in *AddChatSessionsReq, opts ...grpc.CallOption) (*AddChatSessionsResp, error)
|
||||
UpdateChatSessions(ctx context.Context, in *UpdateChatSessionsReq, opts ...grpc.CallOption) (*UpdateChatSessionsResp, error)
|
||||
DelChatSessions(ctx context.Context, in *DelChatSessionsReq, opts ...grpc.CallOption) (*DelChatSessionsResp, error)
|
||||
GetChatSessionsById(ctx context.Context, in *GetChatSessionsByIdReq, opts ...grpc.CallOption) (*GetChatSessionsByIdResp, error)
|
||||
SearchChatSessions(ctx context.Context, in *SearchChatSessionsReq, opts ...grpc.CallOption) (*SearchChatSessionsResp, error)
|
||||
AddParticipant(ctx context.Context, in *AddParticipantReq, opts ...grpc.CallOption) (*AddParticipantResp, error)
|
||||
RemoveParticipant(ctx context.Context, in *RemoveParticipantReq, opts ...grpc.CallOption) (*RemoveParticipantResp, error)
|
||||
AddChatMessages(ctx context.Context, in *AddChatMessagesReq, opts ...grpc.CallOption) (*AddChatMessagesResp, error)
|
||||
DelChatMessages(ctx context.Context, in *DelChatMessagesReq, opts ...grpc.CallOption) (*DelChatMessagesResp, error)
|
||||
GetChatMessagesById(ctx context.Context, in *GetChatMessagesByIdReq, opts ...grpc.CallOption) (*GetChatMessagesByIdResp, error)
|
||||
SearchChatMessages(ctx context.Context, in *SearchChatMessagesReq, opts ...grpc.CallOption) (*SearchChatMessagesResp, error)
|
||||
}
|
||||
|
||||
defaultChatService struct {
|
||||
cli zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewChatService(cli zrpc.Client) ChatService {
|
||||
return &defaultChatService{cli: cli}
|
||||
}
|
||||
|
||||
func (m *defaultChatService) AddChatSessions(ctx context.Context, in *AddChatSessionsReq, opts ...grpc.CallOption) (*AddChatSessionsResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.AddChatSessions(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) UpdateChatSessions(ctx context.Context, in *UpdateChatSessionsReq, opts ...grpc.CallOption) (*UpdateChatSessionsResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.UpdateChatSessions(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) DelChatSessions(ctx context.Context, in *DelChatSessionsReq, opts ...grpc.CallOption) (*DelChatSessionsResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.DelChatSessions(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) GetChatSessionsById(ctx context.Context, in *GetChatSessionsByIdReq, opts ...grpc.CallOption) (*GetChatSessionsByIdResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.GetChatSessionsById(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) SearchChatSessions(ctx context.Context, in *SearchChatSessionsReq, opts ...grpc.CallOption) (*SearchChatSessionsResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.SearchChatSessions(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) AddParticipant(ctx context.Context, in *AddParticipantReq, opts ...grpc.CallOption) (*AddParticipantResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.AddParticipant(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) RemoveParticipant(ctx context.Context, in *RemoveParticipantReq, opts ...grpc.CallOption) (*RemoveParticipantResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.RemoveParticipant(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) AddChatMessages(ctx context.Context, in *AddChatMessagesReq, opts ...grpc.CallOption) (*AddChatMessagesResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.AddChatMessages(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) DelChatMessages(ctx context.Context, in *DelChatMessagesReq, opts ...grpc.CallOption) (*DelChatMessagesResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.DelChatMessages(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) GetChatMessagesById(ctx context.Context, in *GetChatMessagesByIdReq, opts ...grpc.CallOption) (*GetChatMessagesByIdResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.GetChatMessagesById(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultChatService) SearchChatMessages(ctx context.Context, in *SearchChatMessagesReq, opts ...grpc.CallOption) (*SearchChatMessagesResp, error) {
|
||||
client := pb.NewChatServiceClient(m.cli.Conn())
|
||||
return client.SearchChatMessages(ctx, in, opts...)
|
||||
}
|
||||
Reference in New Issue
Block a user