Browse Source

12.3下午四个模块合并后提交

dev
lijikun 7 months ago
parent
commit
3f75331b40
  1. 16
      api/channel/channel.go
  2. 33
      api/channel/v1/channel.go
  3. 15
      api/live/live.go
  4. 21
      api/live/v1/live.go
  5. 16
      api/reservation/reservation.go
  6. 23
      api/reservation/v1/reservation.go
  7. 16
      api/subscription/subscription.go
  8. 23
      api/subscription/v1/subscription.go
  9. 2
      go.mod
  10. 34
      go.sum
  11. 2
      hack/config.yaml
  12. 18
      internal/cmd/cmd.go
  13. 5
      internal/controller/channel/channel.go
  14. 15
      internal/controller/channel/channel_new.go
  15. 21
      internal/controller/channel/channel_v1_get_channel.go
  16. 14
      internal/controller/channel/channel_v1_get_channel_list.go
  17. 5
      internal/controller/live/live.go
  18. 15
      internal/controller/live/live_new.go
  19. 20
      internal/controller/live/live_v1_get_live.go
  20. 5
      internal/controller/reservation/reservation.go
  21. 15
      internal/controller/reservation/reservation_new.go
  22. 21
      internal/controller/reservation/reservation_v1_add_reservation.go
  23. 17
      internal/controller/reservation/reservation_v1_delete_reservation.go
  24. 5
      internal/controller/subscription/subscription.go
  25. 15
      internal/controller/subscription/subscription_new.go
  26. 21
      internal/controller/subscription/subscription_v1_add_subscription.go
  27. 17
      internal/controller/subscription/subscription_v1_delete_subscription.go
  28. 4
      internal/logic/shows/shows.go
  29. 6
      internal/model/entity/go_channel_subscriptions.go
  30. 10
      internal/model/entity/go_channels.go
  31. 6
      internal/model/entity/go_live_reservations.go
  32. 13
      internal/model/entity/go_lives.go
  33. 29
      internal/model/entity/go_shows.go
  34. 4
      main.go
  35. 532
      resource/public/html/api.html

16
api/channel/channel.go

@ -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)
}

33
api/channel/v1/channel.go

@ -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:"频道列表"`
}

15
api/live/live.go

@ -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)
}

21
api/live/v1/live.go

@ -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:"直播列表"`
}

16
api/reservation/reservation.go

@ -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)
}

23
api/reservation/v1/reservation.go

@ -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:"取消预约是否成功"`
}

16
api/subscription/subscription.go

@ -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)
}

23
api/subscription/v1/subscription.go

@ -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:"取消订阅是否成功"`
}

2
go.mod

@ -3,14 +3,12 @@ module practice_Go
go 1.18
require (
github.com/gogf/gf v1.16.9
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1
github.com/gogf/gf/v2 v2.8.1
)
require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 // indirect
github.com/clbanning/mxj/v2 v2.7.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.17.0 // indirect

34
go.sum

@ -1,17 +1,12 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@ -19,27 +14,21 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/gogf/gf v1.16.9/go.mod h1:8Q/kw05nlVRp+4vv7XASBsMe9L1tsVKiGoeP2AHnlkk=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 h1:jbaPawkb8qmaYzrmBDbTa8Zkhzacq1RBOZw+qRJExI4=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1/go.mod h1:s2aI1fV9AvKi4NtMpv3pV0EHtazkvfUNVQmzapr7UJQ=
github.com/gogf/gf/v2 v2.8.1 h1:1oVQg3G5OgCats4qWFTH3pHLe92nfUQeUDta05tUs1g=
github.com/gogf/gf/v2 v2.8.1/go.mod h1:6iYuZZ+A0ZcH8+4MDS/P0SvTPCvKzRvyAsY1kbkJYJc=
github.com/gomodule/redigo v1.8.5/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4=
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
@ -49,46 +38,27 @@ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

2
hack/config.yaml

@ -1,3 +1,4 @@
# CLI tool, only in development environment.
# https://goframe.org/docs/cli
gfcli:
@ -6,7 +7,6 @@ gfcli:
- link: "mysql:root:80083@tcp(127.0.0.1:3306)/linktest?charset=utf8mb4&parseTime=True&loc=Local"
table: "go_users, go_shows, go_lives, go_live_reservations, go_club, go_channels,go_channel_subscriptions"
descriptionTag: true
jsonCase: "Snake"
docker:
build: "-a amd64 -s linux -p temp -ew"

18
internal/cmd/cmd.go

