diff --git a/app/hdl/hdl_user.go b/app/hdl/hdl_user.go index bd7fc0d..6537c27 100644 --- a/app/hdl/hdl_user.go +++ b/app/hdl/hdl_user.go @@ -334,6 +334,47 @@ func InviteUrl(c *gin.Context) { return } +// ParentInfo +// @Summary 导师信息 +// @Tags 会员中心 +// @Description 导师信息 +// @Accept json +// @Produce json +// @Success 200 {object} md.ParentInfo "登录成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/memberCenter/parentInfo [get] +func ParentInfo(c *gin.Context) { + ownUser := svc.GetUser(c) + if ownUser.ParentUid == 0 { + e.OutSuc(c, md.ParentInfo{}, nil) + return + } + NewUserDb := implement.NewUserDb(db.Db) + user, _ := NewUserDb.GetUser(ownUser.ParentUid) + // 1. 获取会员等级名称 + userLevelDb := implement.NewUserLevelDb(db.Db) + level, err := userLevelDb.UserLevelByID(user.Level) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, nil) + return + } + code := user.SystemInviteCode + if user.CustomInviteCode != "" { + code = user.CustomInviteCode + } + res := md.ParentInfo{ + Nickname: user.Nickname, + LevelName: level.LevelName, + InviteCode: code, + HeadImg: svc.GetOssUrl(user.Avatar), + Id: utils.Int64ToStr(user.Id), + Phone: user.Phone, + WechatAccount: user.WechatAccount, + } + e.OutSuc(c, res, nil) + return +} + // Delete // @Summary 注销账号操作 // @Tags 账号与安全 diff --git a/app/md/md_login.go b/app/md/md_login.go index 39080e9..0bea4a9 100644 --- a/app/md/md_login.go +++ b/app/md/md_login.go @@ -62,3 +62,12 @@ type InviteUrl struct { InviteCode string `json:"invite_code"` Qrcode string `json:"qrcode"` } +type ParentInfo struct { + Nickname string `json:"nickname" example:"昵称"` + LevelName string `json:"level_name" example:"等级"` + InviteCode string `json:"invite_code" example:"邀请码"` + HeadImg string `json:"head_img" example:"头像"` + Id string `json:"id" example:"个人ID号"` + Phone string `json:"phone" example:"手机号"` + WechatAccount string `json:"wechat_account" example:"微信号"` +} diff --git a/app/router/router.go b/app/router/router.go index 696c66c..2662d58 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -119,6 +119,7 @@ func route(r *gin.RouterGroup) { { rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据 rMemberCenter.POST("/bindParent", hdl.UserBindParent) //绑定上级 + rMemberCenter.GET("/parentInfo", hdl.ParentInfo) //上级信息 rMemberCenter.POST("/updatePassword", hdl.UpdatePassword) //修改密码 rMemberCenter.POST("/updatePasscode", hdl.UpdatePasscode) //修改支付密码 rMemberCenter.GET("/inviteUrl", hdl.InviteUrl) //邀请链接 diff --git a/go.mod b/go.mod index 68ed6ea..2442ccb 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241213070558-a1f0ce782dff + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241213090643-10ffb038ded6 code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212140020-c99f60b4f868 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5