Просмотр исходного кода

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

deng.yinping 3 месяцев назад
Родитель
Сommit
e37aad2b91
7 измененных файлов с 142 добавлено и 141 удалено
  1. 10 1
      README.md
  2. 9 9
      controllers/user/user.go
  3. 42 45
      docs/docs.go
  4. 42 45
      docs/swagger.json
  5. 31 33
      docs/swagger.yaml
  6. 5 5
      models/common.go
  7. 3 3
      models/ori.go

+ 10 - 1
README.md

@@ -1,3 +1,12 @@
 # MTP20_IF
 
-MTP2.0 Go 查询服务
+MTP2.0 Go 查询服务
+
+编译:
+go build
+
+调试:
+运行 》 启动高度
+
+Swagger调试:
+http://127.0.0.1:[ListenAddress]/swagger/index.html

+ 9 - 9
controllers/user/user.go

@@ -722,9 +722,9 @@ func GetTodayAccountConfigInfo(c *gin.Context) {
 
 // UpdateUserInfoWechatAndEmailReq 更新用户微信和邮箱入参
 type UpdateUserInfoWechatAndEmailReq struct {
-	UserID int     `json:"userID" binding:"required"` // 用户ID
-	Wechat *string `json:"wechat"`                    // 微信号,如不必修改则不传,传空为清除微信号
-	Email  *string `json:"email"`                     // 邮箱地址,如不必修改则不传,传空为清除邮箱地址
+	UserID int     `json:"userID" binding:"required "` // 用户ID
+	Wechat *string `json:"wechat"`                     // 微信号,如不必修改则不传,传空为清除微信号
+	Email  *string `json:"email"`                      // 邮箱地址,如不必修改则不传,传空为清除邮箱地址
 }
 
 // UpdateUserInfoWechatAndEmail 更新用户微信和邮箱
@@ -760,7 +760,7 @@ func UpdateUserInfoWechatAndEmail(c *gin.Context) {
 }
 
 // GetUserScoreReq 用户积分信息查询请求参数
-type GetUserScoreReq struct {
+type QueryUserScoreReq struct {
 	UserID int `form:"userID" binding:"required"` // 用户ID
 }
 
@@ -769,7 +769,7 @@ type GetUserScoreReq struct {
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param    userID query    int true "用户ID"
-// @Success  200       {object} models.UserScore
+// @Success  200       {object} models.QuerUserScoreRsp
 // @Failure  500    {object} app.Response
 // @Router   /User/QueryUserScore [get]
 // @Tags     用户信息
@@ -777,14 +777,14 @@ func QueryUserScore(c *gin.Context) {
 	appG := app.Gin{C: c}
 
 	// 获取请求参数
-	var req GetUserScoreReq
-	if err := appG.C.ShouldBindJSON(&req); err != nil {
+	var req QueryUserScoreReq
+	if err := appG.C.ShouldBindQuery(&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)
+	datas, err := models.GetUserScore(req.UserID)
 	if err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("QueryUserScore failed: %s", err.Error())
@@ -793,5 +793,5 @@ func QueryUserScore(c *gin.Context) {
 	}
 
 	// 查询成功
-	appG.Response(http.StatusOK, e.SUCCESS, userScores)
+	appG.Response(http.StatusOK, e.SUCCESS, datas)
 }

+ 42 - 45
docs/docs.go

@@ -20588,7 +20588,7 @@ const docTemplate = `{
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.UserScore"
+                            "$ref": "#/definitions/models.QuerUserScoreRsp"
                         }
                     },
                     "500": {
@@ -52844,6 +52844,47 @@ const docTemplate = `{
                 }
             }
         },
+        "models.QuerUserScoreRsp": {
+            "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.QueryErrorInfosRsp": {
             "type": "object",
             "required": [
@@ -59242,47 +59283,6 @@ 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": [
@@ -67766,9 +67766,6 @@ const docTemplate = `{
         },
         "user.UpdateUserInfoWechatAndEmailReq": {
             "type": "object",
-            "required": [
-                "userID"
-            ],
             "properties": {
                 "email": {
                     "description": "邮箱地址,如不必修改则不传,传空为清除邮箱地址",

+ 42 - 45
docs/swagger.json

@@ -20579,7 +20579,7 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.UserScore"
+                            "$ref": "#/definitions/models.QuerUserScoreRsp"
                         }
                     },
                     "500": {
@@ -52835,6 +52835,47 @@
                 }
             }
         },
+        "models.QuerUserScoreRsp": {
+            "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.QueryErrorInfosRsp": {
             "type": "object",
             "required": [
@@ -59233,47 +59274,6 @@
                 }
             }
         },
-        "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": [
@@ -67757,9 +67757,6 @@
         },
         "user.UpdateUserInfoWechatAndEmailReq": {
             "type": "object",
-            "required": [
-                "userID"
-            ],
             "properties": {
                 "email": {
                     "description": "邮箱地址,如不必修改则不传,传空为清除邮箱地址",

+ 31 - 33
docs/swagger.yaml

@@ -21228,6 +21228,36 @@ definitions:
         description: 现货商品ID
         type: integer
     type: object
+  models.QuerUserScoreRsp:
+    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.QueryErrorInfosRsp:
     properties:
       description:
@@ -25960,36 +25990,6 @@ 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:
@@ -32345,8 +32345,6 @@ definitions:
       wechat:
         description: 微信号,如不必修改则不传,传空为清除微信号
         type: string
-    required:
-    - userID
     type: object
   zhongrong.GetUserInfoRsp:
     properties:
@@ -45333,7 +45331,7 @@ paths:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/models.UserScore'
+            $ref: '#/definitions/models.QuerUserScoreRsp'
         "500":
           description: Internal Server Error
           schema:

+ 5 - 5
models/common.go

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

+ 3 - 3
models/ori.go

@@ -1084,8 +1084,8 @@ type ClientDocumentConfig struct {
 
 }
 
-// UserScore 用户积分表
-type UserScore struct {
+// QuerUserScoreRsp 用户积分查询返回请求
+type QuerUserScoreRsp struct {
 	USERID        int64 `json:"userid" xorm:"USERID"`               // 用户ID
 	SCORETYPEID   int32 `json:"scoretypeid" xorm:"SCORETYPEID"`     // 积分类型ID
 	ORISCORE      int32 `json:"oriscore" xorm:"ORISCORE"`           // 期初积分
@@ -1095,7 +1095,7 @@ type UserScore struct {
 	TODAYDECREASE int32 `json:"todaydecrease" xorm:"TODAYDECREASE"` // 今日减少
 	WITHHOLDSOCRE int32 `json:"withholdsocre" xorm:"WITHHOLDSOCRE"` // 代扣积分[积分服务商]
 
-	SCORETYPENAME string `json:"scoretypename" xorm:"-"` // 积分类型名称
+	SCORETYPENAME string `json:"scoretypename" xorm:"SCORETYPENAME"` // 积分类型名称
 }
 
 // TableName is CLIENT_DOCUMNETCONFIG