Browse Source

12.3下午李继坤合并到dev

dev
lijikun 7 months ago
parent
commit
cd59b9e2d9
  1. 8
      .gitignore
  2. 8
      go.mod
  3. 5
      hack/config.yaml
  4. 29
      internal/cmd/cmd.go
  5. 31
      internal/controller/clubPage/clubPage.go
  6. 34
      internal/controller/mainPage/mainPage.go
  7. 27
      internal/dao/go_channel_subscriptions.go
  8. 27
      internal/dao/go_channels.go
  9. 27
      internal/dao/go_clubs.go
  10. 27
      internal/dao/go_live_reservations.go
  11. 27
      internal/dao/go_lives.go
  12. 27
      internal/dao/go_shows.go
  13. 27
      internal/dao/go_users.go
  14. 77
      internal/dao/internal/go_channel_subscriptions.go
  15. 81
      internal/dao/internal/go_channels.go
  16. 79
      internal/dao/internal/go_clubs.go
  17. 77
      internal/dao/internal/go_live_reservations.go
  18. 83
      internal/dao/internal/go_lives.go
  19. 95
      internal/dao/internal/go_shows.go
  20. 79
      internal/dao/internal/go_users.go
  21. 52
      internal/logic/clubs/clubs.go
  22. 8
      internal/logic/logic.go
  23. 59
      internal/logic/shows/shows.go
  24. 17
      internal/model/do/go_channel_subscriptions.go
  25. 19
      internal/model/do/go_channels.go
  26. 18
      internal/model/do/go_clubs.go
  27. 17
      internal/model/do/go_live_reservations.go
  28. 21
      internal/model/do/go_lives.go
  29. 27
      internal/model/do/go_shows.go
  30. 18
      internal/model/do/go_users.go
  31. 12
      internal/model/entity/go_channel_subscriptions.go
  32. 14
      internal/model/entity/go_channels.go
  33. 13
      internal/model/entity/go_clubs.go
  34. 12
      internal/model/entity/go_live_reservations.go
  35. 19
      internal/model/entity/go_lives.go
  36. 28
      internal/model/entity/go_shows.go
  37. 13
      internal/model/entity/go_users.go
  38. 34
      internal/service/clubs.go
  39. 32
      internal/service/shows.go
  40. 3
      main.go

8
.gitignore

@ -16,4 +16,10 @@ manifest/output/
temp/
temp.yaml
bin
**/config/config.yaml
**/config/config.yaml
*.exe
*.exe~
*.dll
*.so
*.dylib

8
go.mod

@ -2,16 +2,22 @@ module practice_Go
go 1.18
require github.com/gogf/gf/v2 v2.8.1
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
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect

5
hack/config.yaml

@ -1,11 +1,12 @@
# CLI tool, only in development environment.
# https://goframe.org/docs/cli
gfcli:
gen:
dao:
- link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test"
- 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"

29
internal/cmd/cmd.go

