parent
7a12a0fcdc
commit
083404cf7b
@ -0,0 +1,70 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"live/app/lib"
|
||||
"live/app/lib/back"
|
||||
"live/app/lib/tools"
|
||||
live2 "live/app/model/live"
|
||||
)
|
||||
|
||||
type Live struct {
|
||||
}
|
||||
type argsUserList struct {
|
||||
UserId uint `json:"userId" form:"userId"`
|
||||
lib.Page
|
||||
}
|
||||
|
||||
type replyItem struct {
|
||||
Id uint `json:"id"`
|
||||
GoodsCount uint `json:"goodsCount"`
|
||||
Cover string `json:"cover"`
|
||||
Look int `json:"look"`
|
||||
Title string `json:"title"`
|
||||
IsLive int `json:"isLive"`
|
||||
StartAt int64 `json:"startAt"`
|
||||
}
|
||||
|
||||
// @Title 用户直播场次列表
|
||||
func (l *Live) UserList(c *gin.Context) {
|
||||
args := argsUserList{}
|
||||
if err := tools.ParseParams(&args, c); err != nil {
|
||||
back.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
if args.UserId <= 0 {
|
||||
back.Fail(c, "参数错误")
|
||||
return
|
||||
}
|
||||
liveItemModel := &live2.LiveItem{}
|
||||
start := args.GetStart()
|
||||
total := int(liveItemModel.GetUserListTotal(args.UserId))
|
||||
resultList := []replyItem{}
|
||||
if total > start {
|
||||
lists := liveItemModel.GetUserList(args.UserId, args.GetStart(), args.GetLimit())
|
||||
liveItemIds := []uint{}
|
||||
for _, list := range lists {
|
||||
liveItemIds = append(liveItemIds, list.Id)
|
||||
}
|
||||
liveDatas := (&live2.LiveData{}).GetByLiveItemIds(liveItemIds)
|
||||
liveDataMap := map[uint]live2.LiveData{}
|
||||
for _, data := range liveDatas {
|
||||
liveDataMap[data.LiveItemId] = data
|
||||
}
|
||||
for _, list := range lists {
|
||||
resultList = append(resultList, replyItem{
|
||||
Id: list.Id,
|
||||
Title: list.Title,
|
||||
IsLive: list.Status,
|
||||
Look: liveDataMap[list.Id].Look,
|
||||
GoodsCount: list.GoodsCount,
|
||||
Cover: list.Cover,
|
||||
StartAt: list.StartAt.Time.Unix(),
|
||||
})
|
||||
}
|
||||
}
|
||||
back.Suc(c, "操作成功", gin.H{
|
||||
"total": total,
|
||||
"lists": resultList,
|
||||
})
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "编译中"
|
||||
go-bindata -o=./app/lib/asset/asset.go -pkg=asset config/...
|
||||
|
||||
# shellcheck disable=SC2006
|
||||
DIR=`dirname "$0"`
|
||||
# shellcheck disable=SC2164
|
||||
# shellcheck disable=SC2086
|
||||
cd $DIR
|
||||
|
||||
if [[ -f "./bin/recook" ]];then
|
||||
echo "删除原来执行文件..."
|
||||
rm ./bin/recook
|
||||
fi
|
||||
|
||||
GOPROXY=https://goproxy.cn GOSUMDB=off GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/recook_live
|
||||
echo "🎄🎄🎄🎄🎄🎄🎄🎄编译完成🎄🎄🎄🎄🎄🎄🎄🎄🎄"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in new issue