Преглед изворни кода

/sbyj/GetMyOrders(获取我的订单列表):条件”accountId" 改为 string类型;

deng.yinping пре 2 месеци
родитељ
комит
65e6a2877a
6 измењених фајлова са 9 додато и 8 уклоњено
  1. 1 1
      controllers/sbyj/goods.go
  2. 3 2
      controllers/sbyj/order.go
  3. 1 1
      docs/docs.go
  4. 1 1
      docs/swagger.json
  5. 1 1
      docs/swagger.yaml
  6. 2 2
      models/sbyj.go

+ 1 - 1
controllers/sbyj/goods.go

@@ -72,5 +72,5 @@ func GetTouristGoods(c *gin.Context) {
 type GetMyOrdersReq struct {
 	GoodsId   int    `form:"goodsId"`                   // 商品ID
 	UserId    int    `form:"userId" binding:"required"` // 用户ID
-	AccountId uint64 `form:"accountId"`                 // 资金账户Id
+	AccountId string `form:"accountId"`                 // 资金账户Id
 }

+ 3 - 2
controllers/sbyj/order.go

@@ -6,6 +6,7 @@ import (
 	"mtp2_if/logger"
 	"mtp2_if/models"
 	"net/http"
+	"strings"
 
 	"github.com/gin-gonic/gin"
 )
@@ -15,7 +16,7 @@ import (
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param    userId  query    int true  "用户ID"
-// @Param    accountId  query int false "资金账户"
+// @Param    accountId  query string false "资金账户"
 // @Param    goodsId query    int false "商品ID"
 // @Success  200     {array}  models.RedisTradeHolderDetailEx
 // @Failure  500     {object} app.Response
@@ -34,7 +35,7 @@ func GetMyOrders(c *gin.Context) {
 
 	// 获取数据
 	d := models.RedisTradeHolderDetailEx{}
-	rsp, err := d.GetDataEx(req.UserId, req.GoodsId, req.AccountId)
+	rsp, err := d.GetDataEx(req.UserId, req.GoodsId, strings.TrimSpace(req.AccountId))
 	if err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("GetMyOrders failed: %s", err.Error())

+ 1 - 1
docs/docs.go

@@ -23697,7 +23697,7 @@ const docTemplate = `{
                         "required": true
                     },
                     {
-                        "type": "integer",
+                        "type": "string",
                         "description": "资金账户",
                         "name": "accountId",
                         "in": "query"

+ 1 - 1
docs/swagger.json

@@ -23689,7 +23689,7 @@
                         "required": true
                     },
                     {
-                        "type": "integer",
+                        "type": "string",
                         "description": "资金账户",
                         "name": "accountId",
                         "in": "query"

+ 1 - 1
docs/swagger.yaml

@@ -47410,7 +47410,7 @@ paths:
       - description: 资金账户
         in: query
         name: accountId
-        type: integer
+        type: string
       - description: 商品ID
         in: query
         name: goodsId

+ 2 - 2
models/sbyj.go

@@ -174,7 +174,7 @@ func (s RedisTradeHolderDetailExArray) Less(i, j int) bool {
 func (s RedisTradeHolderDetailExArray) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
 
 // GetDataEx 从数据库中查询数据
-func (r *RedisTradeHolderDetailEx) GetDataEx(userId int, goodsId int, accountId uint64) (sData RedisTradeHolderDetailExArray, err error) {
+func (r *RedisTradeHolderDetailEx) GetDataEx(userId int, goodsId int, accountId string) (sData RedisTradeHolderDetailExArray, err error) {
 	redisCli := rediscli.GetRedisClient()
 	g := strconv.Itoa(goodsId)
 	if goodsId == 0 {
@@ -207,7 +207,7 @@ func (r *RedisTradeHolderDetailEx) GetDataEx(userId int, goodsId int, accountId
 					m.THDetailEx.AddDepositRate = utils.Float64Round(m.THDetailEx.AddDepositRate, 4)
 
 					// 有资金账户ID则只取该资金账户的数据
-					if accountId == 0 || (accountId != 0 && accountId == m.THDetailEx.AccountID) {
+					if accountId == "" || (accountId != "" && accountId == strconv.FormatUint(m.THDetailEx.AccountID, 10)) {
 						sData = append(sData, m)
 					}
 				}