@ -2,11 +2,16 @@ package cmd
import (
"context"
"practice_Go/internal/controller/channel"
"practice_Go/internal/controller/live"
"practice_Go/internal/controller/reservation"
"practice_Go/internal/controller/subscription"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"practice_Go/internal/controller/clubPage"
"practice_Go/internal/controller/mainPage"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gcmd"
)
@ -17,6 +22,15 @@ var (
Brief: "start http server",
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
s := g.Server()
s.Group("/", func(group *ghttp.RouterGroup) {
group.Middleware(ghttp.MiddlewareHandlerResponse)
group.Bind(
channel.NewV1(),
subscription.NewV1(),
live.NewV1(),
reservation.NewV1(),
)
})
// 定义一个路由组,路径为/mainpage
s.Group("/mainpage", func(group *ghttp.RouterGroup) {
@ -38,8 +52,6 @@ var (
)
})
s.Run()
//开启静态资源
s.SetServerRoot("resource/public")
s.SetOpenApiPath("/api.json") //启用OpenAPIv3,并设置OpenAPI文档的路径

5
internal/controller/channel/channel.go

@ -0,0 +1,5 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package channel

15
internal/controller/channel/channel_new.go

@ -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{}
}

21
internal/controller/channel/channel_v1_get_channel.go

@ -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
}

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
}

5
internal/controller/live/live.go

@ -0,0 +1,5 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package live

15
internal/controller/live/live_new.go

@ -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{}
}

20
internal/controller/live/live_v1_get_live.go

@ -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
}

5
internal/controller/reservation/reservation.go

@ -0,0 +1,5 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package reservation

15
internal/controller/reservation/reservation_new.go

@ -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{}
}

21
internal/controller/reservation/reservation_v1_add_reservation.go

@ -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
}

17
internal/controller/reservation/reservation_v1_delete_reservation.go

@ -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
}

5
internal/controller/subscription/subscription.go

@ -0,0 +1,5 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package subscription

15
internal/controller/subscription/subscription_new.go

@ -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{}
}

21
internal/controller/subscription/subscription_v1_add_subscription.go

@ -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
}

17
internal/controller/subscription/subscription_v1_delete_subscription.go

@ -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
}

4
internal/logic/shows/shows.go

