master
kanade 4 years ago
parent 3b48372ee5
commit 65febdb4ab

@ -17,7 +17,7 @@ func (g *Goods) Histroy(c *gin.Context) {
back.Fail(c, err.Error())
return
}
list, err := recook.Order.GetHistoryGoods(c.Request.Header.Get("X-Recook-Id"), c.Request.Header.Get("X-Recook-Token"), page)
list, err := recook.Order.GetHistoryGoods(c.Request.Header.Get("X-Recook-Id"), c.Request.Header.Get("X-Recook-Token"), c.Request.Header.Get("Device-Type"), page)
if err != nil {
back.Fail(c, err.Error())
return

@ -49,7 +49,7 @@ func (s *Short) Publish(c *gin.Context) {
back.Fail(c, "参数错误")
return
}
err := (&short.Short{}).Publish(uid, args.GoodsId, args.TopicId, args.FileId, args.Content, c.Request.Header.Get("X-Recook-Id"), c.Request.Header.Get("X-Recook-Token"))
err := (&short.Short{}).Publish(uid, args.GoodsId, args.TopicId, args.FileId, args.Content, c.Request.Header.Get("X-Recook-Id"), c.Request.Header.Get("X-Recook-Token"), c.Request.Header.Get("Device-Type"))
if err != nil {
back.Fail(c, err.Error())
return

@ -65,6 +65,7 @@ func RequestFormData(url string, data url.Values, headers ...map[string]string)
} else {
reqest.Header.Add("Content-Type", write.FormDataContentType())
}
reqest.Header.Add("X-Recook-System", "recookapi")
response, err := client.Do(reqest)
if err != nil {
return nil, err

@ -26,7 +26,7 @@ type ArgsHistoryList struct {
}
// @Title 获取会员购买历史商品
func (o *order) GetHistoryGoods(id string, token string, page lib.Page) (result *ArgsHistoryList, err error) {
func (o *order) GetHistoryGoods(id string, token, deviceType string, page lib.Page) (result *ArgsHistoryList, err error) {
result = &ArgsHistoryList{}
err = RecookClient.Exec(actionHistory, url.Values{
"page": []string{strconv.Itoa(page.GetPage())},
@ -34,6 +34,7 @@ func (o *order) GetHistoryGoods(id string, token string, page lib.Page) (result
}, result, map[string]string{
"X-Recook-ID": id,
"X-Recook-Token": token,
"Device-Type": deviceType,
})
if err != nil {
return

@ -88,7 +88,7 @@ func (t *trend) GetGoods(goodsIds []uint) (result map[uint]TrendGoods) {
}
// @Title 添加会员动态
func (t *trend) AddTrend(userId, originId uint, trendType, isShow int, id, token string) error {
func (t *trend) AddTrend(userId, originId uint, trendType, isShow int, id, token, deviceType string) error {
result := ""
if userId <= 0 || originId <= 0 || trendType <= 0 {
return errors.New("参数错误")
@ -101,6 +101,7 @@ func (t *trend) AddTrend(userId, originId uint, trendType, isShow int, id, token
}, &result, map[string]string{
"X-Recook-ID": id,
"X-Recook-Token": token,
"Device-Type": deviceType,
}); err != nil {
return err
}

@ -23,11 +23,12 @@ type Userinfo struct {
UserId uint `json:"userId"`
}
func (u *user) GetUserId(id uint, token string) uint {
func (u *user) GetUserId(id uint, token, deviceType string) uint {
userinfo := &Userinfo{}
if err := RecookClient.Exec(actionUserinfo, url.Values{}, userinfo, map[string]string{
"X-Recook-ID": strconv.FormatUint(uint64(id), 10),
"X-Recook-Token": token,
"Device-Type": deviceType,
}); err != nil {
return 0
}

@ -22,7 +22,7 @@ type Short struct {
// @Param topicIc uint true "参与话题id 0=未参与话题"
// @Param fileId string true "腾讯云视频id"
// @Param content string true "发布内容"
func (s *Short) Publish(userId, goodsId, topicId uint, fileId, content string, loginId, token string) error {
func (s *Short) Publish(userId, goodsId, topicId uint, fileId, content string, loginId, token, deviceType string) error {
info, err := tencent.Short.GetInfo(fileId)
if err != nil {
return errors.New("上传视频错误")
@ -41,7 +41,7 @@ func (s *Short) Publish(userId, goodsId, topicId uint, fileId, content string, l
CoverUrl: fileInfo.BasicInfo.CoverUrl,
})
if id > 0 {
err := (&user.Trend{}).AddTrend(userId, id, user.TREND_TYPE_short, 1, loginId, token)
err := (&user.Trend{}).AddTrend(userId, id, user.TREND_TYPE_short, 1, loginId, token, deviceType)
if err != nil {
log.Println("视频上传错误, err:", err)
}

@ -89,8 +89,8 @@ func (t *Trend) GetList(loginUserId, userId uint, page lib.Page) *recook.TrendLi
}
// @Title 添加会员动态信息
func (t *Trend) AddTrend(userId, originId uint, trendType, isShow int, id, token string) error {
return recook.Trend.AddTrend(userId, originId, trendType, isShow, id, token)
func (t *Trend) AddTrend(userId, originId uint, trendType, isShow int, id, token, deviceType string) error {
return recook.Trend.AddTrend(userId, originId, trendType, isShow, id, token, deviceType)
}
// @Title 更改会员动态信息

@ -34,8 +34,10 @@ func Auth() gin.HandlerFunc {
return
}
deviceType := c.Request.Header.Get("Device-Type")
token := c.Request.Header.Get("X-Recook-Token")
userId := recook.User.GetUserId(uint(id), token)
userId := recook.User.GetUserId(uint(id), token, deviceType)
if userId == 0 {
back.Unauthorized(c)
c.Abort()

@ -27,8 +27,9 @@ func BothAuth() gin.HandlerFunc {
return
}
deviceType := c.Request.Header.Get("Device-Type")
token := c.Request.Header.Get("X-Recook-Token")
userId := recook.User.GetUserId(uint(id), token)
userId := recook.User.GetUserId(uint(id), token, deviceType)
if userId == 0 {
return
}

@ -13,7 +13,7 @@ func CORS() gin.HandlerFunc {
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
c.Writer.Header().Set(
"Access-Control-Allow-Headers",
"Content-Type, Cookie, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, token, Cache-Control, X-Recook-ID, X-Recook-Token, X-Requested-With")
"Content-Type, Cookie, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, token, Cache-Control, Device-Type, X-Recook-ID, X-Recook-Token, X-Requested-With")
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET")
if c.Request.Method == "OPTIONS" {

@ -1,6 +1,7 @@
package task
import (
"encoding/json"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
@ -42,9 +43,13 @@ func (live *Live) Run() {
handle = append(handle, *event.EventHandle)
switch *event.EventType {
case "NewFileUpload":
log.Println("NewFileUpload", event)
live.upSuc(event)
case "TranscodeComplete":
log.Println("TranscodeComplete", event)
}
log.Println(event)
marshal, _ := json.Marshal(event)
log.Println(string(marshal))
}
request1.EventHandles = common.StringPtrs(handle)
client.ConfirmEvents(request1)

Loading…
Cancel
Save