zhou.xiaoning il y a 2 ans
Parent
commit
18652c5811
4 fichiers modifiés avec 17 ajouts et 10 suppressions
  1. 6 6
      config/config.xml
  2. 2 2
      controllers/sbyj/goods.go
  3. 1 1
      controllers/sbyj/order.go
  4. 8 1
      models/sbyj.go

+ 6 - 6
config/config.xml

@@ -13,11 +13,11 @@
     <DbAddress value="192.168.31.88"/>
     <DbName value="orcl"/>
     <DbPort value="1521"/>
-    <DbUser value="mtp2_test204"/>
+    <DbUser value="mtp2_test171"/>
     <DbPwd value="muchinfo"/>
   </DbSetting>
   <RedisSetting>
-    <Address value="192.168.31.204"/>
+    <Address value="192.168.31.171"/>
     <Port value="5007"/>
     <Timeout value="3"/>
     <ConnNum value="1"/>
@@ -25,11 +25,11 @@
     <Pwd value=""/>
   </RedisSetting>
   <MqSetting>
-    <Url value="amqp://guest:guest@192.168.31.204:5020/test"/>
+    <Url value="amqp://guest:guest@192.168.31.171:5020/test"/>
     <Exchange value="entry"/>
   </MqSetting>
   <MongoDBSetting>
-    <HostName value="192.168.31.204"/>
+    <HostName value="192.168.31.171"/>
     <Port value="5025"/>
     <DBName value="HistoryQuote"/>
     <Username value="quote_test01"/>
@@ -38,8 +38,8 @@
   <MySQLSetting>
     <Host value="192.168.30.72"/>
     <Port value="3306"/>
-    <DBName value="historyquote_test204"/>
-    <Username value="quote_test204"/>
+    <DBName value="historyquote_test171"/>
+    <Username value="quote_test171"/>
     <Password value="123456"/>
   </MySQLSetting>
 </Configuration>

+ 2 - 2
controllers/sbyj/goods.go

@@ -34,6 +34,6 @@ func GetTouristGoods(c *gin.Context) {
 }
 
 type GetMyOrdersReq struct {
-	GoodsId int `form:"goodsId" binding:"required"` // 商品ID
-	UserId  int `form:"userId" binding:"required"`  // 用户ID
+	GoodsId int `form:"goodsId"`                   // 商品ID
+	UserId  int `form:"userId" binding:"required"` // 用户ID
 }

+ 1 - 1
controllers/sbyj/order.go

@@ -14,8 +14,8 @@ import (
 // @Summary  获取我的订单列表
 // @Produce  json
 // @Security ApiKeyAuth
-// @Param    goodsId query    int true "商品ID"
 // @Param    userId  query    int true "用户ID"
+// @Param    goodsId query    int false "商品ID"
 // @Success  200     {array}  models.RedisTradeHolderDetailEx
 // @Failure  500     {object} app.Response
 // @Router   /sbyj/GetMyOrders [get]

+ 8 - 1
models/sbyj.go

@@ -8,6 +8,7 @@ import (
 	"mtp2_if/rediscli"
 	"mtp2_if/utils"
 	"sort"
+	"strconv"
 	"time"
 
 	"google.golang.org/protobuf/proto"
@@ -140,9 +141,15 @@ func (s RedisTradeHolderDetailExArray) Swap(i, j int) { s[i], s[j] = s[j], s[i]
 // GetDataEx 从数据库中查询数据
 func (r *RedisTradeHolderDetailEx) GetDataEx(userId int, goodsId int) (sData RedisTradeHolderDetailExArray, err error) {
 	redisCli := rediscli.GetRedisClient()
+	g := strconv.Itoa(goodsId)
+	if goodsId == 0 {
+		g = "*"
+	}
 
 	sData = make([]RedisTradeHolderDetailEx, 0)
-	key := fmt.Sprintf("TradeHolderDetailEx:%d:*:%d:*", goodsId, userId)
+	// boost::format fmtDuration("TradeHolderDetailEx:%d_%d_%d_%" PRId64 "");
+	// fmtDuration % detailEx.goodsid() % detailEx.buyorsell()%detailEx.userid()%detailEx.tradeid();
+	key := fmt.Sprintf("TradeHolderDetailEx:%s:*:%d:*", g, userId)
 	if ret, err := redisCli.Do("keys", key).Result(); err == nil {
 		datas := ret.([]interface{})
 		for _, item := range datas {