@ -20,7 +20,7 @@ type sShow struct{}
// 定义一个方法,用于获取所有节目
func (s sShow) GetShows(ctx context.Context) (shows []entity.GoShows, err error) {
// 使用dao包中的GoShows结构体,在指定的上下文中扫描数据,并将结果存储在shows变量中
flagType := g.RequestFromCtx(ctx).Get("flag_type").Int()
flagType := g.RequestFromCtx(ctx).Get("flagType").Int()
if flagType != 0 {
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}, entity.GoClubs{}).Where("flag_type", flagType).Scan(&shows) //err用于存储过程中可能出现的错误,结果直接存到shows中了
} else {
@ -33,7 +33,7 @@ func (s sShow) GetShows(ctx context.Context) (shows []entity.GoShows, err error)
// 定义一个方法,用于获取视频列表
func (s sShow) GetVideos(ctx context.Context) (videos []entity.GoShows, err error) {
// 使用dao包中的GoShows结构体,在指定的上下文中扫描视频列表
flagType := g.RequestFromCtx(ctx).Get("flag_type").Int()
flagType := g.RequestFromCtx(ctx).Get("flagType").Int()
if flagType != 0 {
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}, entity.GoClubs{}).Where("flag_type", flagType).OrderDesc("release_time").Scan(&videos) //err用于存储过程中可能出现的错误,结果直接存到shows中了
} else {

6
internal/model/entity/go_channel_subscriptions.go

@ -6,7 +6,7 @@ package entity
// GoChannelSubscriptions is the golang structure for table go_channel_subscriptions.
type GoChannelSubscriptions struct {
Id int `json:"id" orm:"id" description:"频道订阅关系唯一ID,自增"` // 频道订阅关系唯一ID,自增
UserId int `json:"user_id" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
ChannelId int `json:"channel_id" orm:"channel_id" description:"关联的频道ID,指向go_channels表的id,不能为空"` // 关联的频道ID,指向go_channels表的id,不能为空
Id int `json:"id" orm:"id" description:"频道订阅关系唯一ID,自增"` // 频道订阅关系唯一ID,自增
UserId int `json:"userId" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
ChannelId int `json:"channelId" orm:"channel_id" description:"关联的频道ID,指向go_channels表的id,不能为空"` // 关联的频道ID,指向go_channels表的id,不能为空
}

10
internal/model/entity/go_channels.go

@ -6,9 +6,9 @@ package entity
// GoChannels is the golang structure for table go_channels.
type GoChannels struct {
Id int `json:"id" orm:"id" description:"频道唯一ID,自增"` // 频道唯一ID,自增
Image string `json:"image" orm:"image" description:"频道图片路径或相关标识,可为空"` // 频道图片路径或相关标识,可为空
Name string `json:"name" orm:"name" description:"频道名称,最大长度255字符,不能为空"` // 频道名称,最大长度255字符,不能为空
SubscriptionCount int `json:"subscription_count" orm:"subscription_count" description:"频道订阅数量,初始值为0,可累加"` // 频道订阅数量,初始值为0,可累加
BackgroundImage string `json:"background_image" orm:"background_image" description:"频道背景图路径或相关标识,可为空"` // 频道背景图路径或相关标识,可为空
Id int `json:"id" orm:"id" description:"频道唯一ID,自增"` // 频道唯一ID,自增
Image string `json:"image" orm:"image" description:"频道图片路径或相关标识,可为空"` // 频道图片路径或相关标识,可为空
Name string `json:"name" orm:"name" description:"频道名称,最大长度255字符,不能为空"` // 频道名称,最大长度255字符,不能为空
SubscriptionCount int `json:"subscriptionCount" orm:"subscription_count" description:"频道订阅数量,初始值为0,可累加"` // 频道订阅数量,初始值为0,可累加
BackgroundImage string `json:"backgroundImage" orm:"background_image" description:"频道背景图路径或相关标识,可为空"` // 频道背景图路径或相关标识,可为空
}

6
internal/model/entity/go_live_reservations.go

@ -6,7 +6,7 @@ package entity
// GoLiveReservations is the golang structure for table go_live_reservations.
type GoLiveReservations struct {
Id int `json:"id" orm:"id" description:"直播预约关系唯一ID,自增"` // 直播预约关系唯一ID,自增
UserId int `json:"user_id" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
LiveId int `json:"live_id" orm:"live_id" description:"关联的直播ID,指向go_lives表的id,不能为空"` // 关联的直播ID,指向go_lives表的id,不能为空
Id int `json:"id" orm:"id" description:"直播预约关系唯一ID,自增"` // 直播预约关系唯一ID,自增
UserId int `json:"userId" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
LiveId int `json:"liveId" orm:"live_id" description:"关联的直播ID,指向go_lives表的id,不能为空"` // 关联的直播ID,指向go_lives表的id,不能为空
}

13
internal/model/entity/go_lives.go

@ -10,10 +10,11 @@ import (
// GoLives is the golang structure for table go_lives.
type GoLives struct {
Id int `json:"id" orm:"id" description:"直播唯一ID,自增"` // 直播唯一ID,自增
Cover string `json:"cover" orm:"cover" description:"直播封面路径或相关标识,可为空"` // 直播封面路径或相关标识,可为空
UserId int `json:"user_id" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
LiveName string `json:"live_name" orm:"live_name" description:"直播名称,最大长度255字符,不能为空"` // 直播名称,最大长度255字符,不能为空
StartTime *gtime.Time `json:"start_time" orm:"start_time" description:"直播开始时间,不能为空"` // 直播开始时间,不能为空
Status int `json:"status" orm:"status" description:"直播状态,0:未开播 1:已开播,不能为空"` // 直播状态,0:未开播 1:已开播,不能为空
Id int `json:"id" orm:"id" description:"直播唯一ID,自增"` // 直播唯一ID,自增
Cover string `json:"cover" orm:"cover" description:"直播封面路径或相关标识,可为空"` // 直播封面路径或相关标识,可为空
UserId int `json:"userId" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
User *GoUsers `json:"user" orm:"with:id=user_id" description:"关联的用户信息"` // 关联的用户信息
LiveName string `json:"liveName" orm:"live_name" description:"直播名称,最大长度255字符,不能为空"` // 直播名称,最大长度255字符,不能为空
StartTime *gtime.Time `json:"startTime" orm:"start_time" description:"直播开始时间,不能为空"` // 直播开始时间,不能为空
Status int `json:"status" orm:"status" description:"直播状态,0:未开播 1:已开播,不能为空"` // 直播状态,0:未开播 1:已开播,不能为空
}

29
internal/model/entity/go_shows.go

@ -10,19 +10,18 @@ import (
// GoShows is the golang structure for table go_shows.
type GoShows struct {
Id int `json:"id" orm:"id" description:"展示内容唯一ID,自增"` // 展示内容唯一ID,自增
Cover string `json:"cover" orm:"cover" description:"展示内容封面路径或相关标识,可为空"` // 展示内容封面路径或相关标识,可为空
Name string `json:"name" orm:"name" description:"展示内容名称,最大长度255字符,不能为空"` // 展示内容名称,最大长度255字符,不能为空
UserId int `json:"user_id" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
ReleaseTime *gtime.Time `json:"release_time" orm:"release_time" description:"展示内容发布时间,可为空"` // 展示内容发布时间,可为空
VideoDuration *gtime.Time `json:"video_duration" orm:"video_duration" description:"展示内容视频时长,格式根据实际情况定,可为空"` // 展示内容视频时长,格式根据实际情况定,可为空
ViewCount int `json:"view_count" orm:"view_count" description:"展示内容观看数量,初始值为0,可累加"` // 展示内容观看数量,初始值为0,可累加
Comments int `json:"comments" orm:"comments" description:"展示内容评论数量,初始值为0,可累加"` // 展示内容评论数量,初始值为0,可累加
Likes int `json:"likes" orm:"likes" description:"展示内容点赞数量,初始值为0,可累加"` // 展示内容点赞数量,初始值为0,可累加
FlagType int `json:"flag_type" orm:"flag_type" description:"展示内容标识类型,按业务规则确定,可为空"` // 展示内容标识类型,按业务规则确定,可为空
ClubId int `json:"club_id" orm:"club_id" description:"关联的俱乐部ID,指向go_clubs表的id,可为空"` // 关联的俱乐部ID,指向go_clubs表的id,可为空
ChannelId int `json:"channel_id" orm:"channel_id" description:"关联的频道ID,指向go_channels表的id,可为空"` // 关联的频道ID,指向go_channels表的id,可为空
User *GoUsers `json:"user" orm:"with:id=user_id"`
Club *GoClubs `json:"club" orm:"with:id=club_id"`
Id int `json:"id" orm:"id" description:"展示内容唯一ID,自增"` // 展示内容唯一ID,自增
Cover string `json:"cover" orm:"cover" description:"展示内容封面路径或相关标识,可为空"` // 展示内容封面路径或相关标识,可为空
Name string `json:"name" orm:"name" description:"展示内容名称,最大长度255字符,不能为空"` // 展示内容名称,最大长度255字符,不能为空
UserId int `json:"userId" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
User *GoUsers `json:"user" orm:"with:id=user_id" description:"关联的用户信息"` // 关联的用户信息
ReleaseTime *gtime.Time `json:"releaseTime" orm:"release_time" description:"展示内容发布时间,可为空"` // 展示内容发布时间,可为空
VideoDuration *gtime.Time `json:"videoDuration" orm:"video_duration" description:"展示内容视频时长,格式根据实际情况定,可为空"` // 展示内容视频时长,格式根据实际情况定,可为空
ViewCount int `json:"viewCount" orm:"view_count" description:"展示内容观看数量,初始值为0,可累加"` // 展示内容观看数量,初始值为0,可累加
Comments int `json:"comments" orm:"comments" description:"展示内容评论数量,初始值为0,可累加"` // 展示内容评论数量,初始值为0,可累加
Likes int `json:"likes" orm:"likes" description:"展示内容点赞数量,初始值为0,可累加"` // 展示内容点赞数量,初始值为0,可累加
FlagType int `json:"flagType" orm:"flag_type" description:"展示内容标识类型,按业务规则确定,可为空"` // 展示内容标识类型,按业务规则确定,可为空
ClubId int `json:"clubId" orm:"club_id" description:"关联的俱乐部ID,指向go_clubs表的id,可为空"` // 关联的俱乐部ID,指向go_clubs表的id,可为空
ChannelId int `json:"channelId" orm:"channel_id" description:"关联的频道ID,指向go_channels表的id,可为空"` // 关联的频道ID,指向go_channels表的id,可为空
Club *GoClubs `json:"club" orm:"with:id=club_id"`
}

4
main.go

@ -4,10 +4,10 @@ import (
_ "practice_Go/internal/logic"
_ "practice_Go/internal/packed"
"github.com/gogf/gf/v2/os/gctx"
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
"github.com/gogf/gf/v2/os/gctx"
"practice_Go/internal/cmd"
)

532
resource/public/html/api.html
File diff suppressed because it is too large
View File

Loading…
Cancel
Save