Browse Source

feat:分发接口添加

duxin 2 năm trước cách đây
mục cha
commit
6ecad02c10

+ 5 - 5
jyBXSubscribe/api/bxsubscribe.api

@@ -105,12 +105,12 @@ type (
 		UserType  string `path:"userType,optional"`
 		InfoId    string `json:"infoId,optional"`
 	}
-	msgDistributor{
+	msgDistributor {
 		AppId     string `header:"appId"`
 		EntId     string `header:"entId,optional"`
 		EntUserId string `header:"entUserId,optional"`
-		MessageId string  `json:"messageId"`
-		Staffs    string  `json:"staffs"`
+		MessageId string `json:"messageId"`
+		Staffs    string `json:"staffs"`
 	}
 )
 service bxsubscribe-api {
@@ -130,6 +130,6 @@ service bxsubscribe-api {
 	post /jybx/subscribe/:userType/distributor(DistributorReq) returns (commonResp)
 	@handler viewStatus
 	post /jybx/subscribe/:userType/viewStatus(viewStatusReq) returns (commonResp)
-    @handler msgDistributor
+	@handler msgDistributor
 	post /juybx/subscribe/msgDistributor(msgDistributor) returns (commonResp)
-}
+}

+ 28 - 0
jyBXSubscribe/api/internal/handler/msgDistributorHandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+	"jyBXSubscribe/api/internal/logic"
+	"jyBXSubscribe/api/internal/svc"
+	"jyBXSubscribe/api/internal/types"
+)
+
+func msgDistributorHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.MsgDistributor
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewMsgDistributorLogic(r.Context(), svcCtx)
+		resp, err := l.MsgDistributor(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

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

@@ -52,6 +52,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/jybx/subscribe/:userType/viewStatus",
 				Handler: viewStatusHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/juybx/subscribe/msgDistributor",
+				Handler: msgDistributorHandler(serverCtx),
+			},
 		},
 	)
 }

+ 30 - 0
jyBXSubscribe/api/internal/logic/msgDistributorLogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"jyBXSubscribe/api/internal/svc"
+	"jyBXSubscribe/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type MsgDistributorLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewMsgDistributorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MsgDistributorLogic {
+	return &MsgDistributorLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *MsgDistributorLogic) MsgDistributor(req *types.MsgDistributor) (resp *types.CommonResp, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 8 - 0
jyBXSubscribe/api/internal/types/types.go

@@ -101,3 +101,11 @@ type ViewStatusReq struct {
 	UserType  string `path:"userType,optional"`
 	InfoId    string `json:"infoId,optional"`
 }
+
+type MsgDistributor struct {
+	AppId     string `header:"appId"`
+	EntId     string `header:"entId,optional"`
+	EntUserId string `header:"entUserId,optional"`
+	MessageId string `json:"messageId"`
+	Staffs    string `json:"staffs"`
+}