@ -2,9 +2,11 @@ package cmd
import (
"context"
"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/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd"
)
@ -15,12 +17,33 @@ var (
Brief: "start http server",
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
s := g.Server()
s.Group("/", func(group *ghttp.RouterGroup) {
// 定义一个路由组,路径为/mainpage
s.Group("/mainpage", func(group *ghttp.RouterGroup) {
// 添加中间件,用于处理响应
group.Middleware(ghttp.MiddlewareHandlerResponse)
// 绑定路由,将mainPage.NewMainPage()绑定到该路由组
group.Bind(
mainPage.NewMainPage(),
)
})
// 定义一个路由组,路径为/clubpage
s.Group("/clubpage", func(group *ghttp.RouterGroup) {
// 添加中间件,用于处理响应
group.Middleware(ghttp.MiddlewareHandlerResponse)
// 绑定路由,将mainPage.NewMainPage()绑定到该路由组
group.Bind(
clubPage.NewClubPage(),
)
})
s.Run()
//开启静态资源
s.SetServerRoot("resource/public")
s.SetOpenApiPath("/api.json") //启用OpenAPIv3,并设置OpenAPI文档的路径
s.SetSwaggerPath("/swagger") //启用内置的Swagger接口文档UI,并设置Swagger文档的路径
s.Run()
return nil
},

31
internal/controller/clubPage/clubPage.go

@ -0,0 +1,31 @@
package clubPage
import (
"github.com/gogf/gf/v2/net/ghttp"
"practice_Go/internal/service"
)
type ClubPage struct{}
func NewClubPage() *ClubPage {
return &ClubPage{}
}
// GetClub 获取俱乐部信息
func (c ClubPage) GetClub(req *ghttp.Request) {
club, err := service.GetClubs().GetClubs(req.Context())
if err == nil {
req.Response.WriteJson(club)
} else {
req.Response.WriteJson(err)
}
}
func (c ClubPage) GetClubShows(req *ghttp.Request) {
shows, err := service.GetClubs().GetClubShows(req.Context())
if err == nil {
req.Response.WriteJson(shows)
} else {
req.Response.WriteJson(err)
}
}

34
internal/controller/mainPage/mainPage.go

@ -0,0 +1,34 @@
package mainPage
import (
"github.com/gogf/gf/v2/net/ghttp"
"practice_Go/internal/service"
)
// 定义一个MainPage结构体
type MainPage struct{}
// 创建一个新的MainPage实例 初始化
func NewMainPage() *MainPage {
return &MainPage{}
}
// 获取文章,视频
func (c *MainPage) GetShows(req *ghttp.Request) {
shows, err := service.GetShows().GetShows(req.Context())
if err == nil {
req.Response.WriteJson(shows)
} else {
req.Response.WriteJson(err)
}
}
// 获取视频
func (c *MainPage) GetVideos(req *ghttp.Request) {
shows, err := service.GetShows().GetVideos(req.Context())
if err == nil {
req.Response.WriteJson(shows)
} else {
req.Response.WriteJson(err)
}
}

27
internal/dao/go_channel_subscriptions.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"practice_Go/internal/dao/internal"
)
// internalGoChannelSubscriptionsDao is internal type for wrapping internal DAO implements.
type internalGoChannelSubscriptionsDao = *internal.GoChannelSubscriptionsDao
// goChannelSubscriptionsDao is the data access object for table go_channel_subscriptions.
// You can define custom methods on it to extend its functionality as you wish.
type goChannelSubscriptionsDao struct {
internalGoChannelSubscriptionsDao
}
var (
// GoChannelSubscriptions is globally public accessible object for table go_channel_subscriptions operations.
GoChannelSubscriptions = goChannelSubscriptionsDao{
internal.NewGoChannelSubscriptionsDao(),
}
)
// Fill with you ideas below.

27
internal/dao/go_channels.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"practice_Go/internal/dao/internal"
)
// internalGoChannelsDao is internal type for wrapping internal DAO implements.
type internalGoChannelsDao = *internal.GoChannelsDao
// goChannelsDao is the data access object for table go_channels.
// You can define custom methods on it to extend its functionality as you wish.
type goChannelsDao struct {
internalGoChannelsDao
}
var (
// GoChannels is globally public accessible object for table go_channels operations.
GoChannels = goChannelsDao{
internal.NewGoChannelsDao(),
}
)
// Fill with you ideas below.

27
internal/dao/go_clubs.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"practice_Go/internal/dao/internal"
)
// internalGoClubsDao is internal type for wrapping internal DAO implements.
type internalGoClubsDao = *internal.GoClubsDao
// goClubsDao is the data access object for table go_clubs.
// You can define custom methods on it to extend its functionality as you wish.
type goClubsDao struct {
internalGoClubsDao
}
var (
// GoClubs is globally public accessible object for table go_clubs operations.
GoClubs = goClubsDao{
internal.NewGoClubsDao(),
}
)
// Fill with you ideas below.

27
internal/dao/go_live_reservations.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"practice_Go/internal/dao/internal"
)
// internalGoLiveReservationsDao is internal type for wrapping internal DAO implements.
type internalGoLiveReservationsDao = *internal.GoLiveReservationsDao
// goLiveReservationsDao is the data access object for table go_live_reservations.
// You can define custom methods on it to extend its functionality as you wish.
type goLiveReservationsDao struct {
internalGoLiveReservationsDao
}
var (
// GoLiveReservations is globally public accessible object for table go_live_reservations operations.
GoLiveReservations = goLiveReservationsDao{
internal.NewGoLiveReservationsDao(),
}
)
// Fill with you ideas below.

