majun 7 months ago
parent
commit
ec0b0030f5
  1. 15
      api/channel/v1/channel.go
  2. 4
      internal/controller/channel/channel_v1_get_channel.go

15
api/channel/v1/channel.go

@ -6,6 +6,15 @@ import (
"github.com/gogf/gf/v2/frame/g" "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 { type ChannelList struct {
Id int `json:"id" dc:"频道ID"` Id int `json:"id" dc:"频道ID"`
Name string `json:"name" dc:"频道名称"` Name string `json:"name" dc:"频道名称"`
@ -19,9 +28,9 @@ type GetChannelReq struct {
} }
type GetChannelRes 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 { type GetChannelListReq struct {

4
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) { func (c *ControllerV1) GetChannel(ctx context.Context, req *v1.GetChannelReq) (res *v1.GetChannelRes, err error) {
res = &v1.GetChannelRes{} 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) 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.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 return
} }
Loading…
Cancel
Save