Browse Source

查询已完成

pindao-mj
majun 7 months ago
parent
commit
42f5ed8e7f
  1. 6
      api/channel/v1/channel.go
  2. 7
      internal/controller/channel/channel_v1_get_channel.go

6
api/channel/v1/channel.go

@ -8,11 +8,13 @@ import (
type GetChannelReq struct {
g.Meta `path:"/channel" method:"get" tags:"Channel" summary:"获取单个频道"`
Id int `v:"required|min:1#频道ID不能为空|频道ID不能小于1" dc:"频道ID"`
userId int `v:"required|min:90000000|max:99999999#用户ID不能为空|用户ID不能小于90000000|用户ID不能大于99999999" dc:"用户ID"`
Id int `v:"required|min:1#频道ID不能为空|频道ID不能小于1" dc:"频道ID"`
UserId int `v:"required|min:90000000|max:99999999#用户ID不能为空|用户ID不能小于90000000|用户ID不能大于99999999" dc:"用户ID"`
FlagType int `v:"min:1|max:2#类型不能小于1|类型不能大于2" dc:"列表类型"`
}
type GetChannelRes struct {
*entity.GoChannels `json:"channel" dc:"单个频道"`
List []*entity.GoShows `json:"shows" dc:"频道下的所有节目和对应创作人"`
Status bool `json:"status" dc:"订阅状态"`
}

7
internal/controller/channel/channel_v1_get_channel.go

@ -11,6 +11,11 @@ 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.GoShows.Ctx(ctx).With(entity.GoUsers{}).Where("channel_id =?", req.Id).Scan(&res.List)
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()
return
}
Loading…
Cancel
Save