27
internal/dao/go_lives.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"practice_Go/internal/dao/internal"
)
// internalGoLivesDao is internal type for wrapping internal DAO implements.
type internalGoLivesDao = *internal.GoLivesDao
// goLivesDao is the data access object for table go_lives.
// You can define custom methods on it to extend its functionality as you wish.
type goLivesDao struct {
internalGoLivesDao
}
var (
// GoLives is globally public accessible object for table go_lives operations.
GoLives = goLivesDao{
internal.NewGoLivesDao(),
}
)
// Fill with you ideas below.

27
internal/dao/go_shows.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"practice_Go/internal/dao/internal"
)
// internalGoShowsDao is internal type for wrapping internal DAO implements.
type internalGoShowsDao = *internal.GoShowsDao
// goShowsDao is the data access object for table go_shows.
// You can define custom methods on it to extend its functionality as you wish.
type goShowsDao struct {
internalGoShowsDao
}
var (
// GoShows is globally public accessible object for table go_shows operations.
GoShows = goShowsDao{
internal.NewGoShowsDao(),
}
)
// Fill with you ideas below.

27
internal/dao/go_users.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"practice_Go/internal/dao/internal"
)
// internalGoUsersDao is internal type for wrapping internal DAO implements.
type internalGoUsersDao = *internal.GoUsersDao
// goUsersDao is the data access object for table go_users.
// You can define custom methods on it to extend its functionality as you wish.
type goUsersDao struct {
internalGoUsersDao
}
var (
// GoUsers is globally public accessible object for table go_users operations.
GoUsers = goUsersDao{
internal.NewGoUsersDao(),
}
)
// Fill with you ideas below.

77
internal/dao/internal/go_channel_subscriptions.go

