Răsfoiți Sursa

feat: 提交

zhangxinlei1996 2 ani în urmă
părinte
comite
2973d99054

+ 28 - 0
api/internal/handler/getentuserinfobypositonidhandler.go

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

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

@@ -82,6 +82,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/userCenter/ent/userInfo",
 				Handler: GetEntUserInfoHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/userCenter/ent/getUserInfoByPId",
+				Handler: GetEntUserInfoByPositonIdHandler(serverCtx),
+			},
 		},
 	)
 

+ 42 - 0
api/internal/logic/getentuserinfobypositonidlogic.go

@@ -0,0 +1,42 @@
+package logic
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/api/internal/types"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/entity"
+	. "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetEntUserInfoByPositonIdLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetEntUserInfoByPositonIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEntUserInfoByPositonIdLogic {
+	return &GetEntUserInfoByPositonIdLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GetEntUserInfoByPositonIdLogic) GetEntUserInfoByPositonId(req *types.GetUserInfoByPIdReq) (resp *types.Resp, err error) {
+	positionId := encrypt.SE.Decode4Hex(req.PositionId)
+	res, err := entity.UserCenterRpc.IdentityByPositionId(l.ctx, &IdentityReq{
+		Id: common.Int64All(positionId),
+	})
+
+	return &types.Resp{
+		Error_code: 0,
+		Error_msg:  "",
+		Data: map[string]interface{}{
+			"name": res.EntUserName,
+		},
+	}, err
+}

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

@@ -289,3 +289,8 @@ type UserIdentityReq struct {
 	NewUserId int64  `json:"newUserId"`
 	EntId     int64  `json:"entId,optional"`
 }
+
+type GetUserInfoByPIdReq struct {
+	AppId      string `header:"appId"`
+	PositionId string `json:"positionId"` //职位id
+}

+ 7 - 0
api/userCenter.api

@@ -304,6 +304,11 @@ type (
 		NewUserId int64  `json:"newUserId"`
 		EntId     int64  `json:"entId,optional"`
 	}
+
+	GetUserInfoByPIdReq {
+		AppId      string `header:"appId"`
+		PositionId string `json:"positionId"` //职位id
+	}
 )
 
 service userCenter-api {
@@ -337,6 +342,8 @@ service userCenter-api {
 	post /userCenter/user/getUserInfo (UserReq) returns (resp)
 	@handler GetEntUserInfo
 	post /userCenter/ent/userInfo (EntUserReq) returns (resp)
+	@handler GetEntUserInfoByPositonId
+	post /userCenter/ent/getUserInfoByPId (GetUserInfoByPIdReq) returns (resp)
 }
 
 @server(