|
@ -5,17 +5,21 @@ import ( |
|
|
|
|
|
|
|
|
"practice_Go/api/channel/v1" |
|
|
"practice_Go/api/channel/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) GetChannel(ctx context.Context, req *v1.GetChannelReq) (res *v1.GetChannelRes, err error) { |
|
|
|
|
|
res = &v1.GetChannelRes{} |
|
|
|
|
|
err = dao.GoChannels.Ctx(ctx).WherePri(req.Id).Scan(&res.Channel) |
|
|
|
|
|
|
|
|
func (c *ControllerV1) GetChannel(ctx context.Context, req *v1.GetChannelReq) (*dto.Result, error) { |
|
|
|
|
|
res := v1.GetChannelRes{} |
|
|
|
|
|
err := dao.GoChannels.Ctx(ctx).WherePri(req.Id).Scan(&res.Channel) |
|
|
query := dao.GoShows.Ctx(ctx).With(entity.GoUsers{}).Where("channel_id =?", req.Id) |
|
|
query := dao.GoShows.Ctx(ctx).With(entity.GoUsers{}).Where("channel_id =?", req.Id) |
|
|
if req.FlagType != 0 { |
|
|
if req.FlagType != 0 { |
|
|
query = query.Where("flag_type =?", req.FlagType) |
|
|
query = query.Where("flag_type =?", req.FlagType) |
|
|
} |
|
|
} |
|
|
err = query.Scan(&res.List) |
|
|
err = query.Scan(&res.List) |
|
|
res.Channel.Status, err = dao.GoChannelSubscriptions.Ctx(ctx).Wheref("channel_id =? and user_id =?", req.Id, req.UserId).Exist() |
|
|
res.Channel.Status, err = dao.GoChannelSubscriptions.Ctx(ctx).Wheref("channel_id =? and user_id =?", req.Id, req.UserId).Exist() |
|
|
return |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return dto.Error(err.Error()), nil |
|
|
|
|
|
} |
|
|
|
|
|
return dto.SuccessWithData(res), nil |
|
|
} |
|
|
} |