@ -0,0 +1,77 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// GoChannelSubscriptionsDao is the data access object for table go_channel_subscriptions.
type GoChannelSubscriptionsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns GoChannelSubscriptionsColumns // columns contains all the column names of Table for convenient usage.
}
// GoChannelSubscriptionsColumns defines and stores column names for table go_channel_subscriptions.
type GoChannelSubscriptionsColumns struct {
Id string // 频道订阅关系唯一ID,自增
UserId string // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
ChannelId string // 关联的频道ID,指向go_channels表的id,不能为空
}
// goChannelSubscriptionsColumns holds the columns for table go_channel_subscriptions.
var goChannelSubscriptionsColumns = GoChannelSubscriptionsColumns{
Id: "id",
UserId: "user_id",
ChannelId: "channel_id",
}
// NewGoChannelSubscriptionsDao creates and returns a new DAO object for table data access.
func NewGoChannelSubscriptionsDao() *GoChannelSubscriptionsDao {
return &GoChannelSubscriptionsDao{
group: "default",
table: "go_channel_subscriptions",
columns: goChannelSubscriptionsColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *GoChannelSubscriptionsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *GoChannelSubscriptionsDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *GoChannelSubscriptionsDao) Columns() GoChannelSubscriptionsColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *GoChannelSubscriptionsDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *GoChannelSubscriptionsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *GoChannelSubscriptionsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

81
internal/dao/internal/go_channels.go

@ -0,0 +1,81 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// GoChannelsDao is the data access object for table go_channels.
type GoChannelsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns GoChannelsColumns // columns contains all the column names of Table for convenient usage.
}
// GoChannelsColumns defines and stores column names for table go_channels.
type GoChannelsColumns struct {
Id string // 频道唯一ID,自增
Image string // 频道图片路径或相关标识,可为空
Name string // 频道名称,最大长度255字符,不能为空
SubscriptionCount string // 频道订阅数量,初始值为0,可累加
BackgroundImage string // 频道背景图路径或相关标识,可为空
}
// goChannelsColumns holds the columns for table go_channels.
var goChannelsColumns = GoChannelsColumns{
Id: "id",
Image: "image",
Name: "name",
SubscriptionCount: "subscription_count",
BackgroundImage: "background_image",
}
// NewGoChannelsDao creates and returns a new DAO object for table data access.
func NewGoChannelsDao() *GoChannelsDao {
return &GoChannelsDao{
group: "default",
table: "go_channels",
columns: goChannelsColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *GoChannelsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *GoChannelsDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *GoChannelsDao) Columns() GoChannelsColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *GoChannelsDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *GoChannelsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *GoChannelsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

79
internal/dao/internal/go_clubs.go

@ -0,0 +1,79 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// GoClubsDao is the data access object for table go_clubs.
type GoClubsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns GoClubsColumns // columns contains all the column names of Table for convenient usage.
}
// GoClubsColumns defines and stores column names for table go_clubs.
type GoClubsColumns struct {
Id string // 俱乐部唯一ID,自增
Image string // 俱乐部图片路径或相关标识,可为空
Name string // 俱乐部名称,最大长度255字符,不能为空
Introduction string // 俱乐部简介,文本内容,可为空
}
// goClubsColumns holds the columns for table go_clubs.
var goClubsColumns = GoClubsColumns{
Id: "id",
Image: "image",
Name: "name",
Introduction: "introduction",
}
// NewGoClubsDao creates and returns a new DAO object for table data access.
func NewGoClubsDao() *GoClubsDao {
return &GoClubsDao{
group: "default",
table: "go_clubs",
columns: goClubsColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *GoClubsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *GoClubsDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *GoClubsDao) Columns() GoClubsColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *GoClubsDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *GoClubsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *GoClubsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

77
internal/dao/internal/go_live_reservations.go

@ -0,0 +1,77 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// GoLiveReservationsDao is the data access object for table go_live_reservations.
type GoLiveReservationsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns GoLiveReservationsColumns // columns contains all the column names of Table for convenient usage.
}
// GoLiveReservationsColumns defines and stores column names for table go_live_reservations.
type GoLiveReservationsColumns struct {
Id string // 直播预约关系唯一ID,自增
UserId string // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
LiveId string // 关联的直播ID,指向go_lives表的id,不能为空
}
// goLiveReservationsColumns holds the columns for table go_live_reservations.
var goLiveReservationsColumns = GoLiveReservationsColumns{
Id: "id",
UserId: "user_id",
LiveId: "live_id",
}
// NewGoLiveReservationsDao creates and returns a new DAO object for table data access.
func NewGoLiveReservationsDao() *GoLiveReservationsDao {
return &GoLiveReservationsDao{
group: "default",
table: "go_live_reservations",
columns: goLiveReservationsColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *GoLiveReservationsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *GoLiveReservationsDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *GoLiveReservationsDao) Columns() GoLiveReservationsColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *GoLiveReservationsDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *GoLiveReservationsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *GoLiveReservationsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

83
internal/dao/internal/go_lives.go

@ -0,0 +1,83 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// GoLivesDao is the data access object for table go_lives.
type GoLivesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns GoLivesColumns // columns contains all the column names of Table for convenient usage.
}
// GoLivesColumns defines and stores column names for table go_lives.
type GoLivesColumns struct {
Id string // 直播唯一ID,自增
Cover string // 直播封面路径或相关标识,可为空
UserId string // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
LiveName string // 直播名称,最大长度255字符,不能为空
StartTime string // 直播开始时间,不能为空
Status string // 直播状态,0:未开播 1:已开播,不能为空
}
// goLivesColumns holds the columns for table go_lives.
var goLivesColumns = GoLivesColumns{
Id: "id",
Cover: "cover",
UserId: "user_id",
LiveName: "live_name",
StartTime: "start_time",
Status: "status",
}
// NewGoLivesDao creates and returns a new DAO object for table data access.
func NewGoLivesDao() *GoLivesDao {
return &GoLivesDao{
group: "default",
table: "go_lives",
columns: goLivesColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *GoLivesDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *GoLivesDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *GoLivesDao) Columns() GoLivesColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *GoLivesDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *GoLivesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *GoLivesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

95
internal/dao/internal/go_shows.go

@ -0,0 +1,95 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// GoShowsDao is the data access object for table go_shows.
type GoShowsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns GoShowsColumns // columns contains all the column names of Table for convenient usage.
}
// GoShowsColumns defines and stores column names for table go_shows.
type GoShowsColumns struct {
Id string // 展示内容唯一ID,自增
Cover string // 展示内容封面路径或相关标识,可为空
Name string // 展示内容名称,最大长度255字符,不能为空
UserId string // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
ReleaseTime string // 展示内容发布时间,可为空
VideoDuration string // 展示内容视频时长,格式根据实际情况定,可为空
ViewCount string // 展示内容观看数量,初始值为0,可累加
Comments string // 展示内容评论数量,初始值为0,可累加
Likes string // 展示内容点赞数量,初始值为0,可累加
FlagType string // 展示内容标识类型,按业务规则确定,可为空
ClubId string // 关联的俱乐部ID,指向go_clubs表的id,可为空
ChannelId string // 关联的频道ID,指向go_channels表的id,可为空
}
// goShowsColumns holds the columns for table go_shows.
var goShowsColumns = GoShowsColumns{
Id: "id",
Cover: "cover",
Name: "name",
UserId: "user_id",
ReleaseTime: "release_time",
VideoDuration: "video_duration",
ViewCount: "view_count",
Comments: "comments",
Likes: "likes",
FlagType: "flag_type",
ClubId: "club_id",
ChannelId: "channel_id",
}
// NewGoShowsDao creates and returns a new DAO object for table data access.
func NewGoShowsDao() *GoShowsDao {
return &GoShowsDao{
group: "default",
table: "go_shows",
columns: goShowsColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *GoShowsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *GoShowsDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *GoShowsDao) Columns() GoShowsColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *GoShowsDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *GoShowsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *GoShowsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

79
internal/dao/internal/go_users.go

@ -0,0 +1,79 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// GoUsersDao is the data access object for table go_users.
type GoUsersDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns GoUsersColumns // columns contains all the column names of Table for convenient usage.
}
// GoUsersColumns defines and stores column names for table go_users.
type GoUsersColumns struct {
Id string // 用户唯一ID,自增,长度为8位整数
Username string // 用户名,最大长度255字符,不能为空
Avatar string // 用户头像路径或相关标识,可为空
Password string // 用户登录密码,最大长度255字符,不能为空
}
// goUsersColumns holds the columns for table go_users.
var goUsersColumns = GoUsersColumns{
Id: "id",
Username: "username",
Avatar: "avatar",
Password: "password",
}
// NewGoUsersDao creates and returns a new DAO object for table data access.
func NewGoUsersDao() *GoUsersDao {
return &GoUsersDao{
group: "default",
table: "go_users",
columns: goUsersColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *GoUsersDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *GoUsersDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *GoUsersDao) Columns() GoUsersColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *GoUsersDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *GoUsersDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *GoUsersDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

52
internal/logic/clubs/clubs.go

@ -0,0 +1,52 @@
package clubs
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"practice_Go/internal/dao"
"practice_Go/internal/model/do"
"practice_Go/internal/model/entity"
"practice_Go/internal/service"
)
// 1.注册
func init() {
service.RegisterClubs(&sClubs{})
}
type sClubs struct{}
func (c sClubs) GetClubs(ctx context.Context) (clubs []entity.GoClubs, err error) {
clubId := g.RequestFromCtx(ctx).Get("id").Int()
if clubId == 0 {
panic("获取俱乐部信息时id不能为空")
} else {
err = dao.GoClubs.Ctx(ctx).Where("id", clubId).Scan(&clubs) //查询数据库, 并将可能出现的错误赋给err
}
return
}
func (c sClubs) GetClubShows(ctx context.Context) (shows []entity.GoShows, err error) {
clubId := g.RequestFromCtx(ctx).Get("id").Int()
if clubId == 0 {
panic("获取俱乐部内容时id不能为空")
} else {
err = dao.GoShows.Ctx(ctx).FieldsEx("club").With(entity.GoUsers{}).Where("club_id", clubId).Scan(&shows)
}
return
}
func (c sClubs) AddClub(ctx context.Context, club do.GoShows) (err error) {
//TODO implement me
panic("implement me")
}
func (c sClubs) EditClub(ctx context.Context, club do.GoClubs) (err error) {
//TODO implement me
panic("implement me")
}
func (c sClubs) DeleteClub(ctx context.Context) (err error) {
//TODO implement me
panic("implement me")
}

