diff --git a/api/channel/v1/channel.go b/api/channel/v1/channel.go index 9821bde..1400f40 100644 --- a/api/channel/v1/channel.go +++ b/api/channel/v1/channel.go @@ -6,6 +6,15 @@ import ( "github.com/gogf/gf/v2/frame/g" ) +type Channel struct { + Id int `json:"id" dc:"频道ID"` + Image string `json:"image" dc:"频道图片"` + Name string `json:"name" dc:"频道名称"` + SubscriptionCount int `json:"subscriptionCount" dc:"频道订阅数量"` + BackgroundImage string `json:"backgroundImage" dc:"频道背景图"` + Status bool `json:"status" dc:"订阅状态"` +} + type ChannelList struct { Id int `json:"id" dc:"频道ID"` Name string `json:"name" dc:"频道名称"` @@ -19,9 +28,9 @@ type GetChannelReq struct { } type GetChannelRes struct { - *entity.GoChannels `json:"channel" dc:"单个频道"` - List []*entity.GoShows `json:"shows" dc:"频道下的所有节目和对应创作人"` - Status bool `json:"status" dc:"订阅状态"` + *Channel `json:"channel" dc:"单个频道"` + List []*entity.GoShows `json:"shows" dc:"频道下的所有节目和对应创作人"` + } type GetChannelListReq struct { diff --git a/internal/controller/channel/channel_v1_get_channel.go b/internal/controller/channel/channel_v1_get_channel.go index d62d16c..96916df 100644 --- a/internal/controller/channel/channel_v1_get_channel.go +++ b/internal/controller/channel/channel_v1_get_channel.go @@ -10,12 +10,12 @@ import ( 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.GoChannels) + err = dao.GoChannels.Ctx(ctx).WherePri(req.Id).Scan(&res.Channel) query := dao.GoShows.Ctx(ctx).With(entity.GoUsers{}).Where("channel_id =?", req.Id) if req.FlagType != 0 { query = query.Where("flag_type =?", req.FlagType) } err = query.Scan(&res.List) - res.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 }