Browse Source

增加频道列表

pindao-mj
majun 7 months ago
parent
commit
4524c0b941
  1. 1
      api/channel/channel.go
  2. 13
      api/channel/v1/channel.go
  3. 14
      internal/controller/channel/channel_v1_get_channel_list.go

1
api/channel/channel.go

@ -12,4 +12,5 @@ import (
type IChannelV1 interface {
GetChannel(ctx context.Context, req *v1.GetChannelReq) (res *v1.GetChannelRes, err error)
GetChannelList(ctx context.Context, req *v1.GetChannelListReq) (res *v1.GetChannelListRes, err error)
}

13
api/channel/v1/channel.go

@ -6,6 +6,11 @@ import (
"github.com/gogf/gf/v2/frame/g"
)
type ChannelList struct {
Id int `json:"id" dc:"频道ID"`
Name string `json:"name" dc:"频道名称"`
}
type GetChannelReq struct {
g.Meta `path:"/channel" method:"get" tags:"Channel" summary:"获取单个频道"`
Id int `v:"required|min:1#频道ID不能为空|频道ID不能小于1" dc:"频道ID"`
@ -17,4 +22,12 @@ type GetChannelRes struct {
*entity.GoChannels `json:"channel" dc:"单个频道"`
List []*entity.GoShows `json:"shows" dc:"频道下的所有节目和对应创作人"`
Status bool `json:"status" dc:"订阅状态"`
}
type GetChannelListReq struct {
g.Meta `path:"/list" method:"get" tags:"ChannelList" summary:"获取频道列表"`
}
type GetChannelListRes struct {
List []*ChannelList `json:"list" dc:"频道列表"`
}

14
internal/controller/channel/channel_v1_get_channel_list.go

@ -0,0 +1,14 @@
package channel
import (
"context"
"practice_Go/api/channel/v1"
"practice_Go/internal/dao"
)
func (c *ControllerV1) GetChannelList(ctx context.Context, req *v1.GetChannelListReq) (res *v1.GetChannelListRes, err error) {
res = &v1.GetChannelListRes{}
err = dao.GoChannels.Ctx(ctx).Fields("id, name").Scan(&res.List)
return
}
Loading…
Cancel
Save