8
internal/logic/logic.go

@ -0,0 +1,8 @@
package logic
import (
_ "practice_Go/internal/logic/clubs"
_ "practice_Go/internal/logic/shows"
)
//如果这里导入了文件后还是说未注册就将在main.go文件中导入logic包

59
internal/logic/shows/shows.go

@ -0,0 +1,59 @@
package shows
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"practice_Go/internal/dao"
"practice_Go/internal/model/do"
"practice_Go/internal/model/entity"
"practice_Go/internal/service"
)
func init() {
//GoFrame没有自动注册, 将sShow结构体的实例注册到服务中, 供其他部分访问
service.RegisterShows(&sShow{}) //GoFrame没有自动注册 另外还需要在logic包下创建一个logic.go文件,并在其中导入本文件所在的shows包
}
// 定义一个sShow结构体,供其他部分访问下面的方法
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()
if flagType != 0 {
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}, entity.GoClubs{}).Where("flag_type", flagType).Scan(&shows) //err用于存储过程中可能出现的错误,结果直接存到shows中了
} else {
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}).With(entity.GoClubs{}).Scan(&shows)
}
// 返回结果
return
}
// 定义一个方法,用于获取视频列表
func (s sShow) GetVideos(ctx context.Context) (videos []entity.GoShows, err error) {
// 使用dao包中的GoShows结构体,在指定的上下文中扫描视频列表
flagType := g.RequestFromCtx(ctx).Get("flag_type").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 {
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}).With(entity.GoClubs{}).OrderDesc("release_time").Scan(&videos)
}
// 返回视频列表和错误信息
return
}
func (s sShow) AddShow(ctx context.Context, show do.GoShows) (err error) {
//TODO implement me
panic("implement me")
}
func (s sShow) EditShow(ctx context.Context, show do.GoShows) (err error) {
//TODO implement me
panic("implement me")
}
func (s sShow) DeleteShow(ctx context.Context) (err error) {
//TODO implement me
panic("implement me")
}

