Selaa lähdekoodia

聊天增加接口

wfz 2 vuotta sitten
vanhempi
commit
e8ea16e66d
5 muutettua tiedostoa jossa 841 lisäystä ja 485 poistoa
  1. 505 484
      api/chat/chat.pb.go
  2. 22 1
      api/chat/chat.proto
  3. 114 0
      api/chat/chat_grpc.pb.go
  4. 175 0
      api/chat/chat_http.pb.go
  5. 25 0
      js/api/chat/chat_http_pb.ts

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 505 - 484
api/chat/chat.pb.go


+ 22 - 1
api/chat/chat.proto

@@ -2,7 +2,7 @@ syntax = "proto3";
 
 package api.chat;
 
-//import "google/api/annotations.proto";
+import "google/api/annotations.proto";
 //import "google/protobuf/struct.proto";
 import "google/protobuf/empty.proto";
 import "api/common/common.proto";
@@ -102,6 +102,27 @@ service Chat {
   rpc DeleteScripByPersonID (common.PersonIDParam) returns (google.protobuf.Empty){};
   // 发送消息
   rpc SendMessage (SendMessageRequest) returns (common.SendMessageReply){};
+  // 发送消息 new
+  rpc Send (common.SendMessageRequest) returns (common.SendMessageReply){
+    option (google.api.http) = {
+      post: "/api/chat/send",
+      body:"*"
+    };
+  };
+  // 获取到后将对应数据变为已读
+  rpc GetIsRead (common.ChatIsReadInfo) returns (google.protobuf.Empty){
+    option (google.api.http) = {
+      post: "/api/chat/read",
+      body:"*"
+    };
+  };
+  // 用户进入房间
+  rpc GotoRoom (common.GoToRoom) returns (google.protobuf.Empty){
+    option (google.api.http) = {
+      post: "/api/chat/room/goto",
+      body:"*"
+    };
+  };
 }
 
 message SendMessageRequest{

+ 114 - 0
api/chat/chat_grpc.pb.go

@@ -110,6 +110,12 @@ type ChatClient interface {
 	DeleteScripByPersonID(ctx context.Context, in *common.PersonIDParam, opts ...grpc.CallOption) (*emptypb.Empty, error)
 	// 发送消息
 	SendMessage(ctx context.Context, in *SendMessageRequest, opts ...grpc.CallOption) (*common.SendMessageReply, error)
+	// 发送消息 new
+	Send(ctx context.Context, in *common.SendMessageRequest, opts ...grpc.CallOption) (*common.SendMessageReply, error)
+	// 获取到后将对应数据变为已读
+	GetIsRead(ctx context.Context, in *common.ChatIsReadInfo, opts ...grpc.CallOption) (*emptypb.Empty, error)
+	// 用户进入房间
+	GotoRoom(ctx context.Context, in *common.GoToRoom, opts ...grpc.CallOption) (*emptypb.Empty, error)
 }
 
 type chatClient struct {
@@ -525,6 +531,33 @@ func (c *chatClient) SendMessage(ctx context.Context, in *SendMessageRequest, op
 	return out, nil
 }
 
+func (c *chatClient) Send(ctx context.Context, in *common.SendMessageRequest, opts ...grpc.CallOption) (*common.SendMessageReply, error) {
+	out := new(common.SendMessageReply)
+	err := c.cc.Invoke(ctx, "/api.chat.Chat/Send", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *chatClient) GetIsRead(ctx context.Context, in *common.ChatIsReadInfo, opts ...grpc.CallOption) (*emptypb.Empty, error) {
+	out := new(emptypb.Empty)
+	err := c.cc.Invoke(ctx, "/api.chat.Chat/GetIsRead", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *chatClient) GotoRoom(ctx context.Context, in *common.GoToRoom, opts ...grpc.CallOption) (*emptypb.Empty, error) {
+	out := new(emptypb.Empty)
+	err := c.cc.Invoke(ctx, "/api.chat.Chat/GotoRoom", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // ChatServer is the server API for Chat service.
 // All implementations must embed UnimplementedChatServer
 // for forward compatibility
@@ -619,6 +652,12 @@ type ChatServer interface {
 	DeleteScripByPersonID(context.Context, *common.PersonIDParam) (*emptypb.Empty, error)
 	// 发送消息
 	SendMessage(context.Context, *SendMessageRequest) (*common.SendMessageReply, error)
+	// 发送消息 new
+	Send(context.Context, *common.SendMessageRequest) (*common.SendMessageReply, error)
+	// 获取到后将对应数据变为已读
+	GetIsRead(context.Context, *common.ChatIsReadInfo) (*emptypb.Empty, error)
+	// 用户进入房间
+	GotoRoom(context.Context, *common.GoToRoom) (*emptypb.Empty, error)
 	mustEmbedUnimplementedChatServer()
 }
 
@@ -761,6 +800,15 @@ func (UnimplementedChatServer) DeleteScripByPersonID(context.Context, *common.Pe
 func (UnimplementedChatServer) SendMessage(context.Context, *SendMessageRequest) (*common.SendMessageReply, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method SendMessage not implemented")
 }
+func (UnimplementedChatServer) Send(context.Context, *common.SendMessageRequest) (*common.SendMessageReply, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method Send not implemented")
+}
+func (UnimplementedChatServer) GetIsRead(context.Context, *common.ChatIsReadInfo) (*emptypb.Empty, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetIsRead not implemented")
+}
+func (UnimplementedChatServer) GotoRoom(context.Context, *common.GoToRoom) (*emptypb.Empty, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GotoRoom not implemented")
+}
 func (UnimplementedChatServer) mustEmbedUnimplementedChatServer() {}
 
 // UnsafeChatServer may be embedded to opt out of forward compatibility for this service.
@@ -1584,6 +1632,60 @@ func _Chat_SendMessage_Handler(srv interface{}, ctx context.Context, dec func(in
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Chat_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(common.SendMessageRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ChatServer).Send(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/api.chat.Chat/Send",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ChatServer).Send(ctx, req.(*common.SendMessageRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Chat_GetIsRead_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(common.ChatIsReadInfo)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ChatServer).GetIsRead(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/api.chat.Chat/GetIsRead",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ChatServer).GetIsRead(ctx, req.(*common.ChatIsReadInfo))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Chat_GotoRoom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(common.GoToRoom)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ChatServer).GotoRoom(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/api.chat.Chat/GotoRoom",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ChatServer).GotoRoom(ctx, req.(*common.GoToRoom))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // Chat_ServiceDesc is the grpc.ServiceDesc for Chat service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -1771,6 +1873,18 @@ var Chat_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "SendMessage",
 			Handler:    _Chat_SendMessage_Handler,
 		},
+		{
+			MethodName: "Send",
+			Handler:    _Chat_Send_Handler,
+		},
+		{
+			MethodName: "GetIsRead",
+			Handler:    _Chat_GetIsRead_Handler,
+		},
+		{
+			MethodName: "GotoRoom",
+			Handler:    _Chat_GotoRoom_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "chat.proto",

+ 175 - 0
api/chat/chat_http.pb.go

@@ -0,0 +1,175 @@
+// Code generated by protoc-gen-go-http. DO NOT EDIT.
+// versions:
+// protoc-gen-go-http v2.0.0
+
+package chat
+
+import (
+	context "context"
+	base "git.ikuban.com/server/base-protobuf/kuban/api/base"
+	reply "git.ikuban.com/server/kratos-utils/http/reply"
+	common "git.ikuban.com/server/pw-protobuf/api/common"
+	http "github.com/go-kratos/kratos/v2/transport/http"
+	binding "github.com/go-kratos/kratos/v2/transport/http/binding"
+	emptypb "google.golang.org/protobuf/types/known/emptypb"
+	ioutil "io/ioutil"
+	time "time"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the kratos package it is being compiled against.
+var _ = new(context.Context)
+var _ = binding.EncodeURL
+var _ = ioutil.Discard
+var _ = new(time.Time)
+var _ = new(reply.SuccessReply)
+var _ = new(base.Html)
+
+const _ = http.SupportPackageIsVersion1
+
+type ChatHTTPServer interface {
+	GetIsRead(context.Context, *common.ChatIsReadInfo) (*emptypb.Empty, error)
+	GotoRoom(context.Context, *common.GoToRoom) (*emptypb.Empty, error)
+	Send(context.Context, *common.SendMessageRequest) (*common.SendMessageReply, error)
+}
+
+func RegisterChatHTTPServer(s *http.Server, srv ChatHTTPServer) {
+	r := s.Route("/")
+	r.POST("/api/chat/send", _Chat_Send0_HTTP_Handler(srv))
+	r.POST("/api/chat/read", _Chat_GetIsRead0_HTTP_Handler(srv))
+	r.POST("/api/chat/room/goto", _Chat_GotoRoom0_HTTP_Handler(srv))
+}
+
+func _Chat_Send0_HTTP_Handler(srv ChatHTTPServer) func(ctx http.Context) error {
+	return func(ctx http.Context) error {
+		var in common.SendMessageRequest
+		if err := ctx.Bind(&in); err != nil {
+			return err
+		}
+		if err := ctx.BindQuery(&in); err != nil {
+			return err
+		}
+		http.SetOperation(ctx, "/api.chat.Chat/Send")
+		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
+			return srv.Send(ctx, req.(*common.SendMessageRequest))
+		})
+		out, err := h(ctx, &in)
+		if err != nil {
+			return err
+		}
+		success := &reply.SuccessReply{
+			Code: 0,
+		}
+		if out != nil {
+			success.Data = out
+		}
+		return ctx.Result(200, success)
+	}
+}
+
+func _Chat_GetIsRead0_HTTP_Handler(srv ChatHTTPServer) func(ctx http.Context) error {
+	return func(ctx http.Context) error {
+		var in common.ChatIsReadInfo
+		if err := ctx.Bind(&in); err != nil {
+			return err
+		}
+		if err := ctx.BindQuery(&in); err != nil {
+			return err
+		}
+		http.SetOperation(ctx, "/api.chat.Chat/GetIsRead")
+		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
+			return srv.GetIsRead(ctx, req.(*common.ChatIsReadInfo))
+		})
+		out, err := h(ctx, &in)
+		if err != nil {
+			return err
+		}
+		success := &reply.SuccessReply{
+			Code: 0,
+		}
+		if out != nil {
+			success.Data = out
+		}
+		return ctx.Result(200, success)
+	}
+}
+
+func _Chat_GotoRoom0_HTTP_Handler(srv ChatHTTPServer) func(ctx http.Context) error {
+	return func(ctx http.Context) error {
+		var in common.GoToRoom
+		if err := ctx.Bind(&in); err != nil {
+			return err
+		}
+		if err := ctx.BindQuery(&in); err != nil {
+			return err
+		}
+		http.SetOperation(ctx, "/api.chat.Chat/GotoRoom")
+		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
+			return srv.GotoRoom(ctx, req.(*common.GoToRoom))
+		})
+		out, err := h(ctx, &in)
+		if err != nil {
+			return err
+		}
+		success := &reply.SuccessReply{
+			Code: 0,
+		}
+		if out != nil {
+			success.Data = out
+		}
+		return ctx.Result(200, success)
+	}
+}
+
+type ChatHTTPClient interface {
+	GetIsRead(ctx context.Context, req *common.ChatIsReadInfo, opts ...http.CallOption) (rsp *emptypb.Empty, err error)
+	GotoRoom(ctx context.Context, req *common.GoToRoom, opts ...http.CallOption) (rsp *emptypb.Empty, err error)
+	Send(ctx context.Context, req *common.SendMessageRequest, opts ...http.CallOption) (rsp *common.SendMessageReply, err error)
+}
+
+type ChatHTTPClientImpl struct {
+	cc *http.Client
+}
+
+func NewChatHTTPClient(client *http.Client) ChatHTTPClient {
+	return &ChatHTTPClientImpl{client}
+}
+
+func (c *ChatHTTPClientImpl) GetIsRead(ctx context.Context, in *common.ChatIsReadInfo, opts ...http.CallOption) (*emptypb.Empty, error) {
+	var out emptypb.Empty
+	pattern := "/api/chat/read"
+	path := binding.EncodeURL(pattern, in, false)
+	opts = append(opts, http.Operation("/api.chat.Chat/GetIsRead"))
+	opts = append(opts, http.PathTemplate(pattern))
+	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return &out, err
+}
+
+func (c *ChatHTTPClientImpl) GotoRoom(ctx context.Context, in *common.GoToRoom, opts ...http.CallOption) (*emptypb.Empty, error) {
+	var out emptypb.Empty
+	pattern := "/api/chat/room/goto"
+	path := binding.EncodeURL(pattern, in, false)
+	opts = append(opts, http.Operation("/api.chat.Chat/GotoRoom"))
+	opts = append(opts, http.PathTemplate(pattern))
+	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return &out, err
+}
+
+func (c *ChatHTTPClientImpl) Send(ctx context.Context, in *common.SendMessageRequest, opts ...http.CallOption) (*common.SendMessageReply, error) {
+	var out common.SendMessageReply
+	pattern := "/api/chat/send"
+	path := binding.EncodeURL(pattern, in, false)
+	opts = append(opts, http.Operation("/api.chat.Chat/Send"))
+	opts = append(opts, http.PathTemplate(pattern))
+	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return &out, err
+}

+ 25 - 0
js/api/chat/chat_http_pb.ts

@@ -0,0 +1,25 @@
+// @ts-ignore
+import request from '@/libs/request';
+import {UserIDsParam,ListPageAndPersonRequest,RecommendPersonListReply,ChatRecordListReply,ChatRoomMsg,ReportRequest,RoomChatMsg,CreateScripRequest,ScripID,DeleteScripRequest,FindScripRequest,ScripReply,FindOtherScripRequest,PersonLookScripRequest,PersonParam,ScripInfo,ReplyScripRequest,ChatRecordInfo,MatchingRequest,GetMatchingPartnerInfoReply,RoomIDRequest,PersonIDParam,ManagerFindRoomListRequest,ManagerFindRoomListReply,ManagerFindChatRecordListRequest,ManagerFindScripListRequest,ManagerScripReply,ManagerUpdateScripTextRequest,ManagerUpdateScripPictureRequest,IDParam,ManagerFindReportListRequest,ManagerFindReportListReply,ManagerFindReportDetailsListRequest,ManagerFindReportDetailsListReply,SendMessageReply,SendMessageRequest,ChatIsReadInfo,GoToRoom} from "../common/common_pb";
+import {CheckUserPartnerIsRelationshipReply,CreateChatRoomParam,RoomReply,FindRecommendPersonListRequest,PartnerFindRoomListRequest,PartnerFindRoomListReply,UserFindRoomListRequest,UserFindRoomListReply,ReceiveRequest,ReceiveReply,FindChatRecordListRequest,FindChatRoomMsgRequest,SetBlackChatParam,FindRoomCardMsgRequest,WindowInfo,GetRandomMatchingReply,GetMatchingPartnerInfoRequest,AccurateMatchingUserInfoRequest,PartnerCollectIDsRequest,PartnerCollectRequest,UserUnlockRequest,GetRoomProfitReply,GetOnlinePersonNumReply,UnreadNumReply,UserRoomInfo,UserSuperLoveInfo,SendMessageRequest} from "./chat_pb";
+
+const ChatService = {
+  /**  发送消息 new */
+  Send: async (req?: SendMessageRequest) => {
+	const res = await request.post<{ data: SendMessageReply, code: string, message: string }>('/api/chat/send', req);
+    return res.data.data;
+  },
+  /**  获取到后将对应数据变为已读 */
+  GetIsRead: async (req?: ChatIsReadInfo) => {
+	const res = await request.post('/api/chat/read', req);
+    return res.data.data;
+  },
+  /**  用户进入房间 */
+  GotoRoom: async (req?: GoToRoom) => {
+	const res = await request.post('/api/chat/room/goto', req);
+    return res.data.data;
+  },
+
+};
+
+export default ChatService;

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä