Browse Source

api文件修改

WH01243 2 years ago
parent
commit
d9071a53a0

+ 10 - 10
jyBXSubscribe/api/bxsubscribe.api

@@ -122,23 +122,23 @@ type (
 	}
 	}
 	GetUserReq {
 	GetUserReq {
 		AppId        string `header:"appId"`
 		AppId        string `header:"appId"`
-		EntId        string `header:"entId,optional"`
-		EntUserId    string `header:"entUserId,optional"`
+		EntId        int64  `header:"entId,optional"`
+		EntUserId    int64  `header:"entUserId,optional"`
 		PositionType int64  `header:"positionType,optional"`
 		PositionType int64  `header:"positionType,optional"`
 		UserId       string `header:"userId,optional"`
 		UserId       string `header:"userId,optional"`
 	}
 	}
 	SetUserReq {
 	SetUserReq {
 		AppId        string `header:"appId"`
 		AppId        string `header:"appId"`
-		EntId        string `header:"entId,optional"`
-		EntUserId    string `header:"entUserId,optional"`
+		EntId        int64  `header:"entId,optional"`
+		EntUserId    int64  `header:"entUserId,optional"`
 		PositionType int64  `header:"positionType,optional"`
 		PositionType int64  `header:"positionType,optional"`
 		UserId       string `header:"userId,optional"`
 		UserId       string `header:"userId,optional"`
 		Mail         string `json:"mail,optional"`
 		Mail         string `json:"mail,optional"`
 	}
 	}
-	PushSetReq {
+	SetPushSetReq {
 		AppId        string   `header:"appId"`
 		AppId        string   `header:"appId"`
-		EntId        string   `header:"entId,optional"`
-		EntUserId    string   `header:"entUserId,optional"`
+		EntId        int64    `header:"entId,optional"`
+		EntUserId    int64    `header:"entUserId,optional"`
 		PositionType int64    `header:"positionType,optional"`
 		PositionType int64    `header:"positionType,optional"`
 		UserId       string   `header:"userId,optional"`
 		UserId       string   `header:"userId,optional"`
 		Item         string   `json:"item"`
 		Item         string   `json:"item"`
@@ -168,12 +168,12 @@ service bxsubscribe-api {
 	post /jybx/subscribe/:userType/viewStatus(viewStatusReq) returns (commonResp)
 	post /jybx/subscribe/:userType/viewStatus(viewStatusReq) returns (commonResp)
 	@handler msgDistributor
 	@handler msgDistributor
 	post /jybx/subscribe/msgDistributor(msgDistributor) returns (commonResp)
 	post /jybx/subscribe/msgDistributor(msgDistributor) returns (commonResp)
-	@handler userInfo //查询用户信息
-	post /jybx/subscribe/userInfo (GetUserReq) returns (commonResp)
+	@handler getUser //查询用户信息
+	post /jybx/subscribe/getUser (GetUserReq) returns (commonResp)
 	@handler setUser  //设置用户信息
 	@handler setUser  //设置用户信息
 	post /jybx/subscribe/setUser (SetUserReq) returns (commonResp)
 	post /jybx/subscribe/setUser (SetUserReq) returns (commonResp)
 	@handler getPushSet  //推送设置查询
 	@handler getPushSet  //推送设置查询
-	post /jybx/subscribe/getPushSet (GetUserReq) returns (commonResp)
+	post /jybx/subscribe/getPushSet (SetPushSetReq) returns (commonResp)
 	@handler setPushSet  //推送设置修改
 	@handler setPushSet  //推送设置修改
 	post /jybx/subscribe/setPushSet (GetUserReq) returns (commonResp)
 	post /jybx/subscribe/setPushSet (GetUserReq) returns (commonResp)
 }
 }

+ 28 - 0
jyBXSubscribe/api/internal/handler/getUserHandler.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 getUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.GetUserReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewGetUserLogic(r.Context(), svcCtx)
+		resp, err := l.GetUser(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 2 - 2
jyBXSubscribe/api/internal/handler/routes.go

@@ -59,8 +59,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			},
 			},
 			{
 			{
 				Method:  http.MethodPost,
 				Method:  http.MethodPost,
-				Path:    "/jybx/subscribe/userInfo",
-				Handler: userInfoHandler(serverCtx),
+				Path:    "/jybx/subscribe/getUser",
+				Handler: getUserHandler(serverCtx),
 			},
 			},
 			{
 			{
 				Method:  http.MethodPost,
 				Method:  http.MethodPost,

+ 1 - 1
jyBXSubscribe/api/internal/handler/setPushSetHandler.go

@@ -11,7 +11,7 @@ import (
 
 
 func setPushSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 func setPushSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 	return func(w http.ResponseWriter, r *http.Request) {
-		var req types.GetUserReq
+		var req types.SetPushSetReq
 		if err := httpx.Parse(r, &req); err != nil {
 		if err := httpx.Parse(r, &req); err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 			httpx.ErrorCtx(r.Context(), w, err)
 			return
 			return

+ 10 - 3
jyBXSubscribe/api/internal/logic/getPushSetLogic.go

@@ -26,15 +26,22 @@ func NewGetPushSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPus
 
 
 func (l *GetPushSetLogic) GetPushSet(req *types.GetUserReq) (*types.CommonResp, error) {
 func (l *GetPushSetLogic) GetPushSet(req *types.GetUserReq) (*types.CommonResp, error) {
 	// todo: add your logic here and delete this line
 	// todo: add your logic here and delete this line
-	res, _ := l.svcCtx.Suscribe.GetKey(l.ctx, &bxsubscribe.GetKeyReq{
+	res, err := l.svcCtx.Suscribe.GetPushSet(l.ctx, &bxsubscribe.GetPushSetReq{
 		UserId:       req.UserId,
 		UserId:       req.UserId,
 		EntId:        req.EntId,
 		EntId:        req.EntId,
 		EntUserId:    req.EntUserId,
 		EntUserId:    req.EntUserId,
 		PositionType: req.PositionType,
 		PositionType: req.PositionType,
 	})
 	})
+	if err != nil {
+		return &types.CommonResp{
+			Err_code: res.ErrorCode,
+			Err_msg:  res.ErrorMsg,
+			Data:     nil,
+		}, nil
+	}
 	return &types.CommonResp{
 	return &types.CommonResp{
-		Err_code: res.ErrCode,
-		Err_msg:  res.ErrMsg,
+		Err_code: res.ErrorCode,
+		Err_msg:  res.ErrorMsg,
 		Data:     res,
 		Data:     res,
 	}, nil
 	}, nil
 }
 }

+ 47 - 0
jyBXSubscribe/api/internal/logic/getUserLogic.go

@@ -0,0 +1,47 @@
+package logic
+
+import (
+	"context"
+	"jyBXSubscribe/rpc/bxsubscribe"
+
+	"jyBXSubscribe/api/internal/svc"
+	"jyBXSubscribe/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetUserLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserLogic {
+	return &GetUserLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GetUserLogic) GetUser(req *types.GetUserReq) (*types.CommonResp, error) {
+	// todo: add your logic here and delete this line
+	res, err := l.svcCtx.Suscribe.UserInfo(l.ctx, &bxsubscribe.GetUserInfoReq{
+		UserId:       req.UserId,
+		EntId:        req.EntId,
+		EntUserId:    req.EntUserId,
+		PositionType: req.PositionType,
+	})
+	if err != nil {
+		return &types.CommonResp{
+			Err_code: res.ErrorCode,
+			Err_msg:  res.ErrorMsg,
+			Data:     nil,
+		}, nil
+	}
+	return &types.CommonResp{
+		Err_code: res.ErrorCode,
+		Err_msg:  res.ErrorMsg,
+		Data:     res,
+	}, nil
+}

+ 26 - 3
jyBXSubscribe/api/internal/logic/setPushSetLogic.go

@@ -2,6 +2,7 @@ package logic
 
 
 import (
 import (
 	"context"
 	"context"
+	"jyBXSubscribe/rpc/bxsubscribe"
 
 
 	"jyBXSubscribe/api/internal/svc"
 	"jyBXSubscribe/api/internal/svc"
 	"jyBXSubscribe/api/internal/types"
 	"jyBXSubscribe/api/internal/types"
@@ -23,8 +24,30 @@ func NewSetPushSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetPus
 	}
 	}
 }
 }
 
 
-func (l *SetPushSetLogic) SetPushSet(req *types.GetUserReq) (resp *types.CommonResp, err error) {
+func (l *SetPushSetLogic) SetPushSet(req *types.SetPushSetReq) (*types.CommonResp, error) {
 	// todo: add your logic here and delete this line
 	// todo: add your logic here and delete this line
-
-	return
+	res, err := l.svcCtx.Suscribe.SetPushSet(l.ctx, &bxsubscribe.SetPushSetReq{
+		UserId:       req.UserId,
+		EntId:        req.EntId,
+		EntUserId:    req.EntUserId,
+		PositionType: req.PositionType,
+		Item:         req.Item,
+		PushType:     req.PushType,
+		PushValue:    req.PushValue,
+		Ratemode:     req.Ratemode,
+		Times:        req.Times,
+		SetType:      req.SetType,
+	})
+	if err != nil {
+		return &types.CommonResp{
+			Err_code: res.ErrorCode,
+			Err_msg:  res.ErrorMsg,
+			Data:     nil,
+		}, nil
+	}
+	return &types.CommonResp{
+		Err_code: res.ErrorCode,
+		Err_msg:  res.ErrorMsg,
+		Data:     res,
+	}, nil
 }
 }

+ 21 - 2
jyBXSubscribe/api/internal/logic/setUserLogic.go

@@ -2,6 +2,7 @@ package logic
 
 
 import (
 import (
 	"context"
 	"context"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
 
 
 	"jyBXSubscribe/api/internal/svc"
 	"jyBXSubscribe/api/internal/svc"
 	"jyBXSubscribe/api/internal/types"
 	"jyBXSubscribe/api/internal/types"
@@ -23,8 +24,26 @@ func NewSetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetUserLo
 	}
 	}
 }
 }
 
 
-func (l *SetUserLogic) SetUser(req *types.SetUserReq) (resp *types.CommonResp, err error) {
+func (l *SetUserLogic) SetUser(req *types.SetUserReq) (*types.CommonResp, error) {
 	// todo: add your logic here and delete this line
 	// todo: add your logic here and delete this line
 
 
-	return
+	res, err := l.svcCtx.Suscribe.SetUser(l.ctx, &bxsubscribe.SetUserInfoReq{
+		UserId:       req.UserId,
+		EntId:        req.EntId,
+		EntUserId:    req.EntUserId,
+		PositionType: req.PositionType,
+		Mail:         req.Mail,
+	})
+	if err != nil {
+		return &types.CommonResp{
+			Err_code: res.ErrorCode,
+			Err_msg:  res.ErrorMsg,
+			Data:     nil,
+		}, nil
+	}
+	return &types.CommonResp{
+		Err_code: res.ErrorCode,
+		Err_msg:  res.ErrorMsg,
+		Data:     res,
+	}, nil
 }
 }

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

@@ -120,31 +120,31 @@ type MsgDistributor struct {
 
 
 type GetUserReq struct {
 type GetUserReq struct {
 	AppId        string `header:"appId"`
 	AppId        string `header:"appId"`
-	EntId        string `header:"entId,optional"`
-	EntUserId    string `header:"entUserId,optional"`
+	EntId        int64  `header:"entId,optional"`
+	EntUserId    int64  `header:"entUserId,optional"`
 	PositionType int64  `header:"positionType,optional"`
 	PositionType int64  `header:"positionType,optional"`
 	UserId       string `header:"userId,optional"`
 	UserId       string `header:"userId,optional"`
 }
 }
 
 
 type SetUserReq struct {
 type SetUserReq struct {
 	AppId        string `header:"appId"`
 	AppId        string `header:"appId"`
-	EntId        string `header:"entId,optional"`
-	EntUserId    string `header:"entUserId,optional"`
+	EntId        int64  `header:"entId,optional"`
+	EntUserId    int64  `header:"entUserId,optional"`
 	PositionType int64  `header:"positionType,optional"`
 	PositionType int64  `header:"positionType,optional"`
 	UserId       string `header:"userId,optional"`
 	UserId       string `header:"userId,optional"`
 	Mail         string `json:"mail,optional"`
 	Mail         string `json:"mail,optional"`
 }
 }
 
 
-type PushSetReq struct {
+type SetPushSetReq struct {
 	AppId        string   `header:"appId"`
 	AppId        string   `header:"appId"`
-	EntId        string   `header:"entId,optional"`
-	EntUserId    string   `header:"entUserId,optional"`
+	EntId        int64    `header:"entId,optional"`
+	EntUserId    int64    `header:"entUserId,optional"`
 	PositionType int64    `header:"positionType,optional"`
 	PositionType int64    `header:"positionType,optional"`
 	UserId       string   `header:"userId,optional"`
 	UserId       string   `header:"userId,optional"`
 	Item         string   `json:"item"`
 	Item         string   `json:"item"`
 	SetType      string   `json:"setType"`
 	SetType      string   `json:"setType"`
 	Ratemode     int64    `json:"ratemode,optional"`
 	Ratemode     int64    `json:"ratemode,optional"`
-	PushType     string   `json:"pushType,optional"`
 	Times        []string `json:"times,optional"`
 	Times        []string `json:"times,optional"`
+	PushType     string   `json:"pushType,optional"`
 	PushValue    int64    `json:"pushValue,optiona"`
 	PushValue    int64    `json:"pushValue,optiona"`
 }
 }

+ 13 - 19
jyBXSubscribe/rpc/internal/logic/setuserlogic.go

@@ -1,13 +1,12 @@
 package logic
 package logic
 
 
 import (
 import (
-	"app.yhyue.com/moapp/message/db"
 	"context"
 	"context"
+	"jyBXSubscribe/rpc/model/service"
 
 
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
 	"jyBXSubscribe/rpc/internal/svc"
 	"jyBXSubscribe/rpc/internal/svc"
 	"jyBXSubscribe/rpc/type/bxsubscribe"
 	"jyBXSubscribe/rpc/type/bxsubscribe"
-	"jyBXSubscribe/rpc/util"
 )
 )
 
 
 type SetUserLogic struct {
 type SetUserLogic struct {
@@ -27,25 +26,20 @@ func NewSetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetUserLo
 // 用户邮箱保存
 // 用户邮箱保存
 func (l *SetUserLogic) SetUser(in *bxsubscribe.SetUserInfoReq) (*bxsubscribe.StatusResp, error) {
 func (l *SetUserLogic) SetUser(in *bxsubscribe.SetUserInfoReq) (*bxsubscribe.StatusResp, error) {
 	// todo: add your logic here and delete this line
 	// todo: add your logic here and delete this line
-	set := map[string]interface{}{
-		"o_pushset.s_email": in.Mail,
+	subService := &service.PushSetService{
+		UserId:       in.UserId,
+		PositionType: in.PositionType,
+		EntUserId:    in.EntUserId,
+		EntId:        in.EntId,
 	}
 	}
-	update := false
-	if in.PositionType == 0 {
-		update = db.Mgo.Update(util.USER, map[string]interface{}{"userid": in.UserId}, map[string]interface{}{
-			"$set": set,
-		}, true, false)
-	} else {
-		update = db.Mgo.Update(util.USER, map[string]interface{}{"entId": in.EntId, "user_id": in.EntUserId}, map[string]interface{}{
-			"$set": set,
-		}, true, false)
-	}
-	if update {
-		return &bxsubscribe.StatusResp{Status: 0}, nil
-
+	fool := subService.SetUser(in.Mail)
+	if fool {
+		return &bxsubscribe.StatusResp{
+			Status: 1,
+		}, nil
 	} else {
 	} else {
 		return &bxsubscribe.StatusResp{
 		return &bxsubscribe.StatusResp{
-			Status: 1}, nil
-
+			Status: 0,
+		}, nil
 	}
 	}
 }
 }

+ 18 - 3
jyBXSubscribe/rpc/model/service/pushSet.go

@@ -2,7 +2,6 @@ package service
 
 
 import (
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/message/db"
 	"fmt"
 	"fmt"
 	IC "jyBXSubscribe/rpc/init"
 	IC "jyBXSubscribe/rpc/init"
 	"jyBXSubscribe/rpc/type/bxsubscribe"
 	"jyBXSubscribe/rpc/type/bxsubscribe"
@@ -40,11 +39,11 @@ func (this *PushSetService) Update(item, setType, pushType string, ratemode, pus
 	}
 	}
 	update := false
 	update := false
 	if this.PositionType == 0 {
 	if this.PositionType == 0 {
-		update = db.Mgo.Update(util.USER, map[string]interface{}{"userid": this.UserId}, map[string]interface{}{
+		update = IC.Mgo.Update(util.USER, map[string]interface{}{"userid": this.UserId}, map[string]interface{}{
 			"$set": set,
 			"$set": set,
 		}, true, false)
 		}, true, false)
 	} else {
 	} else {
-		update = db.Mgo.Update(util.USER, map[string]interface{}{"entId": this.EntId, "user_id": this.EntUserId}, map[string]interface{}{
+		update = IC.Mgo.Update(util.USER, map[string]interface{}{"entId": this.EntId, "user_id": this.EntUserId}, map[string]interface{}{
 			"$set": set,
 			"$set": set,
 		}, true, false)
 		}, true, false)
 	}
 	}
@@ -104,3 +103,19 @@ func pushSetMontage(in interface{}) (bool, *bxsubscribe.PushSet) {
 	}
 	}
 
 
 }
 }
+func (this *PushSetService) SetUser(mail string) bool {
+	set := map[string]interface{}{
+		"o_pushset.s_email": mail,
+	}
+	update := false
+	if this.PositionType == 0 {
+		update = IC.Mgo.Update(util.USER, map[string]interface{}{"userid": this.UserId}, map[string]interface{}{
+			"$set": set,
+		}, true, false)
+	} else {
+		update = IC.Mgo.Update(util.USER, map[string]interface{}{"entId": this.EntId, "user_id": this.EntUserId}, map[string]interface{}{
+			"$set": set,
+		}, true, false)
+	}
+	return update
+}