wangfei 6 лет назад
Родитель
Сommit
3fb01126e7
2 измененных файлов: 12 добавлений и 10 удалений
  1. 1
    10
      controllers/flashbuy/flashbuy.go
  2. 11
    0
      service/flashbuy/flashbuy.go

+ 1
- 10
controllers/flashbuy/flashbuy.go Просмотреть файл

@@ -8,8 +8,6 @@ import (
8 8
 	"spaceofcheng/services/models/model"
9 9
 	"spaceofcheng/services/service/flashbuy"
10 10
 	"spaceofcheng/services/utils"
11
-
12
-	"github.com/astaxie/beego"
13 11
 )
14 12
 
15 13
 // CaseController 信息
@@ -77,17 +75,10 @@ func (c *FlashBuyController) GetFlashBuyById() {
77 75
 	if err != nil {
78 76
 		c.ResponseError(err)
79 77
 	}
80
-	userRaw := c.Context.Get("customer")
81
-	if userRaw == nil {
82
-		c.ResponseError(errors.New("系统内部错误"), http.StatusInternalServerError)
83
-	}
84
-
85
-	user := userRaw.(model.TaCustomer)
86
-	userinfo, err := c.dao.GetCustomerFlashBuyId(flashBuyId, user.CustomerId)
78
+	userinfo, err := c.dao.GetFlashByUser(flashBuyId)
87 79
 	if err != nil {
88 80
 		c.ResponseError(err)
89 81
 	}
90
-	beego.Error(userinfo)
91 82
 	c.ResponseJSON(map[string]interface{}{
92 83
 		"flashBuy": flashBuy,
93 84
 		"userInfo": userinfo,

+ 11
- 0
service/flashbuy/flashbuy.go Просмотреть файл

@@ -62,6 +62,17 @@ func (s *FlashBuyServ) GetFlashBuyById(flashBuyId string) (*model.TaFlashBuy, er
62 62
 	}
63 63
 	return flashbuy, nil
64 64
 }
65
+
66
+// GetFlashByUser 获取用户的抢购信息
67
+func (s *FlashBuyServ) GetFlashByUser(id string) ([]model.TaCustomerFlashBuy, error) {
68
+	cst := s.ctx.Get("customer")
69
+	if cst == nil {
70
+		return nil, errors.New("系统内部错误")
71
+	}
72
+	flashbuys, err := s.dao.GetCustomerFlashBuy(id, cst.(model.TaCustomer).CustomerId)
73
+	return flashbuys, err
74
+}
75
+
65 76
 func (s *FlashBuyServ) SaveFlashBuy(flashbuy model.TaFlashBuy) (*model.TaFlashBuy, error) {
66 77
 	var newFlashBuy *model.TaFlashBuy
67 78
 	var err error