|
@ -6,15 +6,19 @@ import ( |
|
|
|
|
|
|
|
|
"practice_Go/api/live/v1" |
|
|
"practice_Go/api/live/v1" |
|
|
"practice_Go/internal/dao" |
|
|
"practice_Go/internal/dao" |
|
|
|
|
|
"practice_Go/internal/model/dto" |
|
|
"practice_Go/internal/model/entity" |
|
|
"practice_Go/internal/model/entity" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func (c *ControllerV1) GetLive(ctx context.Context, req *v1.GetLiveReq) (res *v1.GetLiveRes, err error) { |
|
|
|
|
|
res = &v1.GetLiveRes{} |
|
|
|
|
|
|
|
|
func (c *ControllerV1) GetLive(ctx context.Context, req *v1.GetLiveReq) (*dto.Result, error) { |
|
|
|
|
|
res := v1.GetLiveRes{} |
|
|
now := time.Now() |
|
|
now := time.Now() |
|
|
err = dao.GoLives.Ctx(ctx).With(entity.GoUsers{}).Where("start_time >=? or status = 1", now).Order("status desc, start_time asc").Scan(&res.List) |
|
|
|
|
|
|
|
|
err := dao.GoLives.Ctx(ctx).With(entity.GoUsers{}).Where("start_time >=? or status = 1", now).Order("status desc, start_time asc").Scan(&res.List) |
|
|
for i, live := range res.List { |
|
|
for i, live := range res.List { |
|
|
res.List[i].Reservation, err = dao.GoLiveReservations.Ctx(ctx).Wheref("live_id =? and user_id =?", live.Id, req.UserId).Count() |
|
|
res.List[i].Reservation, err = dao.GoLiveReservations.Ctx(ctx).Wheref("live_id =? and user_id =?", live.Id, req.UserId).Count() |
|
|
} |
|
|
} |
|
|
return |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return dto.Error(err.Error()), nil |
|
|
|
|
|
} |
|
|
|
|
|
return dto.SuccessWithData(res.List), nil |
|
|
} |
|
|
} |