Sfoglia il codice sorgente

绑定上级

master
huangjiajun 9 ore fa
parent
commit
2fa7857c88
5 ha cambiato i file con 169 aggiunte e 3 eliminazioni
  1. +58
    -0
      app/hdl/hdl_user.go
  2. +2
    -0
      app/router/router.go
  3. +41
    -1
      docs/docs.go
  4. +41
    -1
      docs/swagger.json
  5. +27
    -1
      docs/swagger.yaml

+ 58
- 0
app/hdl/hdl_user.go Vedi File

@@ -99,3 +99,61 @@ func InviteCodeUserInfo(c *gin.Context) {
e.OutSuc(c, res, nil)
return
}

// UserBindParent
// @Summary 绑定上级-要登陆的
// @Tags 登录注册
// @Description 绑定上级
// @Accept json
// @Produce json
// @Param req body md.InviteCodeUserInfoReq true "注册参数"
// @Success 200 {string} "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/memberCenter/bindParent [post]
func UserBindParent(c *gin.Context) {
var req md.InviteCodeUserInfoReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = svc.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
if req.InviteCode == "" {
e.OutErr(c, 400, e.NewErr(400, "邀请码不能为空"))
return
}
userDb := implement.NewUserDb(db.Db)
user, err := userDb.UserGetOneByParams(map[string]interface{}{
"key": "system_invite_code",
"value": req.InviteCode,
})
if user == nil {
user, _ = userDb.UserGetOneByParams(map[string]interface{}{
"key": "custom_invite_code",
"value": req.InviteCode,
})
if user == nil {
e.OutErr(c, 400, e.NewErr(400, "用户不存在"))
return
}
}
ownUser := svc.GetUser(c)
if ownUser.ParentUid > 0 {
e.OutErr(c, 400, e.NewErr(400, "已有导师"))
return
}
if user.Id == ownUser.Id {
e.OutErr(c, 400, e.NewErr(400, "不能绑定自己"))
return
}
ownUser.ParentUid = user.Id
_, err = db.Db.Where("id=?", ownUser.Id).Cols("parent_uid").Update(ownUser)
if err != nil {
e.OutErr(c, 400, e.NewErr(400, "绑定失败,请重试"))
return
}
//TODO 绑定成功后 加群之类的怎么处理
e.OutSuc(c, "success", nil)
return
}

+ 2
- 0
app/router/router.go Vedi File

@@ -76,6 +76,7 @@ func route(r *gin.RouterGroup) {
r.Use(mw.Auth) // 以下接口需要JWT验证
rComm(r.Group("/comm"))
r.POST("/advertising/check", hdl.AdvertisingCheck) //广告位判断能不能看

rHomePage := r.Group("/homePage")
{
rHomePage.GET("/index", hdl.HomePage) // 主页
@@ -97,6 +98,7 @@ func route(r *gin.RouterGroup) {
rMemberCenter := r.Group("/memberCenter")
{
rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据
rMemberCenter.POST("/bindParent", hdl.UserBindParent) //绑定上级
}
rPointsCenter := r.Group("/pointsCenter") // 积分中心
{


+ 41
- 1
docs/docs.go Vedi File

@@ -1394,6 +1394,46 @@ const docTemplate = `{
}
}
},
"/api/v1/memberCenter/bindParent": {
"post": {
"description": "绑定上级",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"登录注册"
],
"summary": "绑定上级-要登陆的",
"parameters": [
{
"description": "注册参数",
"name": "req",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/md.InviteCodeUserInfoReq"
}
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/memberCenter/getBasic": {
"get": {
"description": "基础数据(获取)",
@@ -3963,7 +4003,7 @@ const docTemplate = `{
"type": "integer"
},
"to_user_ids": {
"description": "红包给到哪些用户(专属红包)",
"description": "红包给到哪些im用户id(专属红包)",
"type": "array",
"items": {
"type": "integer"


+ 41
- 1
docs/swagger.json Vedi File

@@ -1387,6 +1387,46 @@
}
}
},
"/api/v1/memberCenter/bindParent": {
"post": {
"description": "绑定上级",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"登录注册"
],
"summary": "绑定上级-要登陆的",
"parameters": [
{
"description": "注册参数",
"name": "req",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/md.InviteCodeUserInfoReq"
}
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/memberCenter/getBasic": {
"get": {
"description": "基础数据(获取)",
@@ -3956,7 +3996,7 @@
"type": "integer"
},
"to_user_ids": {
"description": "红包给到哪些用户(专属红包)",
"description": "红包给到哪些im用户id(专属红包)",
"type": "array",
"items": {
"type": "integer"


+ 27
- 1
docs/swagger.yaml Vedi File

@@ -1019,7 +1019,7 @@ definitions:
description: 消息发送时间戳,精确到毫秒
type: integer
to_user_ids:
description: 红包给到哪些用户(专属红包)
description: 红包给到哪些im用户id(专属红包)
items:
type: integer
type: array
@@ -2225,6 +2225,32 @@ paths:
summary: 登陆
tags:
- 登录注册
/api/v1/memberCenter/bindParent:
post:
consumes:
- application/json
description: 绑定上级
parameters:
- description: 注册参数
in: body
name: req
required: true
schema:
$ref: '#/definitions/md.InviteCodeUserInfoReq'
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
type: string
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 绑定上级-要登陆的
tags:
- 登录注册
/api/v1/memberCenter/getBasic:
get:
consumes:


Caricamento…
Annulla
Salva