浏览代码

wip:生代码

fuwencai 2 年之前
父节点
当前提交
c2cf79590d

+ 29 - 0
api/internal/handler/getbuoymsghandler.go

@@ -0,0 +1,29 @@
+package handler
+
+import (
+	"net/http"
+
+	"app.yhyue.com/moapp/MessageCenter/api/internal/logic"
+	"app.yhyue.com/moapp/MessageCenter/api/internal/svc"
+	"app.yhyue.com/moapp/MessageCenter/api/internal/types"
+
+	"github.com/tal-tech/go-zero/rest/httpx"
+)
+
+func GetBuoyMsgHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.GetBuoyMsgReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewGetBuoyMsgLogic(r.Context(), ctx)
+		resp, err := l.GetBuoyMsg(req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 5 - 0
api/internal/handler/routes.go

@@ -67,6 +67,11 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/messageCenter/MultipleSaveMsg",
 				Handler: MultipleSaveMsgHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/messageCenter/GetBuoyMsg",
+				Handler: GetBuoyMsgHandler(serverCtx),
+			},
 		},
 	)
 }

+ 30 - 0
api/internal/logic/getbuoymsglogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/MessageCenter/api/internal/svc"
+	"app.yhyue.com/moapp/MessageCenter/api/internal/types"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type GetBuoyMsgLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetBuoyMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetBuoyMsgLogic {
+	return GetBuoyMsgLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GetBuoyMsgLogic) GetBuoyMsg(req types.GetBuoyMsgReq) (*types.GetBuoyMsgResp, error) {
+	// todo: add your logic here and delete this line
+
+	return &types.GetBuoyMsgResp{}, nil
+}

+ 11 - 0
api/internal/types/types.go

@@ -137,3 +137,14 @@ type MultipleSaveMsgResp struct {
 	Message  string `json:"message"`
 	ErrCount int64  `json:"errCount"`
 }
+
+type GetBuoyMsgReq struct {
+	UserId string `header:"userIds"`
+	Size   int64  `json:"size"`
+}
+
+type GetBuoyMsgResp struct {
+	Code    int64                    `json:"error_code"`
+	Message string                   `json:"error_msg"`
+	Data    []map[string]interface{} `json:"data"`
+}

+ 15 - 0
api/message.api

@@ -135,6 +135,17 @@ type MultipleSaveMsgResp {
 	ErrCount int64  `json:"errCount"`
 }
 
+type GetBuoyMsgReq {
+	UserId string `header:"userIds"`
+	Size   int64  `json:"size"`
+}
+
+type GetBuoyMsgResp {
+	Code    int64                    `json:"error_code"`
+	Message string                   `json:"error_msg"`
+	Data    []map[string]interface{} `json:"data"`
+}
+
 service message-api {
 	//删除消息
 	@handler MessageDeleteHandler // TODO: set handler name and delete this comment
@@ -170,4 +181,8 @@ service message-api {
 	// 发送消息
 	@handler MultipleSaveMsgHandler
 	post /messageCenter/MultipleSaveMsg (MultipleSaveMsgReq) returns (MultipleSaveMsgResp)
+	
+	// 查询浮标信息
+	@handler GetBuoyMsgHandler
+	post /messageCenter/GetBuoyMsg (GetBuoyMsgReq) returns (GetBuoyMsgResp)
 }

+ 10 - 0
api/test/tets.http

@@ -0,0 +1,10 @@
+POST http://192.168.3.206:8787/messageCenter/messageFind
+Content-Type: application/x-www-form-urlencoded
+
+userId=6103bb722abfa5f4d81bb1d1&appId=10000&receiveUserId=qmx&msgType=-1&isRead=-1&offset=1&pageSize=10
+
+###
+POST http://192.168.3.206:8787/messageCenter/messageFind
+Content-Type: application/x-www-form-urlencoded
+
+userId=629d5b09b8bd0060485a4650&appId=10000&receiveUserId=qmx&msgType=-1&isRead=-1&offset=1&pageSize=10