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.
|
|
package logic
import ( "context" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "practice_Go/api/v1/live_streams" "practice_Go/internal/dao" "practice_Go/internal/model/entity" live "practice_Go/internal/service" )
type sLives struct{}
func init() { live.RegisterLives(NewLive()) } func NewLive() *sLives { return &sLives{} }
// 实现接口 ILive 的方法
func (s *sLives) GetLiveList(ctx context.Context, req *live_streams.GetLiveListReq) (res live_streams.GetLiveListRes, err error) { var list []*entity.LiveStreams err = dao.LiveStreams.Ctx(ctx). OrderAsc("start_time"). // 按开播时间升序
Limit(8). // 取前8条
Scan(&list) if err != nil { g.Log().Errorf(ctx, "直播数据获取失败:%v", err) return res, gerror.Wrap(err, "直播数据服务异常") }
// 将 list 转换为 live_streams.GetLiveListRes 的结构
res.List = list return res, nil }
|