35 changed files with 960 additions and 74 deletions
-
16api/channel/channel.go
-
33api/channel/v1/channel.go
-
15api/live/live.go
-
21api/live/v1/live.go
-
16api/reservation/reservation.go
-
23api/reservation/v1/reservation.go
-
16api/subscription/subscription.go
-
23api/subscription/v1/subscription.go
-
2go.mod
-
34go.sum
-
2hack/config.yaml
-
18internal/cmd/cmd.go
-
5internal/controller/channel/channel.go
-
15internal/controller/channel/channel_new.go
-
21internal/controller/channel/channel_v1_get_channel.go
-
14internal/controller/channel/channel_v1_get_channel_list.go
-
5internal/controller/live/live.go
-
15internal/controller/live/live_new.go
-
20internal/controller/live/live_v1_get_live.go
-
5internal/controller/reservation/reservation.go
-
15internal/controller/reservation/reservation_new.go
-
21internal/controller/reservation/reservation_v1_add_reservation.go
-
17internal/controller/reservation/reservation_v1_delete_reservation.go
-
5internal/controller/subscription/subscription.go
-
15internal/controller/subscription/subscription_new.go
-
21internal/controller/subscription/subscription_v1_add_subscription.go
-
17internal/controller/subscription/subscription_v1_delete_subscription.go
-
4internal/logic/shows/shows.go
-
6internal/model/entity/go_channel_subscriptions.go
-
10internal/model/entity/go_channels.go
-
6internal/model/entity/go_live_reservations.go
-
13internal/model/entity/go_lives.go
-
29internal/model/entity/go_shows.go
-
4main.go
-
532resource/public/html/api.html
@ -0,0 +1,16 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package channel |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/channel/v1" |
|||
) |
|||
|
|||
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) |
|||
} |
@ -0,0 +1,33 @@ |
|||
package v1 |
|||
|
|||
import ( |
|||
"practice_Go/internal/model/entity" |
|||
|
|||
"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"` |
|||
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:"订阅状态"` |
|||
} |
|||
|
|||
type GetChannelListReq struct { |
|||
g.Meta `path:"/list" method:"get" tags:"ChannelList" summary:"获取频道列表"` |
|||
} |
|||
|
|||
type GetChannelListRes struct { |
|||
List []*ChannelList `json:"list" dc:"频道列表"` |
|||
} |
@ -0,0 +1,15 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package live |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/live/v1" |
|||
) |
|||
|
|||
type ILiveV1 interface { |
|||
GetLive(ctx context.Context, req *v1.GetLiveReq) (res *v1.GetLiveRes, err error) |
|||
} |
@ -0,0 +1,21 @@ |
|||
package v1 |
|||
|
|||
import ( |
|||
"practice_Go/internal/model/entity" |
|||
|
|||
"github.com/gogf/gf/v2/frame/g" |
|||
) |
|||
|
|||
type Live struct { |
|||
entity.GoLives |
|||
Reservation int `json:"reservation" dc:"预约状态"` |
|||
} |
|||
|
|||
type GetLiveReq struct { |
|||
g.Meta `path:"/live" method:"get" tags:"Live" summary:"获取直播列表"` |
|||
UserId int `v:"required|min:90000000|max:99999999#用户ID不能为空|用户ID不能小于90000000|用户ID不能大于99999999" dc:"用户ID"` |
|||
} |
|||
|
|||
type GetLiveRes struct { |
|||
List []*Live `json:"liveList" dc:"直播列表"` |
|||
} |
@ -0,0 +1,16 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package reservation |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/reservation/v1" |
|||
) |
|||
|
|||
type IReservationV1 interface { |
|||
AddReservation(ctx context.Context, req *v1.AddReservationReq) (res *v1.AddReservationRes, err error) |
|||
DeleteReservation(ctx context.Context, req *v1.DeleteReservationReq) (res *v1.DeleteReservationRes, err error) |
|||
} |
@ -0,0 +1,23 @@ |
|||
package v1 |
|||
|
|||
import "github.com/gogf/gf/v2/frame/g" |
|||
|
|||
type AddReservationReq struct { |
|||
g.Meta `path:"/reservation" method:"post" tags:"Reservation" 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"` |
|||
} |
|||
|
|||
type AddReservationRes struct { |
|||
Success bool `json:"success" dc:"预约是否成功"` |
|||
} |
|||
|
|||
type DeleteReservationReq struct { |
|||
g.Meta `path:"/reservation" method:"delete" tags:"Reservation" 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"` |
|||
} |
|||
|
|||
type DeleteReservationRes struct { |
|||
Success bool `json:"success" dc:"取消预约是否成功"` |
|||
} |
@ -0,0 +1,16 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package subscription |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/subscription/v1" |
|||
) |
|||
|
|||
type ISubscriptionV1 interface { |
|||
AddSubscription(ctx context.Context, req *v1.AddSubscriptionReq) (res *v1.AddSubscriptionRes, err error) |
|||
DeleteSubscription(ctx context.Context, req *v1.DeleteSubscriptionReq) (res *v1.DeleteSubscriptionRes, err error) |
|||
} |
@ -0,0 +1,23 @@ |
|||
package v1 |
|||
|
|||
import "github.com/gogf/gf/v2/frame/g" |
|||
|
|||
type AddSubscriptionReq struct { |
|||
g.Meta `path:"/subscription" method:"post" tags:"Subscription" 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"` |
|||
} |
|||
|
|||
type AddSubscriptionRes struct { |
|||
Success bool `json:"success" dc:"订阅是否成功"` |
|||
} |
|||
|
|||
type DeleteSubscriptionReq struct { |
|||
g.Meta `path:"/subscription" method:"delete" tags:"Subscription" 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"` |
|||
} |
|||
|
|||
type DeleteSubscriptionRes struct { |
|||
Success bool `json:"success" dc:"取消订阅是否成功"` |
|||
} |
@ -0,0 +1,5 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package channel |
@ -0,0 +1,15 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package channel |
|||
|
|||
import ( |
|||
"practice_Go/api/channel" |
|||
) |
|||
|
|||
type ControllerV1 struct{} |
|||
|
|||
func NewV1() channel.IChannelV1 { |
|||
return &ControllerV1{} |
|||
} |
@ -0,0 +1,21 @@ |
|||
package channel |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/channel/v1" |
|||
"practice_Go/internal/dao" |
|||
"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.GoChannels) |
|||
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 |
|||
} |
@ -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 |
|||
} |
@ -0,0 +1,5 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package live |
@ -0,0 +1,15 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package live |
|||
|
|||
import ( |
|||
"practice_Go/api/live" |
|||
) |
|||
|
|||
type ControllerV1 struct{} |
|||
|
|||
func NewV1() live.ILiveV1 { |
|||
return &ControllerV1{} |
|||
} |
@ -0,0 +1,20 @@ |
|||
package live |
|||
|
|||
import ( |
|||
"context" |
|||
"time" |
|||
|
|||
"practice_Go/api/live/v1" |
|||
"practice_Go/internal/dao" |
|||
"practice_Go/internal/model/entity" |
|||
) |
|||
|
|||
func (c *ControllerV1) GetLive(ctx context.Context, req *v1.GetLiveReq) (res *v1.GetLiveRes, err error) { |
|||
res = &v1.GetLiveRes{} |
|||
now := time.Now() |
|||
err = dao.GoLives.Ctx(ctx).With(entity.GoUsers{}).Where("start_time >=? or status = 1", now).Order("status desc, start_time asc").Scan(&res.List) |
|||
for i, live := range res.List { |
|||
res.List[i].Reservation, err = dao.GoLiveReservations.Ctx(ctx).Wheref("live_id =? and user_id =?", live.Id, req.UserId).Count() |
|||
} |
|||
return |
|||
} |
@ -0,0 +1,5 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package reservation |
@ -0,0 +1,15 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package reservation |
|||
|
|||
import ( |
|||
"practice_Go/api/reservation" |
|||
) |
|||
|
|||
type ControllerV1 struct{} |
|||
|
|||
func NewV1() reservation.IReservationV1 { |
|||
return &ControllerV1{} |
|||
} |
@ -0,0 +1,21 @@ |
|||
package reservation |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/reservation/v1" |
|||
"practice_Go/internal/dao" |
|||
"practice_Go/internal/model/do" |
|||
) |
|||
|
|||
func (c *ControllerV1) AddReservation(ctx context.Context, req *v1.AddReservationReq) (res *v1.AddReservationRes, err error) { |
|||
res = &v1.AddReservationRes{} |
|||
_, err = dao.GoLiveReservations.Ctx(ctx).Data(do.GoLiveReservations{ |
|||
LiveId: req.Id, |
|||
UserId: req.UserId, |
|||
}).Insert() |
|||
if err == nil { |
|||
res.Success = true |
|||
} |
|||
return |
|||
} |
@ -0,0 +1,17 @@ |
|||
package reservation |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/reservation/v1" |
|||
"practice_Go/internal/dao" |
|||
) |
|||
|
|||
func (c *ControllerV1) DeleteReservation(ctx context.Context, req *v1.DeleteReservationReq) (res *v1.DeleteReservationRes, err error) { |
|||
res = &v1.DeleteReservationRes{} |
|||
_, err = dao.GoLiveReservations.Ctx(ctx).Wheref("live_id =? and user_id =?", req.Id, req.UserId).Delete() |
|||
if err == nil { |
|||
res.Success = true |
|||
} |
|||
return |
|||
} |
@ -0,0 +1,5 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package subscription |
@ -0,0 +1,15 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package subscription |
|||
|
|||
import ( |
|||
"practice_Go/api/subscription" |
|||
) |
|||
|
|||
type ControllerV1 struct{} |
|||
|
|||
func NewV1() subscription.ISubscriptionV1 { |
|||
return &ControllerV1{} |
|||
} |
@ -0,0 +1,21 @@ |
|||
package subscription |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/subscription/v1" |
|||
"practice_Go/internal/dao" |
|||
"practice_Go/internal/model/do" |
|||
) |
|||
|
|||
func (c *ControllerV1) AddSubscription(ctx context.Context, req *v1.AddSubscriptionReq) (res *v1.AddSubscriptionRes, err error) { |
|||
res = &v1.AddSubscriptionRes{} |
|||
_, err = dao.GoChannelSubscriptions.Ctx(ctx).Data(do.GoChannelSubscriptions{ |
|||
ChannelId: req.Id, |
|||
UserId: req.UserId, |
|||
}).Insert() |
|||
if err == nil { |
|||
res.Success = true |
|||
} |
|||
return |
|||
} |
@ -0,0 +1,17 @@ |
|||
package subscription |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/subscription/v1" |
|||
"practice_Go/internal/dao" |
|||
) |
|||
|
|||
func (c *ControllerV1) DeleteSubscription(ctx context.Context, req *v1.DeleteSubscriptionReq) (res *v1.DeleteSubscriptionRes, err error) { |
|||
res = &v1.DeleteSubscriptionRes{} |
|||
_, err = dao.GoChannelSubscriptions.Ctx(ctx).Wheref("channel_id =? and user_id =?", req.Id, req.UserId).Delete() |
|||
if err == nil { |
|||
res.Success = true |
|||
} |
|||
return |
|||
} |
532
resource/public/html/api.html
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue