Compare commits
2 Commits
Author | SHA1 | Message | Date |
---|---|---|---|
|
cfcb706b15 |
初版
|
1 month ago |
|
b2f18aad31 |
电子书全部查询
|
1 month ago |
-
15api/hello/hello.go
-
12api/hello/v1/hello.go
-
8api/v1/ebooks/ebooks.go
-
9api/v1/live_streams/live_streams.go
-
11api/v1/shows/shows.go
-
4go.mod
-
56go.sum
-
4hack/config.yaml
-
21internal/cmd/cmd.go
-
23internal/controller/ebooks/ebooks.go
-
5internal/controller/hello/hello.go
-
15internal/controller/hello/hello_new.go
-
13internal/controller/hello/hello_v1_hello.go
-
23internal/controller/live_streams/live_streams.go
-
25internal/controller/shows/shows.go
-
27internal/dao/ebooks.go
-
81internal/dao/internal/ebooks.go
-
85internal/dao/internal/live_streams.go
-
95internal/dao/internal/shows.go
-
27internal/dao/live_streams.go
-
27internal/dao/shows.go
-
25internal/logic/ebooks.go
-
37internal/logic/live_streams.go
-
57internal/logic/shows.go
-
19internal/model/do/ebooks.go
-
22internal/model/do/live_streams.go
-
27internal/model/do/shows.go
-
14internal/model/entity/ebooks.go
-
20internal/model/entity/live_streams.go
-
25internal/model/entity/shows.go
-
27internal/service/ebooks.go
-
27internal/service/live_streams.go
-
26internal/service/shows.go
-
6main.go
-
BINresource/public/resource/image/ebook1.png
-
BINresource/public/resource/image/ebook2.png
-
BINresource/public/resource/image/ebook3.png
-
BINresource/public/resource/image/ebook4.png
-
BINresource/public/resource/image/live/p1.png
-
BINresource/public/resource/image/shows/t1.png
-
BINresource/public/resource/image/shows/v1.png
@ -1,15 +0,0 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package hello |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"practice_Go/api/hello/v1" |
|||
) |
|||
|
|||
type IHelloV1 interface { |
|||
Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) |
|||
} |
@ -1,12 +0,0 @@ |
|||
package v1 |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
) |
|||
|
|||
type HelloReq struct { |
|||
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"` |
|||
} |
|||
type HelloRes struct { |
|||
g.Meta `mime:"text/html" example:"string"` |
|||
} |
@ -0,0 +1,8 @@ |
|||
package ebooks |
|||
|
|||
import "practice_Go/internal/model/entity" |
|||
|
|||
type GetEbooksListReq struct{} |
|||
type GetEbooksListRes struct { |
|||
List []*entity.Ebooks `json:"list" dc:"ebooks list"` |
|||
} |
@ -0,0 +1,9 @@ |
|||
package live_streams |
|||
|
|||
import "practice_Go/internal/model/entity" |
|||
|
|||
type GetLiveListReq struct { |
|||
} |
|||
type GetLiveListRes struct { |
|||
List []*entity.LiveStreams `json:"list" dc:"LiveStreams list"` |
|||
} |
@ -0,0 +1,11 @@ |
|||
package shows |
|||
|
|||
import "practice_Go/internal/model/entity" |
|||
|
|||
type ShowReq struct { |
|||
QueryType int `v:"required|in:1,2,3,4" p:"queryType"` // 验证参数有效性
|
|||
} |
|||
|
|||
type GetShowsListRes struct { |
|||
List []*entity.Shows `json:"list" dc:"shows list"` |
|||
} |
@ -0,0 +1,23 @@ |
|||
package ebooks |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/net/ghttp" |
|||
"practice_Go/api/v1/ebooks" |
|||
ebook "practice_Go/internal/service" |
|||
) |
|||
|
|||
type cEbooks struct{} |
|||
|
|||
var Ebooks = cEbooks{} |
|||
|
|||
func (c *cEbooks) GetEbooksList(r *ghttp.Request) { |
|||
var req *ebooks.GetEbooksListReq |
|||
if err := r.Parse(&req); err != nil { |
|||
r.Response.WriteJsonExit(err.Error()) |
|||
} |
|||
res, err := ebook.Ebooks().GetEbooksList(r.Context(), req) |
|||
if err != nil { |
|||
r.Response.WriteJsonExit(err.Error()) |
|||
} |
|||
r.Response.WriteJsonExit(res) |
|||
} |
@ -1,5 +0,0 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package hello |
@ -1,15 +0,0 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package hello |
|||
|
|||
import ( |
|||
"practice_Go/api/hello" |
|||
) |
|||
|
|||
type ControllerV1 struct{} |
|||
|
|||
func NewV1() hello.IHelloV1 { |
|||
return &ControllerV1{} |
|||
} |
@ -1,13 +0,0 @@ |
|||
package hello |
|||
|
|||
import ( |
|||
"context" |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
|
|||
"practice_Go/api/hello/v1" |
|||
) |
|||
|
|||
func (c *ControllerV1) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) { |
|||
g.RequestFromCtx(ctx).Response.Writeln("Hello World!") |
|||
return |
|||
} |
@ -0,0 +1,23 @@ |
|||
package live_streams |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/net/ghttp" |
|||
"practice_Go/api/v1/live_streams" |
|||
live "practice_Go/internal/service" |
|||
) |
|||
|
|||
type cLive struct{} |
|||
|
|||
var Live = cLive{} |
|||
|
|||
func (c *cLive) GetLiveList(r *ghttp.Request) { |
|||
var req *live_streams.GetLiveListReq |
|||
if err := r.Parse(&req); err != nil { |
|||
r.Response.WriteJsonExit(err.Error()) |
|||
} |
|||
res, err := live.Live().GetLiveList(r.Context(), req) |
|||
if err != nil { |
|||
r.Response.WriteJsonExit(err.Error()) |
|||
} |
|||
r.Response.WriteJsonExit(res) |
|||
} |
@ -0,0 +1,25 @@ |
|||
package shows |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/errors/gcode" |
|||
"github.com/gogf/gf/v2/net/ghttp" |
|||
"practice_Go/api/v1/shows" |
|||
"practice_Go/internal/service" |
|||
) |
|||
|
|||
type cShows struct{} |
|||
|
|||
var Shows = cShows{} |
|||
|
|||
func (c *cShows) GetShowList(r *ghttp.Request) { |
|||
var req *shows.ShowReq |
|||
if err := r.Parse(&req); err != nil { |
|||
r.Response.WriteJsonExit(gcode.New(400, "参数错误", nil)) |
|||
} |
|||
|
|||
res, err := service.Shows().GetShowsList(r.Context(), req) |
|||
if err != nil { |
|||
r.Response.WriteJsonExit(gcode.New(500, err.Error(), nil)) |
|||
} |
|||
r.Response.WriteJson(res) |
|||
} |
@ -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" |
|||
) |
|||
|
|||
// internalEbooksDao is internal type for wrapping internal DAO implements.
|
|||
type internalEbooksDao = *internal.EbooksDao |
|||
|
|||
// ebooksDao is the data access object for table ebooks.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type ebooksDao struct { |
|||
internalEbooksDao |
|||
} |
|||
|
|||
var ( |
|||
// Ebooks is globally public accessible object for table ebooks operations.
|
|||
Ebooks = ebooksDao{ |
|||
internal.NewEbooksDao(), |
|||
} |
|||
) |
|||
|
|||
// Fill with you ideas below.
|
@ -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" |
|||
) |
|||
|
|||
// EbooksDao is the data access object for table ebooks.
|
|||
type EbooksDao 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 EbooksColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// EbooksColumns defines and stores column names for table ebooks.
|
|||
type EbooksColumns struct { |
|||
Id string // 主键
|
|||
Cover string // 封面图URL
|
|||
Title string // 书名(唯一约束)
|
|||
Description string // 简介
|
|||
ViewCount string // 观看人数
|
|||
} |
|||
|
|||
// ebooksColumns holds the columns for table ebooks.
|
|||
var ebooksColumns = EbooksColumns{ |
|||
Id: "id", |
|||
Cover: "cover", |
|||
Title: "title", |
|||
Description: "description", |
|||
ViewCount: "view_count", |
|||
} |
|||
|
|||
// NewEbooksDao creates and returns a new DAO object for table data access.
|
|||
func NewEbooksDao() *EbooksDao { |
|||
return &EbooksDao{ |
|||
group: "default", |
|||
table: "ebooks", |
|||
columns: ebooksColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *EbooksDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *EbooksDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *EbooksDao) Columns() EbooksColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *EbooksDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *EbooksDao) 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 *EbooksDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { |
|||
return dao.Ctx(ctx).Transaction(ctx, f) |
|||
} |
@ -0,0 +1,85 @@ |
|||
// ==========================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// LiveStreamsDao is the data access object for table live_streams.
|
|||
type LiveStreamsDao 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 LiveStreamsColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// LiveStreamsColumns defines and stores column names for table live_streams.
|
|||
type LiveStreamsColumns struct { |
|||
Id string // 主键
|
|||
Cover string // 直播封面URL
|
|||
Title string // 直播标题
|
|||
Avatar string // 主播头像URL
|
|||
PublisherName string // 主播名字
|
|||
StartTime string // 计划开播时间
|
|||
Status string // 开播状态(0=未开播,1=直播中)
|
|||
} |
|||
|
|||
// liveStreamsColumns holds the columns for table live_streams.
|
|||
var liveStreamsColumns = LiveStreamsColumns{ |
|||
Id: "id", |
|||
Cover: "cover", |
|||
Title: "title", |
|||
Avatar: "avatar", |
|||
PublisherName: "publisher_name", |
|||
StartTime: "start_time", |
|||
Status: "status", |
|||
} |
|||
|
|||
// NewLiveStreamsDao creates and returns a new DAO object for table data access.
|
|||
func NewLiveStreamsDao() *LiveStreamsDao { |
|||
return &LiveStreamsDao{ |
|||
group: "default", |
|||
table: "live_streams", |
|||
columns: liveStreamsColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *LiveStreamsDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *LiveStreamsDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *LiveStreamsDao) Columns() LiveStreamsColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *LiveStreamsDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *LiveStreamsDao) 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 *LiveStreamsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { |
|||
return dao.Ctx(ctx).Transaction(ctx, f) |
|||
} |
@ -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" |
|||
) |
|||
|
|||
// ShowsDao is the data access object for table shows.
|
|||
type ShowsDao 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 ShowsColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// ShowsColumns defines and stores column names for table shows.
|
|||
type ShowsColumns struct { |
|||
Id string // 主键
|
|||
Cover string // 封面图URL
|
|||
Title string // 标题
|
|||
PublisherName string // 发布人名字
|
|||
PublisherAvatar string // 发布人头像URL
|
|||
PublishTime string // 发布时间
|
|||
ViewCount string // 观看人数
|
|||
CommentCount string // 评论数
|
|||
LikeCount string // 点赞数
|
|||
Type string // 类型(1=文章,2=视频)
|
|||
ClubId string // 所属俱乐部(0=无,1=博古)
|
|||
VideoDuration string // 视频时长(秒)
|
|||
} |
|||
|
|||
// showsColumns holds the columns for table shows.
|
|||
var showsColumns = ShowsColumns{ |
|||
Id: "id", |
|||
Cover: "cover", |
|||
Title: "title", |
|||
PublisherName: "publisher_name", |
|||
PublisherAvatar: "publisher_avatar", |
|||
PublishTime: "publish_time", |
|||
ViewCount: "view_count", |
|||
CommentCount: "comment_count", |
|||
LikeCount: "like_count", |
|||
Type: "type", |
|||
ClubId: "club_id", |
|||
VideoDuration: "video_duration", |
|||
} |
|||
|
|||
// NewShowsDao creates and returns a new DAO object for table data access.
|
|||
func NewShowsDao() *ShowsDao { |
|||
return &ShowsDao{ |
|||
group: "default", |
|||
table: "shows", |
|||
columns: showsColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *ShowsDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *ShowsDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *ShowsDao) Columns() ShowsColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *ShowsDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *ShowsDao) 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 *ShowsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { |
|||
return dao.Ctx(ctx).Transaction(ctx, f) |
|||
} |
@ -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" |
|||
) |
|||
|
|||
// internalLiveStreamsDao is internal type for wrapping internal DAO implements.
|
|||
type internalLiveStreamsDao = *internal.LiveStreamsDao |
|||
|
|||
// liveStreamsDao is the data access object for table live_streams.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type liveStreamsDao struct { |
|||
internalLiveStreamsDao |
|||
} |
|||
|
|||
var ( |
|||
// LiveStreams is globally public accessible object for table live_streams operations.
|
|||
LiveStreams = liveStreamsDao{ |
|||
internal.NewLiveStreamsDao(), |
|||
} |
|||
) |
|||
|
|||
// Fill with you ideas below.
|
@ -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" |
|||
) |
|||
|
|||
// internalShowsDao is internal type for wrapping internal DAO implements.
|
|||
type internalShowsDao = *internal.ShowsDao |
|||
|
|||
// showsDao is the data access object for table shows.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type showsDao struct { |
|||
internalShowsDao |
|||
} |
|||
|
|||
var ( |
|||
// Shows is globally public accessible object for table shows operations.
|
|||
Shows = showsDao{ |
|||
internal.NewShowsDao(), |
|||
} |
|||
) |
|||
|
|||
// Fill with you ideas below.
|
@ -0,0 +1,25 @@ |
|||
package logic |
|||
|
|||
import ( |
|||
"context" |
|||
"practice_Go/api/v1/ebooks" |
|||
"practice_Go/internal/dao" |
|||
ebook "practice_Go/internal/service" |
|||
) |
|||
|
|||
type sEbooks struct{} |
|||
|
|||
func init() { |
|||
ebook.RegisterEbooks(New()) |
|||
} |
|||
func New() *sEbooks { |
|||
return &sEbooks{} |
|||
} |
|||
|
|||
func (c *sEbooks) GetEbooksList(ctx context.Context, req *ebooks.GetEbooksListReq) (res ebooks.GetEbooksListRes, err error) { |
|||
err = dao.Ebooks.Ctx(ctx).Scan(&res.List) |
|||
if err != nil { |
|||
return |
|||
} |
|||
return |
|||
} |
@ -0,0 +1,37 @@ |
|||
package logic |
|||
|
|||
import ( |
|||
"context" |
|||
"github.com/gogf/gf/v2/errors/gerror" |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
"practice_Go/api/v1/live_streams" |
|||
"practice_Go/internal/dao" |
|||
"practice_Go/internal/model/entity" |
|||
live "practice_Go/internal/service" |
|||
) |
|||
|
|||
type sLives struct{} |
|||
|
|||
func init() { |
|||
live.RegisterLives(NewLive()) |
|||
} |
|||
func NewLive() *sLives { |
|||
return &sLives{} |
|||
} |
|||
|
|||
// 实现接口 ILive 的方法
|
|||
func (s *sLives) GetLiveList(ctx context.Context, req *live_streams.GetLiveListReq) (res live_streams.GetLiveListRes, err error) { |
|||
var list []*entity.LiveStreams |
|||
err = dao.LiveStreams.Ctx(ctx). |
|||
OrderAsc("start_time"). // 按开播时间升序
|
|||
Limit(8). // 取前8条
|
|||
Scan(&list) |
|||
if err != nil { |
|||
g.Log().Errorf(ctx, "直播数据获取失败:%v", err) |
|||
return res, gerror.Wrap(err, "直播数据服务异常") |
|||
} |
|||
|
|||
// 将 list 转换为 live_streams.GetLiveListRes 的结构
|
|||
res.List = list |
|||
return res, nil |
|||
} |
@ -0,0 +1,57 @@ |
|||
package logic |
|||
|
|||
import ( |
|||
"context" |
|||
"github.com/gogf/gf/v2/errors/gcode" |
|||
"github.com/gogf/gf/v2/errors/gerror" |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
v1 "practice_Go/api/v1/shows" |
|||
"practice_Go/internal/dao" |
|||
"practice_Go/internal/model/entity" |
|||
show "practice_Go/internal/service" |
|||
) |
|||
|
|||
type sShows struct{} |
|||
|
|||
func init() { |
|||
show.RegisterShows(NewShows()) |
|||
} |
|||
|
|||
func NewShows() *sShows { |
|||
return &sShows{} |
|||
} |
|||
|
|||
const ( |
|||
QueryRecommend = iota + 1 // 推荐界面
|
|||
QueryVideo // 精选视频
|
|||
QueryClub // 博股俱乐部
|
|||
QueryChannel // homilyLink频道
|
|||
) |
|||
|
|||
// 实现 IShows 接口中的 GetShowsList 方法
|
|||
func (s *sShows) GetShowsList(ctx context.Context, req *v1.ShowReq) (res v1.GetShowsListRes, err error) { |
|||
model := dao.Shows.Ctx(ctx) |
|||
|
|||
// 根据请求类型动态调整查询条件
|
|||
switch req.QueryType { |
|||
case QueryVideo: |
|||
model = model.Where("type", 2).OrderAsc("publish_time") // 视频类型正序
|
|||
case QueryClub: |
|||
model = model.Where("club_id", 1).OrderDesc("publish_time") // 俱乐部倒序
|
|||
case QueryChannel: |
|||
model = model.Where("publisher_name", "homilyLink").OrderDesc("publish_time") |
|||
default: |
|||
model = model.OrderDesc("publish_time") // 默认推荐倒序
|
|||
} |
|||
|
|||
// 查询数据并填充到结果列表
|
|||
var list []*entity.Shows |
|||
if err := model.Scan(&list); err != nil { |
|||
g.Log().Errorf(ctx, "内容查询异常|类型:%d|错误:%v", req.QueryType, err) |
|||
return res, gerror.WrapCode(gcode.CodeDbOperationError, err, "数据获取失败") |
|||
} |
|||
|
|||
// 将查询结果赋值给返回值
|
|||
res.List = list |
|||
return res, nil |
|||
} |
@ -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" |
|||
) |
|||
|
|||
// Ebooks is the golang structure of table ebooks for DAO operations like Where/Data.
|
|||
type Ebooks struct { |
|||
g.Meta `orm:"table:ebooks, do:true"` |
|||
Id interface{} // 主键
|
|||
Cover interface{} // 封面图URL
|
|||
Title interface{} // 书名(唯一约束)
|
|||
Description interface{} // 简介
|
|||
ViewCount interface{} // 观看人数
|
|||
} |
@ -0,0 +1,22 @@ |
|||
// =================================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// LiveStreams is the golang structure of table live_streams for DAO operations like Where/Data.
|
|||
type LiveStreams struct { |
|||
g.Meta `orm:"table:live_streams, do:true"` |
|||
Id interface{} // 主键
|
|||
Cover interface{} // 直播封面URL
|
|||
Title interface{} // 直播标题
|
|||
Avatar interface{} // 主播头像URL
|
|||
PublisherName interface{} // 主播名字
|
|||
StartTime *gtime.Time // 计划开播时间
|
|||
Status interface{} // 开播状态(0=未开播,1=直播中)
|
|||
} |
@ -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" |
|||
) |
|||
|
|||
// Shows is the golang structure of table shows for DAO operations like Where/Data.
|
|||
type Shows struct { |
|||
g.Meta `orm:"table:shows, do:true"` |
|||
Id interface{} // 主键
|
|||
Cover interface{} // 封面图URL
|
|||
Title interface{} // 标题
|
|||
PublisherName interface{} // 发布人名字
|
|||
PublisherAvatar interface{} // 发布人头像URL
|
|||
PublishTime *gtime.Time // 发布时间
|
|||
ViewCount interface{} // 观看人数
|
|||
CommentCount interface{} // 评论数
|
|||
LikeCount interface{} // 点赞数
|
|||
Type interface{} // 类型(1=文章,2=视频)
|
|||
ClubId interface{} // 所属俱乐部(0=无,1=博古)
|
|||
VideoDuration interface{} // 视频时长(秒)
|
|||
} |
@ -0,0 +1,14 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
// Ebooks is the golang structure for table ebooks.
|
|||
type Ebooks struct { |
|||
Id uint64 `json:"id" orm:"id" description:"主键"` // 主键
|
|||
Cover string `json:"cover" orm:"cover" description:"封面图URL"` // 封面图URL
|
|||
Title string `json:"title" orm:"title" description:"书名(唯一约束)"` // 书名(唯一约束)
|
|||
Description string `json:"description" orm:"description" description:"简介"` // 简介
|
|||
ViewCount uint `json:"viewCount" orm:"view_count" description:"观看人数"` // 观看人数
|
|||
} |
@ -0,0 +1,20 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/os/gtime" |
|||
) |
|||
|
|||
// LiveStreams is the golang structure for table live_streams.
|
|||
type LiveStreams struct { |
|||
Id uint64 `json:"id" orm:"id" description:"主键"` // 主键
|
|||
Cover string `json:"cover" orm:"cover" description:"直播封面URL"` // 直播封面URL
|
|||
Title string `json:"title" orm:"title" description:"直播标题"` // 直播标题
|
|||
Avatar string `json:"avatar" orm:"avatar" description:"主播头像URL"` // 主播头像URL
|
|||
PublisherName string `json:"publisherName" orm:"publisher_name" description:"主播名字"` // 主播名字
|
|||
StartTime *gtime.Time `json:"startTime" orm:"start_time" description:"计划开播时间"` // 计划开播时间
|
|||
Status int `json:"status" orm:"status" description:"开播状态(0=未开播,1=直播中)"` // 开播状态(0=未开播,1=直播中)
|
|||
} |
@ -0,0 +1,25 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/os/gtime" |
|||
) |
|||
|
|||
// Shows is the golang structure for table shows.
|
|||
type Shows struct { |
|||
Id uint64 `json:"id" orm:"id" description:"主键"` // 主键
|
|||
Cover string `json:"cover" orm:"cover" description:"封面图URL"` // 封面图URL
|
|||
Title string `json:"title" orm:"title" description:"标题"` // 标题
|
|||
PublisherName string `json:"publisherName" orm:"publisher_name" description:"发布人名字"` // 发布人名字
|
|||
PublisherAvatar string `json:"publisherAvatar" orm:"publisher_avatar" description:"发布人头像URL"` // 发布人头像URL
|
|||
PublishTime *gtime.Time `json:"publishTime" orm:"publish_time" description:"发布时间"` // 发布时间
|
|||
ViewCount uint `json:"viewCount" orm:"view_count" description:"观看人数"` // 观看人数
|
|||
CommentCount uint `json:"commentCount" orm:"comment_count" description:"评论数"` // 评论数
|
|||
LikeCount uint `json:"likeCount" orm:"like_count" description:"点赞数"` // 点赞数
|
|||
Type int `json:"type" orm:"type" description:"类型(1=文章,2=视频)"` // 类型(1=文章,2=视频)
|
|||
ClubId int `json:"clubId" orm:"club_id" description:"所属俱乐部(0=无,1=博古)"` // 所属俱乐部(0=无,1=博古)
|
|||
VideoDuration uint `json:"videoDuration" orm:"video_duration" description:"视频时长(秒)"` // 视频时长(秒)
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package service |
|||
|
|||
import ( |
|||
"context" |
|||
"practice_Go/api/v1/ebooks" |
|||
) |
|||
|
|||
type ( |
|||
IEbooks interface { |
|||
GetEbooksList(ctx context.Context, req *ebooks.GetEbooksListReq) (res ebooks.GetEbooksListRes, err error) |
|||
} |
|||
) |
|||
|
|||
var ( |
|||
localBooks IEbooks |
|||
) |
|||
|
|||
func Ebooks() IEbooks { |
|||
if localBooks == nil { |
|||
panic("implement not found for interface IUser, forgot register?") |
|||
} |
|||
return localBooks |
|||
} |
|||
|
|||
func RegisterEbooks(i IEbooks) { |
|||
localBooks = i |
|||
} |
@ -0,0 +1,27 @@ |
|||
package service |
|||
|
|||
import ( |
|||
"context" |
|||
"practice_Go/api/v1/live_streams" |
|||
) |
|||
|
|||
type ( |
|||
ILive interface { |
|||
GetLiveList(ctx context.Context, req *live_streams.GetLiveListReq) (res live_streams.GetLiveListRes, err error) |
|||
} |
|||
) |
|||
|
|||
var ( |
|||
localLive ILive |
|||
) |
|||
|
|||
func Live() ILive { |
|||
if localLive == nil { |
|||
panic("implement not found for interface IUser, forgot register?") |
|||
} |
|||
return localLive |
|||
} |
|||
|
|||
func RegisterLives(i ILive) { |
|||
localLive = i |
|||
} |
@ -0,0 +1,26 @@ |
|||
package service |
|||
|
|||
import ( |
|||
"context" |
|||
"practice_Go/api/v1/shows" |
|||
) |
|||
|
|||
type ( |
|||
IShows interface { |
|||
GetShowsList(ctx context.Context, req *shows.ShowReq) (res shows.GetShowsListRes, err error) |
|||
} |
|||
) |
|||
|
|||
var ( |
|||
localShows IShows |
|||
) |
|||
|
|||
func Shows() IShows { |
|||
if localShows == nil { |
|||
panic("implement not found for interface IShows") |
|||
} |
|||
return localShows |
|||
} |
|||
func RegisterShows(i IShows) { |
|||
localShows = i |
|||
} |
After Width: 119 | Height: 169 | Size: 40 KiB |
After Width: 123 | Height: 170 | Size: 43 KiB |
After Width: 116 | Height: 166 | Size: 48 KiB |
After Width: 122 | Height: 170 | Size: 52 KiB |
After Width: 228 | Height: 106 | Size: 36 KiB |
After Width: 145 | Height: 92 | Size: 20 KiB |
After Width: 191 | Height: 121 | Size: 64 KiB |