You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.2 KiB
58 lines
1.2 KiB
5 years ago
|
package short
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"live/app/common"
|
||
|
"live/app/lib/back"
|
||
|
"live/app/lib/tencent"
|
||
|
"live/app/lib/tools"
|
||
|
"live/app/logic/short"
|
||
|
)
|
||
|
|
||
|
type Short struct {
|
||
|
}
|
||
|
|
||
|
// @Title 获取短视频上传签名
|
||
|
func (s *Short) UploadSign(c *gin.Context) {
|
||
|
uid := common.GetUserId(c)
|
||
|
if uid == 0 {
|
||
|
back.Fail(c, "未登录")
|
||
|
return
|
||
|
}
|
||
|
back.Suc(c, "操作成功", gin.H{
|
||
|
"sign": tencent.Short.Sign(),
|
||
|
})
|
||
|
}
|
||
|
|
||
|
type argsPublish struct {
|
||
|
Content string `json:"content" form:"content"`
|
||
|
FileId string `json:"fileId" form:"fileId"`
|
||
|
TopicId uint `json:"topicId" form:"topicId"`
|
||
|
GoodsId uint `json:"goodsId" form:"goodsId"`
|
||
|
}
|
||
|
|
||
|
// @Title 发布短视频
|
||
|
func (s *Short) Publish(c *gin.Context) {
|
||
|
uid := common.GetUserId(c)
|
||
|
if uid == 0 {
|
||
|
back.Fail(c, "未登录")
|
||
|
return
|
||
|
}
|
||
|
args := argsPublish{}
|
||
|
if err := tools.ParseParams(&args, c); err != nil {
|
||
|
back.Fail(c, err.Error())
|
||
|
return
|
||
|
}
|
||
|
if args.TopicId <= 0 || args.GoodsId <= 0 || args.Content == "" || args.FileId == "" {
|
||
|
back.Fail(c, "参数错误")
|
||
|
return
|
||
|
}
|
||
|
err := (&short.Short{}).Publish(uid, args.GoodsId, args.TopicId, args.FileId, args.Content)
|
||
|
if err != nil {
|
||
|
back.Fail(c, err.Error())
|
||
|
return
|
||
|
}
|
||
|
back.Suc(c, "发布成功", "")
|
||
|
return
|
||
|
}
|