Parcourir la source

#7092 【Go查询】添加接口"用户积分信息查询": /User/QueryUserScore

deng.yinping il y a 3 mois
Parent
commit
e1e7adab1c
7 fichiers modifiés avec 281 ajouts et 0 suppressions
  1. 37 0
      controllers/user/user.go
  2. 80 0
      docs/docs.go
  3. 80 0
      docs/swagger.json
  4. 54 0
      docs/swagger.yaml
  5. 13 0
      models/common.go
  6. 14 0
      models/ori.go
  7. 3 0
      routers/router.go

+ 37 - 0
controllers/user/user.go

@@ -758,3 +758,40 @@ func UpdateUserInfoWechatAndEmail(c *gin.Context) {
 	logger.GetLogger().Debugln("UpdateUserInfoWechatAndEmail successed:", "ok")
 	appG.Response(http.StatusOK, e.SUCCESS, "ok")
 }
+
+// GetUserScoreReq 用户积分信息查询请求参数
+type GetUserScoreReq struct {
+	UserID int `form:"userID" binding:"required"` // 用户ID
+}
+
+// QueryUserScore 用户积分信息查询
+// @Summary  用户积分信息查询
+// @Produce  json
+// @Security ApiKeyAuth
+// @Param    userid query    int true "用户ID"
+// @Success  200       {object} models.UserScore
+// @Failure  500    {object} app.Response
+// @Router   /User/QueryUserScore [get]
+// @Tags     用户信息
+func QueryUserScore(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req GetUserScoreReq
+	if err := appG.C.ShouldBindJSON(&req); err != nil {
+		logger.GetLogger().Errorf("QueryUserScore failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	userScores, err := models.GetUserScore(req.UserID)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryUserScore failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功
+	appG.Response(http.StatusOK, e.SUCCESS, userScores)
+}

+ 80 - 0
docs/docs.go

@@ -20561,6 +20561,45 @@ const docTemplate = `{
                 }
             }
         },
+        "/User/QueryUserScore": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "用户信息"
+                ],
+                "summary": "用户积分信息查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.UserScore"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/User/RemoveUserFavoriteGoods": {
             "post": {
                 "security": [
@@ -59203,6 +59242,47 @@ const docTemplate = `{
                 }
             }
         },
+        "models.UserScore": {
+            "type": "object",
+            "properties": {
+                "curscore": {
+                    "description": "期末积分",
+                    "type": "integer"
+                },
+                "freezescore": {
+                    "description": "冻结积分",
+                    "type": "integer"
+                },
+                "oriscore": {
+                    "description": "期初积分",
+                    "type": "integer"
+                },
+                "scoretypeid": {
+                    "description": "积分类型ID",
+                    "type": "integer"
+                },
+                "scoretypename": {
+                    "description": "积分类型名称",
+                    "type": "string"
+                },
+                "todaydecrease": {
+                    "description": "今日减少",
+                    "type": "integer"
+                },
+                "todayincrease": {
+                    "description": "今日增加",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "withholdsocre": {
+                    "description": "代扣积分[积分服务商]",
+                    "type": "integer"
+                }
+            }
+        },
         "models.UserTradeSetting": {
             "type": "object",
             "required": [

+ 80 - 0
docs/swagger.json

@@ -20552,6 +20552,45 @@
                 }
             }
         },
+        "/User/QueryUserScore": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "用户信息"
+                ],
+                "summary": "用户积分信息查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.UserScore"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/User/RemoveUserFavoriteGoods": {
             "post": {
                 "security": [
@@ -59194,6 +59233,47 @@
                 }
             }
         },