17
internal/model/do/go_channel_subscriptions.go

@ -0,0 +1,17 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// GoChannelSubscriptions is the golang structure of table go_channel_subscriptions for DAO operations like Where/Data.
type GoChannelSubscriptions struct {
g.Meta `orm:"table:go_channel_subscriptions, do:true"`
Id interface{} // 频道订阅关系唯一ID,自增
UserId interface{} // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
ChannelId interface{} // 关联的频道ID,指向go_channels表的id,不能为空
}

19
internal/model/do/go_channels.go

@ -0,0 +1,19 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// GoChannels is the golang structure of table go_channels for DAO operations like Where/Data.
type GoChannels struct {
g.Meta `orm:"table:go_channels, do:true"`
Id interface{} // 频道唯一ID,自增
Image interface{} // 频道图片路径或相关标识,可为空
Name interface{} // 频道名称,最大长度255字符,不能为空
SubscriptionCount interface{} // 频道订阅数量,初始值为0,可累加
BackgroundImage interface{} // 频道背景图路径或相关标识,可为空
}

18
internal/model/do/go_clubs.go

@ -0,0 +1,18 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// GoClubs is the golang structure of table go_clubs for DAO operations like Where/Data.
type GoClubs struct {
g.Meta `orm:"table:go_clubs, do:true"`
Id interface{} // 俱乐部唯一ID,自增
Image interface{} // 俱乐部图片路径或相关标识,可为空
Name interface{} // 俱乐部名称,最大长度255字符,不能为空
Introduction interface{} // 俱乐部简介,文本内容,可为空
}

17
internal/model/do/go_live_reservations.go

@ -0,0 +1,17 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// GoLiveReservations is the golang structure of table go_live_reservations for DAO operations like Where/Data.
type GoLiveReservations struct {
g.Meta `orm:"table:go_live_reservations, do:true"`
Id interface{} // 直播预约关系唯一ID,自增
UserId interface{} // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
LiveId interface{} // 关联的直播ID,指向go_lives表的id,不能为空
}

21
internal/model/do/go_lives.go

@ -0,0 +1,21 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// GoLives is the golang structure of table go_lives for DAO operations like Where/Data.
type GoLives struct {
g.Meta `orm:"table:go_lives, do:true"`
Id interface{} // 直播唯一ID,自增
Cover interface{} // 直播封面路径或相关标识,可为空
UserId interface{} // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
LiveName interface{} // 直播名称,最大长度255字符,不能为空
StartTime *gtime.Time // 直播开始时间,不能为空
Status interface{} // 直播状态,0:未开播 1:已开播,不能为空
}

27
internal/model/do/go_shows.go

@ -0,0 +1,27 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// GoShows is the golang structure of table go_shows for DAO operations like Where/Data.
type GoShows struct {
g.Meta `orm:"table:go_shows, do:true"`
Id interface{} // 展示内容唯一ID,自增
Cover interface{} // 展示内容封面路径或相关标识,可为空
Name interface{} // 展示内容名称,最大长度255字符,不能为空
UserId interface{} // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
ReleaseTime *gtime.Time // 展示内容发布时间,可为空
VideoDuration *gtime.Time // 展示内容视频时长,格式根据实际情况定,可为空
ViewCount interface{} // 展示内容观看数量,初始值为0,可累加
Comments interface{} // 展示内容评论数量,初始值为0,可累加
Likes interface{} // 展示内容点赞数量,初始值为0,可累加
FlagType interface{} // 展示内容标识类型,按业务规则确定,可为空
ClubId interface{} // 关联的俱乐部ID,指向go_clubs表的id,可为空
ChannelId interface{} // 关联的频道ID,指向go_channels表的id,可为空
}

