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.

78 lines
1.6 KiB

package short
import (
"github.com/gin-gonic/gin"
"live/app/common"
5 years ago
"live/app/lib"
"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
}
5 years ago
func (s *Short) List(c *gin.Context) {
userId := common.GetUserId(c)
args := lib.Page{}
if err := tools.ParseParams(&args, c); err != nil {
back.Fail(c, err.Error())
return
}
list, count, err := (&short.Short{}).List(userId, args)
if err != nil {
back.Err(c, err.Error())
return
}
back.Suc(c, "操作成功", gin.H{
"total": count,
"list": list,
})
return
}