+        "models.UserScore": {
+            "type": "object",
+            "properties": {
+                "curscore": {
+                    "description": "期末积分",
+                    "type": "integer"
+                },
+                "freezescore": {
+                    "description": "冻结积分",
+                    "type": "integer"
+                },
+                "oriscore": {
+                    "description": "期初积分",
+                    "type": "integer"
+                },
+                "scoretypeid": {
+                    "description": "积分类型ID",
+                    "type": "integer"
+                },
+                "scoretypename": {
+                    "description": "积分类型名称",
+                    "type": "string"
+                },
+                "todaydecrease": {
+                    "description": "今日减少",
+                    "type": "integer"
+                },
+                "todayincrease": {
+                    "description": "今日增加",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "withholdsocre": {
+                    "description": "代扣积分[积分服务商]",
+                    "type": "integer"
+                }
+            }
+        },
         "models.UserTradeSetting": {
             "type": "object",
             "required": [

+ 54 - 0
docs/swagger.yaml

@@ -25960,6 +25960,36 @@ definitions:
         description: 用户ID
         type: integer
     type: object
+  models.UserScore:
+    properties:
+      curscore:
+        description: 期末积分
+        type: integer
+      freezescore:
+        description: 冻结积分
+        type: integer
+      oriscore:
+        description: 期初积分
+        type: integer
+      scoretypeid:
+        description: 积分类型ID
+        type: integer
+      scoretypename:
+        description: 积分类型名称
+        type: string
+      todaydecrease:
+        description: 今日减少
+        type: integer
+      todayincrease:
+        description: 今日增加
+        type: integer
+      userid:
+        description: 用户ID
+        type: integer
+      withholdsocre:
+        description: 代扣积分[积分服务商]
+        type: integer
+    type: object
   models.UserTradeSetting:
     properties:
       closeddays:
@@ -45289,6 +45319,30 @@ paths:
       summary: 获取用户邀请码
       tags:
       - 用户信息
+  /User/QueryUserScore:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.UserScore'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 用户积分信息查询
+      tags:
+      - 用户信息
   /User/RemoveUserFavoriteGoods:
     post:
       parameters:

+ 13 - 0
models/common.go

@@ -1629,3 +1629,16 @@ func GetClientDocumnetConfigs() (datas []ClientDocumentConfig, err error) {
 
 	return
 }
+
+func GetUserScore(userID int) (datas []UserScore, err error) {
+	engine := db.GetEngine()
+	userScores := make([]UserScore, 0)
+	if err := engine.Table("USERSCORE T").
+		Select("T.*, ST.SCORETYPENAME AS SCORETYPENAME").
+		Join("LEFT", "SCORETYPE ST", `T.SCORETYPEID = STSCORETYPEID`).
+		Where("T.USERID = ?", userID).Find(&userScores); err != nil {
+		return nil, err
+	}
+
+	return userScores, nil
+}

+ 14 - 0
models/ori.go

@@ -1084,6 +1084,20 @@ type ClientDocumentConfig struct {
 
 }
 
+// UserScore 用户积分表
+type UserScore struct {
+	USERID        int64 `json:"userid" xorm:"USERID"`               // 用户ID
+	SCORETYPEID   int32 `json:"scoretypeid" xorm:"SCORETYPEID"`     // 积分类型ID
+	ORISCORE      int32 `json:"oriscore" xorm:"ORISCORE"`           // 期初积分
+	CURSCORE      int32 `json:"curscore" xorm:"CURSCORE"`           // 期末积分
+	FREEZESCORE   int32 `json:"freezescore" xorm:"FREEZESCORE"`     // 冻结积分
+	TODAYINCREASE int32 `json:"todayincrease" xorm:"TODAYINCREASE"` // 今日增加
+	TODAYDECREASE int32 `json:"todaydecrease" xorm:"TODAYDECREASE"` // 今日减少
+	WITHHOLDSOCRE int32 `json:"withholdsocre" xorm:"WITHHOLDSOCRE"` // 代扣积分[积分服务商]
+
+	SCORETYPENAME string `json:"scoretypename" xorm:"-"` // 积分类型名称
+}
+
 // TableName is CLIENT_DOCUMNETCONFIG
 func (r *ClientDocumentConfig) TableName() string {
 	return "CLIENT_DOCUMNETCONFIG"

+ 3 - 0
routers/router.go

@@ -125,6 +125,9 @@ func InitRouter() *gin.Engine {
 
 		userR.Use(token.Auth()).GET("/QueryMdUserSwapProtocol", user.QueryMdUserSwapProtocol)
 		userR.Use(token.Auth()).GET("/GetTodayAccountConfigInfo", user.GetTodayAccountConfigInfo)
+
+		// 用户积分信息查询
+		userR.Use(token.Auth()).GET("/QueryUserScore", user.QueryUserScore)
 	}
 	// ************************ 资金账户 ************************
 	taAccountR := apiR.Group("TaAccount")