18
internal/model/do/go_users.go

@ -0,0 +1,18 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// GoUsers is the golang structure of table go_users for DAO operations like Where/Data.
type GoUsers struct {
g.Meta `orm:"table:go_users, do:true"`
Id interface{} // 用户唯一ID,自增,长度为8位整数
Username interface{} // 用户名,最大长度255字符,不能为空
Avatar interface{} // 用户头像路径或相关标识,可为空
Password interface{} // 用户登录密码,最大长度255字符,不能为空
}

12
internal/model/entity/go_channel_subscriptions.go

@ -0,0 +1,12 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
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,不能为空
}

14
internal/model/entity/go_channels.go

@ -0,0 +1,14 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
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:"频道背景图路径或相关标识,可为空"` // 频道背景图路径或相关标识,可为空
}

13
internal/model/entity/go_clubs.go

@ -0,0 +1,13 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
// GoClubs is the golang structure for table go_clubs.
type GoClubs 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字符,不能为空
Introduction string `json:"introduction" orm:"introduction" description:"俱乐部简介,文本内容,可为空"` // 俱乐部简介,文本内容,可为空
}

12
internal/model/entity/go_live_reservations.go

@ -0,0 +1,12 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
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,不能为空
}

19
internal/model/entity/go_lives.go

@ -0,0 +1,19 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// 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:已开播,不能为空
}

28
internal/model/entity/go_shows.go

@ -0,0 +1,28 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// 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"`
}

13
internal/model/entity/go_users.go

@ -0,0 +1,13 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
// GoUsers is the golang structure for table go_users.
type GoUsers struct {
Id int `json:"id" orm:"id" description:"用户唯一ID,自增,长度为8位整数"` // 用户唯一ID,自增,长度为8位整数
Username string `json:"username" orm:"username" description:"用户名,最大长度255字符,不能为空"` // 用户名,最大长度255字符,不能为空
Avatar string `json:"avatar" orm:"avatar" description:"用户头像路径或相关标识,可为空"` // 用户头像路径或相关标识,可为空
//Password string `json:"password" orm:"password" description:"用户登录密码,最大长度255字符,不能为空"` // 用户登录密码,最大长度255字符,不能为空
}

34
internal/service/clubs.go

@ -0,0 +1,34 @@
package service
import (
"context"
"practice_Go/internal/model/do"
"practice_Go/internal/model/entity"
)
// 1.定义接口
type IClubs interface {
GetClubs(ctx context.Context) (clubs []entity.GoClubs, err error)
GetClubShows(ctx context.Context) (shows []entity.GoShows, err error)
AddClub(ctx context.Context, club do.GoShows) (err error)
EditClub(ctx context.Context, club do.GoClubs) (err error)
DeleteClub(ctx context.Context) (err error)
}
// 2.定义接口变量
var localClub IClubs
// 3.定义获取接口实例的函数
func GetClubs() IClubs {
if localClub == nil {
panic("IClubs接口未实现或未注册")
} else {
return localClub
}
}
// 4.定义一个接口实现的注册方法
func RegisterClubs(club IClubs) {
localClub = club
}

32
internal/service/shows.go

@ -0,0 +1,32 @@
package service
import (
"context"
"practice_Go/internal/model/do"
"practice_Go/internal/model/entity"
)
// 1.定义接口
type IShows interface {
GetShows(ctx context.Context) (shows []entity.GoShows, err error)
GetVideos(ctx context.Context) (videos []entity.GoShows, err error)
AddShow(ctx context.Context, show do.GoShows) (err error)
EditShow(ctx context.Context, show do.GoShows) (err error)
DeleteShow(ctx context.Context) (err error) //id通过路径中获取
}
// 2.定义接口变量
var localShow IShows
// 3.定义获取接口实例的函数
func GetShows() IShows {
if localShow == nil {
panic("IShows未实现或未注册")
}
return localShow
}
// 4.定义一个接口实现的注册方法
func RegisterShows(show IShows) {
localShow = show
}

3
main.go

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

Loading…
Cancel
Save