书籍列表接口新增参数

This commit is contained in:
2025-08-13 15:19:42 +08:00
parent 6ccc87f2bf
commit 8afe651c64
201 changed files with 6987 additions and 1066 deletions

27
api/activity/activity.go Normal file
View File

@ -0,0 +1,27 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package activity
import (
"context"
"server/api/activity/v1"
)
type IActivityV1 interface {
RuleList(ctx context.Context, req *v1.RuleListReq) (res *v1.RuleListRes, err error)
RuleAdd(ctx context.Context, req *v1.RuleAddReq) (res *v1.RuleAddRes, err error)
RuleEdit(ctx context.Context, req *v1.RuleEditReq) (res *v1.RuleEditRes, err error)
RuleDel(ctx context.Context, req *v1.RuleDelReq) (res *v1.RuleDelRes, err error)
RuleSetStatus(ctx context.Context, req *v1.RuleSetStatusReq) (res *v1.RuleSetStatusRes, err error)
ItemList(ctx context.Context, req *v1.ItemListReq) (res *v1.ItemListRes, err error)
ItemAdd(ctx context.Context, req *v1.ItemAddReq) (res *v1.ItemAddRes, err error)
ItemEdit(ctx context.Context, req *v1.ItemEditReq) (res *v1.ItemEditRes, err error)
ItemDel(ctx context.Context, req *v1.ItemDelReq) (res *v1.ItemDelRes, err error)
ItemGet(ctx context.Context, req *v1.ItemGetReq) (res *v1.ItemGetRes, err error)
ItemSetStatus(ctx context.Context, req *v1.ItemSetStatusReq) (res *v1.ItemSetStatusRes, err error)
SignInList(ctx context.Context, req *v1.SignInListReq) (res *v1.SignInListRes, err error)
SignIn(ctx context.Context, req *v1.SignInReq) (res *v1.SignInRes, err error)
}

143
api/activity/v1/activity.go Normal file
View File

@ -0,0 +1,143 @@
package v1
import (
"server/internal/model"
"github.com/gogf/gf/v2/frame/g"
)
type RuleListReq struct {
g.Meta `path:"/activity" tags:"Backend/Activity" method:"get" summary:"获取签到奖励规则列表"`
Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"`
Status int `json:"status" dc:"状态"`
RuleName string `json:"ruleName" dc:"规则名称"`
}
type RuleListRes struct {
Total int `json:"total" dc:"总数"`
List []model.SignInRewardRule `json:"list" dc:"规则列表"`
}
type RuleAddReq struct {
g.Meta `path:"/activity" tags:"Backend/Activity" method:"post" summary:"新增签到奖励规则"`
RuleName string `json:"ruleName" dc:"规则名称" v:"required"`
CycleDays int `json:"cycleDays" dc:"周期天数" v:"required"`
StartDate string `json:"startDate" dc:"开始日期" v:"required"`
EndDate string `json:"endDate" dc:"结束日期" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type RuleAddRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type RuleEditReq struct {
g.Meta `path:"/activity/{id}" tags:"Backend/Activity" method:"put" summary:"编辑签到奖励规则"`
Id int64 `json:"id" dc:"规则ID" v:"required"`
RuleName string `json:"ruleName" dc:"规则名称" v:"required"`
CycleDays int `json:"cycleDays" dc:"周期天数" v:"required"`
StartDate string `json:"startDate" dc:"开始日期" v:"required"`
EndDate string `json:"endDate" dc:"结束日期" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type RuleEditRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type RuleDelReq struct {
g.Meta `path:"/activity/{id}" tags:"Backend/Activity" method:"delete" summary:"删除签到奖励规则"`
Id int64 `json:"id" dc:"规则ID" v:"required"`
}
type RuleDelRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type RuleSetStatusReq struct {
g.Meta `path:"/activity/{id}/status" tags:"Backend/Activity" method:"patch" summary:"设置签到奖励规则状态"`
Id int64 `json:"id" dc:"规则ID" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type RuleSetStatusRes struct {
Success bool `json:"success" dc:"是否成功"`
}
// 签到奖励明细列表
type ItemListReq struct {
g.Meta `path:"/activity/items" tags:"Backend/Activity" method:"get" summary:"获取签到奖励明细列表"`
RuleId int64 `json:"ruleId" dc:"规则ID" v:"required"`
}
type ItemListRes struct {
List []model.SignInRewardDetail `json:"list" dc:"明细列表"`
}
// 新增签到奖励明细
type ItemAddReq struct {
g.Meta `path:"/activity/item" tags:"Backend/Activity" method:"post" summary:"新增签到奖励明细"`
RuleId int64 `json:"ruleId" dc:"规则ID" v:"required"`
DayNumber int `json:"dayNumber" dc:"签到天数" v:"required"`
RewardType int `json:"rewardType" dc:"奖励类型" v:"required"`
Quantity int `json:"quantity" dc:"奖励数量" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type ItemAddRes struct {
Id int64 `json:"id" dc:"明细ID"`
Success bool `json:"success" dc:"是否成功"`
}
// 编辑签到奖励明细
type ItemEditReq struct {
g.Meta `path:"/activity/item/{id}" tags:"Backend/Activity" method:"put" summary:"编辑签到奖励明细"`
Id int64 `json:"id" dc:"明细ID" v:"required"`
RuleId int64 `json:"ruleId" dc:"规则ID" v:"required"`
DayNumber int `json:"dayNumber" dc:"签到天数" v:"required"`
RewardType int `json:"rewardType" dc:"奖励类型" v:"required"`
Quantity int `json:"quantity" dc:"奖励数量" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type ItemEditRes struct {
Success bool `json:"success" dc:"是否成功"`
}
// 删除签到奖励明细
type ItemDelReq struct {
g.Meta `path:"/activity/item/{id}" tags:"Backend/Activity" method:"delete" summary:"删除签到奖励明细"`
Id int64 `json:"id" dc:"明细ID" v:"required"`
}
type ItemDelRes struct {
Success bool `json:"success" dc:"是否成功"`
}
// 查询单个签到奖励明细
type ItemGetReq struct {
g.Meta `path:"/activity/item/{id}" tags:"Backend/Activity" method:"get" summary:"获取单个签到奖励明细"`
Id int64 `json:"id" dc:"明细ID" v:"required"`
}
type ItemGetRes struct {
model.SignInRewardDetail
}
// 设置签到奖励明细状态
type ItemSetStatusReq struct {
g.Meta `path:"/activity/item/{id}/status" tags:"Backend/Activity" method:"patch" summary:"设置签到奖励明细状态"`
Id int64 `json:"id" dc:"明细ID" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type ItemSetStatusRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type SignInListReq struct {
g.Meta `path:"/activity/sign" tags:"APP/Activity" method:"get" summary:"用户签到任务列表"`
}
type SignInListRes struct {
List []model.SignInListItem `json:"list" dc:"签到列表"`
}
// 用户签到
type SignInReq struct {
g.Meta `path:"/activity/sign" tags:"APP/Activity" method:"post" summary:"用户签到"`
RuleId int64 `json:"ruleId" dc:"规则ID" v:"required"`
RewardDetailId int64 `json:"rewardDetailId" dc:"奖励明细ID" v:"required"`
}
type SignInRes struct {
Success bool `json:"success" dc:"是否成功"`
}

View File

@ -9,8 +9,9 @@ type InfoReq struct {
} }
type InfoRes struct { type InfoRes struct {
g.Meta `mime:"application/json"` g.Meta `mime:"application/json"`
AdminId int64 `json:"adminId"` Id int64 `json:"id"`
Username string `json:"username"` Username string `json:"username"`
Role string `json:"role"`
} }
type EditPassReq struct { type EditPassReq struct {

15
api/ads/ads.go Normal file
View File

@ -0,0 +1,15 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package ads
import (
"context"
"server/api/ads/v1"
)
type IAdsV1 interface {
Upload(ctx context.Context, req *v1.UploadReq) (res *v1.UploadRes, err error)
}

16
api/ads/v1/ads.go Normal file
View File

@ -0,0 +1,16 @@
package v1
import "github.com/gogf/gf/v2/frame/g"
// UploadReq 广告数据上传请求
type UploadReq struct {
g.Meta `path:"/ads/upload" tags:"APP/Ads" method:"post" summary:"广告数据上传"`
NodeUid string `json:"node_uid" dc:"节点ID" v:"required"`
DeviceCode string `json:"device_code" dc:"设备编号" v:"required"`
Data string `json:"data" dc:"广告数据" v:"required"`
}
// UploadRes 广告数据上传响应
type UploadRes struct {
Success bool `json:"success" dc:"是否成功"`
}

View File

@ -16,4 +16,5 @@ type IAuthV1 interface {
UserRegister(ctx context.Context, req *v1.UserRegisterReq) (res *v1.UserRegisterRes, err error) UserRegister(ctx context.Context, req *v1.UserRegisterReq) (res *v1.UserRegisterRes, err error)
UserEditPass(ctx context.Context, req *v1.UserEditPassReq) (res *v1.UserEditPassRes, err error) UserEditPass(ctx context.Context, req *v1.UserEditPassReq) (res *v1.UserEditPassRes, err error)
UserCode(ctx context.Context, req *v1.UserCodeReq) (res *v1.UserCodeRes, err error) UserCode(ctx context.Context, req *v1.UserCodeReq) (res *v1.UserCodeRes, err error)
AuthorLogin(ctx context.Context, req *v1.AuthorLoginReq) (res *v1.AuthorLoginRes, err error)
} }

View File

@ -3,7 +3,7 @@ package v1
import "github.com/gogf/gf/v2/frame/g" import "github.com/gogf/gf/v2/frame/g"
type AdminLoginReq struct { type AdminLoginReq struct {
g.Meta `path:"/admin/login" tags:"Admin" method:"post" summary:"管理员登录"` g.Meta `path:"/admin/login" tags:"Backend/Admin" method:"post" summary:"管理员登录"`
Username string `json:"username" v:"required" dc:"用户名"` Username string `json:"username" v:"required" dc:"用户名"`
Password string `json:"password" v:"required" dc:"密码"` Password string `json:"password" v:"required" dc:"密码"`
} }
@ -45,3 +45,12 @@ type UserCodeReq struct {
type UserCodeRes struct { type UserCodeRes struct {
Success bool `json:"success" dc:"是否成功"` Success bool `json:"success" dc:"是否成功"`
} }
type AuthorLoginReq struct {
g.Meta `path:"/author/login" tags:"APP/Author" method:"post" summary:"作者登录"`
Email string `json:"email" v:"required" dc:"邮箱"`
Password string `json:"password" v:"required" dc:"密码"`
}
type AuthorLoginRes struct {
Token string `json:"token" dc:"token"`
}

View File

@ -18,4 +18,7 @@ type IAuthorV1 interface {
Follow(ctx context.Context, req *v1.FollowReq) (res *v1.FollowRes, err error) Follow(ctx context.Context, req *v1.FollowReq) (res *v1.FollowRes, err error)
Unfollow(ctx context.Context, req *v1.UnfollowReq) (res *v1.UnfollowRes, err error) Unfollow(ctx context.Context, req *v1.UnfollowReq) (res *v1.UnfollowRes, err error)
Detail(ctx context.Context, req *v1.DetailReq) (res *v1.DetailRes, err error) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.DetailRes, err error)
AuthorInfo(ctx context.Context, req *v1.AuthorInfoReq) (res *v1.AuthorInfoRes, err error)
Apply(ctx context.Context, req *v1.ApplyReq) (res *v1.ApplyRes, err error)
Review(ctx context.Context, req *v1.ReviewReq) (res *v1.ReviewRes, err error)
} }

View File

@ -1,12 +1,13 @@
package v1 package v1
import ( import (
"github.com/gogf/gf/v2/frame/g"
"server/internal/model" "server/internal/model"
"github.com/gogf/gf/v2/frame/g"
) )
type ListReq struct { type ListReq struct {
g.Meta `path:"/author" tags:"Backend/Admin" method:"get" summary:"获取作者列表"` g.Meta `path:"/author" tags:"Backend/Author" method:"get" summary:"获取作者列表"`
Page int `json:"page" dc:"页码"` Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"` Size int `json:"size" dc:"每页数量"`
PenName string `json:"penName" dc:"笔名(模糊搜索)"` PenName string `json:"penName" dc:"笔名(模糊搜索)"`
@ -18,7 +19,7 @@ type ListRes struct {
} }
type AddReq struct { type AddReq struct {
g.Meta `path:"/author" tags:"Backend/Admin" method:"post" summary:"新增作者"` g.Meta `path:"/author" tags:"Backend/Author" method:"post" summary:"新增作者"`
UserId int64 `json:"userId" dc:"用户ID" v:"required"` UserId int64 `json:"userId" dc:"用户ID" v:"required"`
PenName string `json:"penName" dc:"笔名" v:"required"` PenName string `json:"penName" dc:"笔名" v:"required"`
Bio string `json:"bio" dc:"作者简介"` Bio string `json:"bio" dc:"作者简介"`
@ -29,7 +30,7 @@ type AddRes struct {
} }
type EditReq struct { type EditReq struct {
g.Meta `path:"/author" tags:"Backend/Admin" method:"put" summary:"编辑作者"` g.Meta `path:"/author" tags:"Backend/Author" method:"put" summary:"编辑作者"`
Id int64 `json:"id" dc:"作者ID" v:"required"` Id int64 `json:"id" dc:"作者ID" v:"required"`
PenName string `json:"penName" dc:"笔名" v:"required"` PenName string `json:"penName" dc:"笔名" v:"required"`
Bio string `json:"bio" dc:"作者简介"` Bio string `json:"bio" dc:"作者简介"`
@ -40,7 +41,7 @@ type EditRes struct {
} }
type DelReq struct { type DelReq struct {
g.Meta `path:"/author" tags:"Backend/Admin" method:"delete" summary:"删除作者"` g.Meta `path:"/author" tags:"Backend/Author" method:"delete" summary:"删除作者"`
Id int64 `json:"id" dc:"作者ID" v:"required"` Id int64 `json:"id" dc:"作者ID" v:"required"`
} }
type DelRes struct { type DelRes struct {
@ -50,7 +51,7 @@ type DelRes struct {
// 关注作者 // 关注作者
// ============================= // =============================
type FollowReq struct { type FollowReq struct {
g.Meta `path:"/author/follow" tags:"APP" method:"post" summary:"关注作者"` g.Meta `path:"/author/follow" tags:"APP/Author" method:"post" summary:"关注作者"`
AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"` AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"`
} }
type FollowRes struct { type FollowRes struct {
@ -60,16 +61,48 @@ type FollowRes struct {
// 取消关注作者 // 取消关注作者
// ============================= // =============================
type UnfollowReq struct { type UnfollowReq struct {
g.Meta `path:"/author/unfollow" tags:"APP" method:"post" summary:"取消关注作者"` g.Meta `path:"/author/unfollow" tags:"APP/Author" method:"post" summary:"取消关注作者"`
AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"` AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"`
} }
type UnfollowRes struct { type UnfollowRes struct {
Success bool `json:"success" dc:"是否成功"` Success bool `json:"success" dc:"是否成功"`
} }
type DetailReq struct { type DetailReq struct {
g.Meta `path:"/author/detail" tags:"APP" method:"get" summary:"作者详情"` g.Meta `path:"/author/detail" tags:"APP/Author" method:"get" summary:"作者详情"`
AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"` AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"`
} }
type DetailRes struct { type DetailRes struct {
Author *model.AuthorDetailOut `json:"author" dc:"作者信息"` *model.AuthorDetailOut
}
type AuthorInfoReq struct {
g.Meta `path:"/author/info" tags:"Backend/Author" method:"get" summary:"作者基础信息"`
}
type AuthorInfoRes struct {
Id int64 `json:"id"`
PenName string `json:"penName"`
Role string `json:"role"`
}
type ApplyReq struct {
g.Meta `path:"/author/apply" tags:"APP/Author" method:"post" summary:"申请作者"`
Bio string `json:"bio" dc:"作者简介"`
PenName string `json:"penName" dc:"笔名"`
}
type ApplyRes struct {
g.Meta `path:"/author/apply" tags:"APP/Author" method:"post" summary:"申请作者"`
Success bool `json:"success" dc:"是否成功"`
Msg string `json:"msg" dc:"消息"`
}
// 审核作者
// =============================
type ReviewReq struct {
g.Meta `path:"/author/review" tags:"Backend/Author" method:"post" summary:"审核作者申请"`
AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"`
Status int `json:"status" dc:"审核状态1通过3拒绝" v:"required|in:1,3"`
}
type ReviewRes struct {
Success bool `json:"success" dc:"是否成功"`
} }

View File

@ -17,10 +17,13 @@ type IBookV1 interface {
Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error)
ShelfAdd(ctx context.Context, req *v1.ShelfAddReq) (res *v1.ShelfAddRes, err error) ShelfAdd(ctx context.Context, req *v1.ShelfAddReq) (res *v1.ShelfAddRes, err error)
ShelfRemove(ctx context.Context, req *v1.ShelfRemoveReq) (res *v1.ShelfRemoveRes, err error) ShelfRemove(ctx context.Context, req *v1.ShelfRemoveReq) (res *v1.ShelfRemoveRes, err error)
HistoryRemove(ctx context.Context, req *v1.HistoryRemoveReq) (res *v1.HistoryRemoveRes, err error)
AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error) AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error)
AppDetail(ctx context.Context, req *v1.AppDetailReq) (res *v1.AppDetailRes, err error) AppDetail(ctx context.Context, req *v1.AppDetailReq) (res *v1.AppDetailRes, err error)
AppRate(ctx context.Context, req *v1.AppRateReq) (res *v1.AppRateRes, err error) AppRate(ctx context.Context, req *v1.AppRateReq) (res *v1.AppRateRes, err error)
MyList(ctx context.Context, req *v1.MyListReq) (res *v1.MyListRes, err error) MyList(ctx context.Context, req *v1.MyListReq) (res *v1.MyListRes, err error)
BookSetFeatured(ctx context.Context, req *v1.BookSetFeaturedReq) (res *v1.BookSetFeaturedRes, err error) BookSetFeatured(ctx context.Context, req *v1.BookSetFeaturedReq) (res *v1.BookSetFeaturedRes, err error)
BookSetRecommended(ctx context.Context, req *v1.BookSetRecommendedReq) (res *v1.BookSetRecommendedRes, err error) BookSetRecommended(ctx context.Context, req *v1.BookSetRecommendedReq) (res *v1.BookSetRecommendedRes, err error)
BookSetHot(ctx context.Context, req *v1.BookSetHotReq) (res *v1.BookSetHotRes, err error)
BookCoverImage(ctx context.Context, req *v1.BookCoverImageReq) (res *v1.BookCoverImageRes, err error)
} }

View File

@ -3,11 +3,13 @@ package v1
import ( import (
"server/internal/model" "server/internal/model"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
) )
type ListReq struct { type ListReq struct {
g.Meta `path:"/book" tags:"Backend/Author" method:"get" summary:"获取小说列表"` g.Meta `path:"/book" tags:"Backend/Book" method:"get" summary:"获取小说列表"`
Page int `json:"page" dc:"页码"` Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"` Size int `json:"size" dc:"每页数量"`
Title string `json:"title" dc:"书名模糊搜索"` Title string `json:"title" dc:"书名模糊搜索"`
@ -23,7 +25,7 @@ type ListRes struct {
} }
type AddReq struct { type AddReq struct {
g.Meta `path:"/book" tags:"Backend/Author" method:"post" summary:"新增小说"` g.Meta `path:"/book" tags:"Backend/Book" method:"post" summary:"新增小说"`
AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"` AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"`
CategoryId int64 `json:"categoryId" dc:"分类ID" v:"required"` CategoryId int64 `json:"categoryId" dc:"分类ID" v:"required"`
Title string `json:"title" dc:"书名" v:"required"` Title string `json:"title" dc:"书名" v:"required"`
@ -40,7 +42,7 @@ type AddRes struct {
} }
type EditReq struct { type EditReq struct {
g.Meta `path:"/book" tags:"Backend/Author" method:"put" summary:"编辑小说"` g.Meta `path:"/book" tags:"Backend/Book" method:"put" summary:"编辑小说"`
Id int64 `json:"id" dc:"书籍ID" v:"required"` Id int64 `json:"id" dc:"书籍ID" v:"required"`
AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"` AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"`
CategoryId int64 `json:"categoryId" dc:"分类ID" v:"required"` CategoryId int64 `json:"categoryId" dc:"分类ID" v:"required"`
@ -58,7 +60,7 @@ type EditRes struct {
} }
type DelReq struct { type DelReq struct {
g.Meta `path:"/book" tags:"Backend/Author" method:"delete" summary:"删除小说"` g.Meta `path:"/book" tags:"Backend/Book" method:"delete" summary:"删除小说"`
Id int64 `json:"id" dc:"书籍ID" v:"required"` Id int64 `json:"id" dc:"书籍ID" v:"required"`
} }
type DelRes struct { type DelRes struct {
@ -67,7 +69,7 @@ type DelRes struct {
// 加入书架 // 加入书架
type ShelfAddReq struct { type ShelfAddReq struct {
g.Meta `path:"/book/shelf/add" tags:"APP" method:"post" summary:"加入书架"` g.Meta `path:"/book/shelf/add" tags:"APP/Book" method:"post" summary:"加入书架"`
BookId int64 `json:"bookId" dc:"小说ID" v:"required"` BookId int64 `json:"bookId" dc:"小说ID" v:"required"`
} }
type ShelfAddRes struct { type ShelfAddRes struct {
@ -76,21 +78,30 @@ type ShelfAddRes struct {
// 移除书架 // 移除书架
type ShelfRemoveReq struct { type ShelfRemoveReq struct {
g.Meta `path:"/book/shelf/remove" tags:"APP" method:"post" summary:"移除书架(支持批量)"` g.Meta `path:"/book/shelf/remove" tags:"APP/Book" method:"post" summary:"移除书架(支持批量)"`
BookIds []int64 `json:"bookIds" dc:"小说ID列表" v:"required"` BookIds []int64 `json:"bookIds" dc:"小说ID列表" v:"required"`
} }
type ShelfRemoveRes struct { type ShelfRemoveRes struct {
Success bool `json:"success" dc:"是否成功"` Success bool `json:"success" dc:"是否成功"`
} }
type HistoryRemoveReq struct {
g.Meta `path:"/book/history/remove" tags:"APP/Book" method:"post" summary:"移除阅读记录(支持批量)"`
BookIds []int64 `json:"bookIds" dc:"小说ID列表" v:"required"`
}
type HistoryRemoveRes struct {
Success bool `json:"success" dc:"是否成功"`
}
// App 获取书籍列表 // App 获取书籍列表
type AppListReq struct { type AppListReq struct {
g.Meta `path:"/book/app/list" tags:"APP" method:"get" summary:"App获取书籍列表"` g.Meta `path:"/book/app/list" tags:"APP/Book" method:"get" summary:"App获取书籍列表"`
Page int `json:"page" dc:"页码"` Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"` Size int `json:"size" dc:"每页数量"`
IsRecommended bool `json:"isRecommended" dc:"是否推荐"` IsRecommended bool `json:"isRecommended" dc:"是否推荐"`
IsFeatured bool `json:"isFeatured" dc:"是否精选"` IsFeatured bool `json:"isFeatured" dc:"是否精选"`
IsLatest int `json:"isLatest" dc:"是否最新"` IsLatest int `json:"isLatest" dc:"是否最新"`
IsHot bool `json:"isHot" dc:"是否最热"`
CategoryId int64 `json:"categoryId" dc:"分类ID"` CategoryId int64 `json:"categoryId" dc:"分类ID"`
Title string `json:"title" dc:"书名模糊搜索"` Title string `json:"title" dc:"书名模糊搜索"`
AuthorId int `json:"authorId" dc:"作者ID"` AuthorId int `json:"authorId" dc:"作者ID"`
@ -104,34 +115,42 @@ type AppListRes struct {
// App 获取书籍详情 // App 获取书籍详情
type AppDetailReq struct { type AppDetailReq struct {
g.Meta `path:"/book/app/detail" tags:"APP" method:"get" summary:"App获取书籍详情"` g.Meta `path:"/book/app/detail" tags:"APP/Book" method:"get" summary:"App获取书籍详情"`
Id int64 `json:"id" dc:"书籍ID" v:"required"` Id int64 `json:"id" dc:"书籍ID" v:"required"`
} }
type AppDetailRes struct { type AppDetailRes struct {
Id int64 `json:"id" dc:"书籍ID"` Id int64 `json:"id" dc:"书籍ID"`
AuthorId int64 `json:"authorId" dc:"作者ID"`
CategoryId int64 `json:"categoryId" dc:"分类ID"`
Title string `json:"title" dc:"书名"`
CoverUrl string `json:"coverUrl" dc:"封面图"` CoverUrl string `json:"coverUrl" dc:"封面图"`
Rating float64 `json:"rating" dc:"评分"`
Title string `json:"title" dc:"标题"`
Description string `json:"description" dc:"简介"` Description string `json:"description" dc:"简介"`
Status int `json:"status" dc:"状态"` AuthorId int64 `json:"authorId" dc:"作者ID"`
Tags string `json:"tags" dc:"标签"` Author model.AppAuthor `json:"author" dc:"作者信息"`
IsRecommended int `json:"isRecommended" dc:"是否推荐"`
IsFeatured int `json:"isFeatured" dc:"是否精选"` IsFeatured int `json:"isFeatured" dc:"是否精选"`
Language string `json:"language" dc:"语言"` Language string `json:"language" dc:"语言"`
Rating float64 `json:"rating" dc:"分"` CategoryId int64 `json:"categoryId" dc:"分类ID"`
Category model.Category `json:"category" dc:"分类信息"`
Status int `json:"status" dc:"状态"`
WordsCount int `json:"wordsCount" dc:"字数"`
ChaptersCount int `json:"chaptersCount" dc:"章节数"`
ReadCount int64 `json:"readCount" dc:"阅读人数"`
CurrentReaders int64 `json:"currentReaders" dc:"在读人数"` CurrentReaders int64 `json:"currentReaders" dc:"在读人数"`
CreatedAt string `json:"createdAt" dc:"创建时间"` Tags string `json:"tags" dc:"标签"`
UpdatedAt string `json:"updatedAt" dc:"更新时间"` IsRecommended int `json:"isRecommended" dc:"是否推荐"`
HasRated bool `json:"hasRated" dc:"当前用户是否已评分"`
MyRating float64 `json:"myRating" dc:"当前用户评分未评分为0"`
HasRead bool `json:"hasRead" dc:"是否读过"` HasRead bool `json:"hasRead" dc:"是否读过"`
ReadProgress int `json:"readProgress" dc:"阅读进度百分比"` ReadProgress int `json:"readProgress" dc:"阅读进度百分比"`
LastChapterId int64 `json:"lastChapterId" dc:"最近阅读章节ID"` LastChapterId int64 `json:"lastChapterId" dc:"最近阅读章节ID"`
LastReadAt string `json:"lastReadAt" dc:"最近阅读时间"` LastReadAt string `json:"lastReadAt" dc:"最近阅读时间"`
IsInBookshelf bool `json:"isInBookshelf" dc:"当前用户是否已加入书架"`
CreatedAt string `json:"createdAt" dc:"创建时间"`
UpdatedAt string `json:"updatedAt" dc:"更新时间"`
} }
// App 用户评分 // App 用户评分
type AppRateReq struct { type AppRateReq struct {
g.Meta `path:"/book/app/rate" tags:"APP" method:"post" summary:"App用户评分"` g.Meta `path:"/book/app/rate" tags:"APP/Book" method:"post" summary:"App用户评分"`
BookId int64 `json:"bookId" dc:"书籍ID" v:"required"` BookId int64 `json:"bookId" dc:"书籍ID" v:"required"`
Rating float64 `json:"rating" dc:"评分(1-10分)" v:"required"` Rating float64 `json:"rating" dc:"评分(1-10分)" v:"required"`
} }
@ -152,7 +171,7 @@ type BookAppItem struct {
// 我的书籍列表 // 我的书籍列表
// ============================= // =============================
type MyListReq struct { type MyListReq struct {
g.Meta `path:"/book/app/my-books" tags:"APP" method:"get" summary:"获取我的书籍列表"` g.Meta `path:"/book/app/my-books" tags:"APP/Book" method:"get" summary:"获取我的书籍列表"`
Type int `json:"type" dc:"类型1-正在读 2-已读完 3-历史记录" v:"required"` Type int `json:"type" dc:"类型1-正在读 2-已读完 3-历史记录" v:"required"`
Page int `json:"page" dc:"页码"` Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"` Size int `json:"size" dc:"每页数量"`
@ -183,3 +202,20 @@ type BookSetRecommendedReq struct {
type BookSetRecommendedRes struct { type BookSetRecommendedRes struct {
Success bool `json:"success" dc:"是否成功"` Success bool `json:"success" dc:"是否成功"`
} }
type BookSetHotReq struct {
g.Meta `path:"/book/set-hot" tags:"Backend/Book" method:"post" summary:"设置书籍热门状态"`
Id int64 `json:"id" dc:"书籍ID" v:"required"`
IsHot int `json:"isHot" dc:"是否热门" v:"required"`
}
type BookSetHotRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type BookCoverImageReq struct {
g.Meta `path:"/book/coverImage" tags:"Backend/Book" method:"post" summary:"上传封面图"`
File *ghttp.UploadFile `json:"file" v:"required#请上传文件"`
}
type BookCoverImageRes struct {
ImageUrl string `json:"imageUrl" dc:"图片地址"`
}

View File

@ -7,7 +7,7 @@ import (
) )
type ListReq struct { type ListReq struct {
g.Meta `path:"/category" tags:"APP" method:"get" summary:"获取分类列表"` g.Meta `path:"/category" tags:"Backend-APP/Category" method:"get" summary:"获取分类列表"`
Page int `json:"page" dc:"页码"` Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"` Size int `json:"size" dc:"每页数量"`
Name string `json:"name" dc:"分类名称(模糊搜索)"` Name string `json:"name" dc:"分类名称(模糊搜索)"`
@ -19,7 +19,7 @@ type ListRes struct {
} }
type AddReq struct { type AddReq struct {
g.Meta `path:"/category" tags:"Backend/Admin" method:"post" summary:"新增分类"` g.Meta `path:"/category" tags:"Backend/Category" method:"post" summary:"新增分类"`
Name string `json:"name" dc:"分类名称" v:"required"` Name string `json:"name" dc:"分类名称" v:"required"`
Channel int `json:"channel" dc:"频道类型1=男频2=女频" v:"required"` Channel int `json:"channel" dc:"频道类型1=男频2=女频" v:"required"`
} }
@ -28,7 +28,7 @@ type AddRes struct {
} }
type EditReq struct { type EditReq struct {
g.Meta `path:"/category" tags:"Backend/Admin" method:"put" summary:"编辑分类"` g.Meta `path:"/category" tags:"Backend/Category" method:"put" summary:"编辑分类"`
Id int64 `json:"id" dc:"分类ID" v:"required"` Id int64 `json:"id" dc:"分类ID" v:"required"`
Name string `json:"name" dc:"分类名称" v:"required"` Name string `json:"name" dc:"分类名称" v:"required"`
Channel int `json:"channel" dc:"频道类型1=男频2=女频" v:"required"` Channel int `json:"channel" dc:"频道类型1=男频2=女频" v:"required"`
@ -38,7 +38,7 @@ type EditRes struct {
} }
type DelReq struct { type DelReq struct {
g.Meta `path:"/category" tags:"Backend/Admin" method:"delete" summary:"删除分类"` g.Meta `path:"/category" tags:"Backend/Category" method:"delete" summary:"删除分类"`
Id int64 `json:"id" dc:"分类ID" v:"required"` Id int64 `json:"id" dc:"分类ID" v:"required"`
} }
type DelRes struct { type DelRes struct {

View File

@ -7,7 +7,7 @@ import (
) )
type ListReq struct { type ListReq struct {
g.Meta `path:"/chapter" tags:"Backend/Author" method:"get" summary:"获取章节列表"` g.Meta `path:"/chapter" tags:"Backend/Chapter" method:"get" summary:"获取章节列表"`
Page int `json:"page" dc:"页码"` Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"` Size int `json:"size" dc:"每页数量"`
BookId int64 `json:"bookId" dc:"小说ID"` BookId int64 `json:"bookId" dc:"小说ID"`
@ -20,7 +20,7 @@ type ListRes struct {
} }
type AddReq struct { type AddReq struct {
g.Meta `path:"/chapter" tags:"Backend/Author" method:"post" summary:"新增章节"` g.Meta `path:"/chapter" tags:"Backend/Chapter" method:"post" summary:"新增章节"`
BookId int64 `json:"bookId" dc:"小说ID" v:"required"` BookId int64 `json:"bookId" dc:"小说ID" v:"required"`
Title string `json:"title" dc:"章节标题" v:"required"` Title string `json:"title" dc:"章节标题" v:"required"`
Content string `json:"content" dc:"章节内容" v:"required"` Content string `json:"content" dc:"章节内容" v:"required"`
@ -34,7 +34,7 @@ type AddRes struct {
} }
type EditReq struct { type EditReq struct {
g.Meta `path:"/chapter" tags:"Backend/Author" method:"put" summary:"编辑章节"` g.Meta `path:"/chapter" tags:"Backend/Chapter" method:"put" summary:"编辑章节"`
Id int64 `json:"id" dc:"章节ID" v:"required"` Id int64 `json:"id" dc:"章节ID" v:"required"`
BookId int64 `json:"bookId" dc:"小说ID" v:"required"` BookId int64 `json:"bookId" dc:"小说ID" v:"required"`
Title string `json:"title" dc:"章节标题" v:"required"` Title string `json:"title" dc:"章节标题" v:"required"`
@ -49,7 +49,7 @@ type EditRes struct {
} }
type DelReq struct { type DelReq struct {
g.Meta `path:"/chapter" tags:"Backend/Author" method:"delete" summary:"删除章节"` g.Meta `path:"/chapter" tags:"Backend/Chapter" method:"delete" summary:"删除章节"`
Id int64 `json:"id" dc:"章节ID" v:"required"` Id int64 `json:"id" dc:"章节ID" v:"required"`
} }
type DelRes struct { type DelRes struct {
@ -57,7 +57,7 @@ type DelRes struct {
} }
type AppListReq struct { type AppListReq struct {
g.Meta `path:"/chapter/app/list" tags:"APP" method:"get" summary:"App获取章节列表"` g.Meta `path:"/chapter/app/list" tags:"APP/Chapter" method:"get" summary:"App获取章节列表"`
BookId int64 `json:"bookId" dc:"书籍ID" v:"required"` BookId int64 `json:"bookId" dc:"书籍ID" v:"required"`
IsDesc bool `json:"isDesc" dc:"是否逆序排列"` IsDesc bool `json:"isDesc" dc:"是否逆序排列"`
Page int `json:"page" dc:"页码"` Page int `json:"page" dc:"页码"`
@ -69,7 +69,7 @@ type AppListRes struct {
} }
type AppDetailReq struct { type AppDetailReq struct {
g.Meta `path:"/chapter/app/detail" tags:"APP" method:"get" summary:"App获取章节详情"` g.Meta `path:"/chapter/app/detail" tags:"APP/Chapter" method:"get" summary:"App获取章节详情"`
Id int64 `json:"id" dc:"章节ID" v:"required"` Id int64 `json:"id" dc:"章节ID" v:"required"`
} }
type AppDetailRes struct { type AppDetailRes struct {
@ -85,7 +85,7 @@ type AppDetailRes struct {
} }
type AppPurchaseReq struct { type AppPurchaseReq struct {
g.Meta `path:"/chapter/app/purchase" tags:"APP" method:"post" summary:"App购买章节"` g.Meta `path:"/chapter/app/purchase" tags:"APP/Chapter" method:"post" summary:"App购买章节"`
Id int64 `json:"id" dc:"章节ID" v:"required"` Id int64 `json:"id" dc:"章节ID" v:"required"`
} }
type AppPurchaseRes struct { type AppPurchaseRes struct {
@ -93,11 +93,11 @@ type AppPurchaseRes struct {
} }
type AppProgressReq struct { type AppProgressReq struct {
g.Meta `path:"/chapter/app/progress" tags:"APP" method:"post" summary:"App上传阅读进度"` g.Meta `path:"/chapter/app/progress" tags:"APP/Chapter" method:"post" summary:"App上传阅读进度"`
BookId int64 `json:"bookId" dc:"书籍ID" v:"required"` BookId int64 `json:"bookId" dc:"书籍ID" v:"required"`
ChapterId int64 `json:"chapterId" dc:"章节ID" v:"required"` Chapters []model.ChapterProgressItem `json:"chapters" dc:"章节进度列表" v:"required"`
Progress int `json:"progress" dc:"阅读进度百分比(0-100)"`
} }
type AppProgressRes struct { type AppProgressRes struct {
Success bool `json:"success" dc:"是否成功"` Success bool `json:"success" dc:"是否成功"`
} }

View File

@ -7,7 +7,7 @@ import (
) )
type ListReq struct { type ListReq struct {
g.Meta `path:"/feedback" tags:"Backend/Admin" method:"get" summary:"获取反馈列表"` g.Meta `path:"/feedback" tags:"Backend/Feedback" method:"get" summary:"获取反馈列表"`
Page int `json:"page" dc:"页码"` Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"` Size int `json:"size" dc:"每页数量"`
UserId int64 `json:"userId" dc:"用户ID"` UserId int64 `json:"userId" dc:"用户ID"`
@ -19,7 +19,7 @@ type ListRes struct {
} }
type AddReq struct { type AddReq struct {
g.Meta `path:"/feedback" tags:"APP" method:"post" summary:"新增反馈"` g.Meta `path:"/feedback" tags:"APP/Feedback" method:"post" summary:"新增反馈"`
Content string `json:"content" dc:"反馈内容" v:"required"` Content string `json:"content" dc:"反馈内容" v:"required"`
} }
type AddRes struct { type AddRes struct {

View File

@ -0,0 +1,22 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package recommend
import (
"context"
"server/api/recommend/v1"
)
type IRecommendV1 interface {
List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error)
Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error)
Edit(ctx context.Context, req *v1.EditReq) (res *v1.EditRes, err error)
Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error)
SetStatus(ctx context.Context, req *v1.SetStatusReq) (res *v1.SetStatusRes, err error)
SortOrder(ctx context.Context, req *v1.SortOrderReq) (res *v1.SortOrderRes, err error)
AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error)
UploadCover(ctx context.Context, req *v1.UploadCoverReq) (res *v1.UploadCoverRes, err error)
}

View File

@ -0,0 +1,93 @@
package v1
import (
"server/internal/model"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
type ListReq struct {
g.Meta `path:"/recommend" tags:"Backend/Recommend" method:"get" summary:"获取推荐列表"`
Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"`
Type int `json:"type" dc:"推荐类型"`
Status int `json:"status" dc:"状态"`
BookId int64 `json:"bookId" dc:"书籍ID"`
}
type ListRes struct {
Total int `json:"total" dc:"总数"`
List []model.BookRecommendation `json:"list" dc:"推荐列表"`
}
type AddReq struct {
g.Meta `path:"/recommend" tags:"Backend/Recommend" method:"post" summary:"新增推荐"`
BookId int64 `json:"bookId" dc:"书籍ID" v:"required"`
Type int `json:"type" dc:"推荐类型" v:"required"`
CoverUrl string `json:"coverUrl" dc:"封面图" v:"required"`
SortOrder int `json:"sortOrder" dc:"排序" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type AddRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type EditReq struct {
g.Meta `path:"/recommend" tags:"Backend/Recommend" method:"put" summary:"编辑推荐"`
Id int64 `json:"id" dc:"推荐ID" v:"required"`
BookId int64 `json:"bookId" dc:"书籍ID" v:"required"`
Type int `json:"type" dc:"推荐类型" v:"required"`
CoverUrl string `json:"coverUrl" dc:"封面图" v:"required"`
SortOrder int `json:"sortOrder" dc:"排序" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type EditRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type DelReq struct {
g.Meta `path:"/recommend" tags:"Backend/Recommend" method:"delete" summary:"删除推荐"`
Id int64 `json:"id" dc:"推荐ID" v:"required"`
}
type DelRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type SetStatusReq struct {
g.Meta `path:"/recommend/set-status" tags:"Backend/Recommend" method:"post" summary:"设置推荐状态"`
Id int64 `json:"id" dc:"推荐ID" v:"required"`
Status int `json:"status" dc:"状态" v:"required"`
}
type SetStatusRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type SortOrderReq struct {
g.Meta `path:"/recommend/sort-order" tags:"Backend/Recommend" method:"post" summary:"设置推荐排序"`
Id int64 `json:"id" dc:"推荐ID" v:"required"`
SortOrder int `json:"sortOrder" dc:"排序" v:"required"`
}
type SortOrderRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type AppListReq struct {
g.Meta `path:"/recommend/app/list" tags:"APP/Recommend" method:"get" summary:"App获取推荐列表"`
Type int `json:"type" dc:"推荐类型"`
Status int `json:"status" dc:"状态"`
Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"`
}
type AppListRes struct {
Total int `json:"total" dc:"总数"`
List []model.RecommendAppItem `json:"list" dc:"推荐列表"`
}
type UploadCoverReq struct {
g.Meta `path:"/recommend/upload-cover" tags:"Backend/Recommend" method:"post" summary:"上传推荐封面图"`
File *ghttp.UploadFile `json:"file" type:"file" dc:"图片文件"`
}
type UploadCoverRes struct {
Url string `json:"url" dc:"图片访问地址"`
}

16
api/system/system.go Normal file
View File

@ -0,0 +1,16 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package system
import (
"context"
"server/api/system/v1"
)
type ISystemV1 interface {
SystemSave(ctx context.Context, req *v1.SystemSaveReq) (res *v1.SystemSaveRes, err error)
SystemVersion(ctx context.Context, req *v1.SystemVersionReq) (res *v1.SystemVersionRes, err error)
}

19
api/system/v1/system.go Normal file
View File

@ -0,0 +1,19 @@
package v1
import "github.com/gogf/gf/v2/frame/g"
type SystemSaveReq struct {
g.Meta `path:"/system/save" method:"post" tags:"Backend/System" sm:"(管理员)保存系统设置"`
Key string
Value string
}
type SystemSaveRes struct {
}
type SystemVersionReq struct {
g.Meta `path:"/system/version" method:"get" tags:"APP/System" sm:"(访客、用户、管理员)获取版本信息"`
}
type SystemVersionRes struct {
Ios map[string]string `json:"ios"`
Android map[string]string `json:"android"`
}

19
api/task/task.go Normal file
View File

@ -0,0 +1,19 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package task
import (
"context"
"server/api/task/v1"
)
type ITaskV1 interface {
List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error)
Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error)
Edit(ctx context.Context, req *v1.EditReq) (res *v1.EditRes, err error)
Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error)
AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error)
}

61
api/task/v1/task.go Normal file
View File

@ -0,0 +1,61 @@
package v1
import (
"server/internal/model"
"github.com/gogf/gf/v2/frame/g"
)
// ================== 任务接口 ==================
type ListReq struct {
g.Meta `path:"/task" tags:"Backend/Task" method:"get" summary:"任务列表"`
Page int `json:"page"`
Size int `json:"size"`
Title string `json:"title" dc:"任务标题(模糊搜索)"`
Status int `json:"status" dc:"状态1启用2禁用"`
}
type ListRes struct {
Total int `json:"total"`
List []model.Task `json:"list"`
}
type AddReq struct {
g.Meta `path:"/task" tags:"Backend/Task" method:"post" summary:"新增任务"`
TaskType uint `json:"taskType"`
Title string `json:"title"`
Description string `json:"description"`
RewardPoints uint `json:"rewardPoints"`
Status int `json:"status"`
}
type AddRes struct {
Success bool `json:"success"`
}
type EditReq struct {
g.Meta `path:"/task" tags:"Backend/Task" method:"put" summary:"编辑任务"`
Id int64 `json:"id"`
TaskType uint `json:"taskType"`
Title string `json:"title"`
Description string `json:"description"`
RewardPoints uint `json:"rewardPoints"`
Status int `json:"status"`
}
type EditRes struct {
Success bool `json:"success"`
}
type DelReq struct {
g.Meta `path:"/task" tags:"Backend/Task" method:"delete" summary:"删除任务"`
Id int64 `json:"id"`
}
type DelRes struct {
Success bool `json:"success"`
}
// ================== App端任务接口 ==================
type AppListReq struct {
g.Meta `path:"/task/appList" tags:"APP/Task" method:"get" summary:"App端任务列表"`
}
type AppListRes struct {
List []model.TaskSimpleItem `json:"list"`
}

View File

@ -5,19 +5,24 @@ import (
) )
type InfoReq struct { type InfoReq struct {
g.Meta `path:"/user/info" tags:"APP" method:"get" summary:"获取用户信息"` g.Meta `path:"/user/info" tags:"APP/User" method:"get" summary:"获取用户信息"`
} }
type InfoRes struct { type InfoRes struct {
g.Meta `mime:"application/json"` g.Meta `mime:"application/json"`
UserId int64 `json:"userId"` Id int64 `json:"id" dc:"用户ID"`
Username string `json:"username"` // 用户名 Username string `json:"username" dc:"用户名"`
Avatar string `json:"avatar"` // 头像 URL Avatar string `json:"avatar" dc:"头像URL"`
Email string `json:"email"` // 邮箱 Email string `json:"email" dc:"邮箱"`
Points uint64 `json:"points"` Points uint64 `json:"points" dc:"积分数量"`
BackgroundUrl string `json:"backgroundUrl" dc:"背景图片URL"`
AttentionCount int `json:"attentionCount" dc:"关注数量"`
Role string `json:"role" dc:"用户角色"`
IsAuthor bool `json:"isAuthor" dc:"是否是作者"`
AuthorStatus int `json:"authorStatus" dc:"作者申请状态0=未申请1=审核中2=已通过3=已拒绝"`
} }
type DeleteReq struct { type DeleteReq struct {
g.Meta `path:"/user/delete" tags:"APP" method:"post" summary:"删除用户"` g.Meta `path:"/user/delete" tags:"APP/User" method:"post" summary:"删除用户"`
Password string `json:"password" v:"required" dc:"密码"` Password string `json:"password" v:"required" dc:"密码"`
} }
@ -26,7 +31,7 @@ type DeleteRes struct {
} }
type LogoutReq struct { type LogoutReq struct {
g.Meta `path:"/user/logout" tags:"APP" method:"post" summary:"登出"` g.Meta `path:"/user/logout" tags:"APP/User" method:"post" summary:"登出"`
} }
type LogoutRes struct { type LogoutRes struct {
Success bool `json:"success" dc:"是否成功"` Success bool `json:"success" dc:"是否成功"`

View File

@ -4,6 +4,6 @@
gfcli: gfcli:
gen: gen:
dao: dao:
- link: "mysql:root:MSms0427@tcp(127.0.0.1:3306)/novel" - link: "mysql:root:MSms0427@tcp(127.0.0.1:3306)/novel2"
descriptionTag: true descriptionTag: true
tablesEx: "casbin_rule" tablesEx: "casbin_rule"

View File

@ -2,6 +2,7 @@ package cmd
import ( import (
"context" "context"
"server/internal/controller/activity"
"server/internal/controller/admin" "server/internal/controller/admin"
"server/internal/controller/auth" "server/internal/controller/auth"
"server/internal/controller/author" "server/internal/controller/author"
@ -9,6 +10,9 @@ import (
"server/internal/controller/category" "server/internal/controller/category"
"server/internal/controller/chapter" "server/internal/controller/chapter"
"server/internal/controller/feedback" "server/internal/controller/feedback"
"server/internal/controller/recommend"
"server/internal/controller/system"
"server/internal/controller/task"
"server/internal/controller/user" "server/internal/controller/user"
"server/internal/middleware" "server/internal/middleware"
@ -42,6 +46,10 @@ var (
chapter.NewV1(), chapter.NewV1(),
feedback.NewV1(), feedback.NewV1(),
user.NewV1(), user.NewV1(),
recommend.NewV1(),
activity.NewV1(),
task.NewV1(),
system.NewV1(),
) )
}) })
}) })

38
internal/consts/ads.go Normal file
View File

@ -0,0 +1,38 @@
package consts
// AdState 广告状态枚举
type AdState int
const (
StateFetchFailed AdState = iota + 1 // 拉取失败
StateFetchSuccess // 拉取成功
StateDisplayFailed // 显示失败
StateDisplaySuccess // 显示成功
StateNotWatched // 未观看完成
StateWatched // 观看完成
StateNotClicked // 未点击
StateClicked // 已点击
StateNotDownloaded // 未下载
StateDownloaded // 已下载
)
// GetStateDescription 获取状态描述
func GetStateDescription(state AdState) string {
descriptions := map[AdState]string{
StateFetchFailed: "拉取失败",
StateFetchSuccess: "拉取成功",
StateDisplayFailed: "显示失败",
StateDisplaySuccess: "显示成功",
StateNotWatched: "未观看完成",
StateWatched: "观看完成",
StateNotClicked: "未点击",
StateClicked: "已点击",
StateNotDownloaded: "未下载",
StateDownloaded: "已下载",
}
if desc, exists := descriptions[state]; exists {
return desc
}
return "未知状态"
}

View File

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

View File

@ -0,0 +1,15 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package activity
import (
"server/api/activity"
)
type ControllerV1 struct{}
func NewV1() activity.IActivityV1 {
return &ControllerV1{}
}

View File

@ -0,0 +1,23 @@
package activity
import (
"context"
v1 "server/api/activity/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) ItemAdd(ctx context.Context, req *v1.ItemAddReq) (res *v1.ItemAddRes, err error) {
id, err := service.SignInRewardDetails().Create(ctx, &model.SignInRewardDetail{
RuleId: req.RuleId,
DayNumber: req.DayNumber,
RewardType: req.RewardType,
Quantity: req.Quantity,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.ItemAddRes{Id: id, Success: true}, nil
}

View File

@ -0,0 +1,17 @@
package activity
import (
"context"
v1 "server/api/activity/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) ItemDel(ctx context.Context, req *v1.ItemDelReq) (res *v1.ItemDelRes, err error) {
out, err := service.SignInRewardDetails().Delete(ctx, &model.SignInRewardDetailDeleteIn{Id: req.Id})
if err != nil {
return nil, err
}
return &v1.ItemDelRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,24 @@
package activity
import (
"context"
v1 "server/api/activity/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) ItemEdit(ctx context.Context, req *v1.ItemEditReq) (res *v1.ItemEditRes, err error) {
err = service.SignInRewardDetails().Update(ctx, &model.SignInRewardDetail{
Id: req.Id,
RuleId: req.RuleId,
DayNumber: req.DayNumber,
RewardType: req.RewardType,
Quantity: req.Quantity,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.ItemEditRes{Success: true}, nil
}

View File

@ -0,0 +1,17 @@
package activity
import (
"context"
v1 "server/api/activity/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) ItemGet(ctx context.Context, req *v1.ItemGetReq) (res *v1.ItemGetRes, err error) {
out, err := service.SignInRewardDetails().Get(ctx, &model.SignInRewardDetailGetIn{Id: req.Id})
if err != nil {
return nil, err
}
return &v1.ItemGetRes{SignInRewardDetail: out.SignInRewardDetail}, nil
}

View File

@ -0,0 +1,20 @@
package activity
import (
"context"
v1 "server/api/activity/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) ItemList(ctx context.Context, req *v1.ItemListReq) (res *v1.ItemListRes, err error) {
out, err := service.SignInRewardDetails().List(ctx, &model.SignInRewardDetailListIn{
RuleId: req.RuleId,
})
if err != nil {
return nil, err
}
return &v1.ItemListRes{
List: out.List,
}, nil
}

View File

@ -0,0 +1,19 @@
package activity
import (
"context"
v1 "server/api/activity/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) ItemSetStatus(ctx context.Context, req *v1.ItemSetStatusReq) (res *v1.ItemSetStatusRes, err error) {
out, err := service.SignInRewardDetails().SetStatus(ctx, &model.SignInRewardDetailSetStatusIn{
Id: req.Id,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.ItemSetStatusRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,23 @@
package activity
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/activity/v1"
)
func (c *ControllerV1) RuleAdd(ctx context.Context, req *v1.RuleAddReq) (res *v1.RuleAddRes, err error) {
out, err := service.SignInRewardRules().Create(ctx, &model.SignInRewardRulesCreateIn{
RuleName: req.RuleName,
StartDate: req.StartDate,
EndDate: req.EndDate,
CycleDays: req.CycleDays,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.RuleAddRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,19 @@
package activity
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/activity/v1"
)
func (c *ControllerV1) RuleDel(ctx context.Context, req *v1.RuleDelReq) (res *v1.RuleDelRes, err error) {
out, err := service.SignInRewardRules().Delete(ctx, &model.SignInRewardRulesDeleteIn{
Id: req.Id,
})
if err != nil {
return nil, err
}
return &v1.RuleDelRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,24 @@
package activity
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/activity/v1"
)
func (c *ControllerV1) RuleEdit(ctx context.Context, req *v1.RuleEditReq) (res *v1.RuleEditRes, err error) {
out, err := service.SignInRewardRules().Update(ctx, &model.SignInRewardRulesUpdateIn{
Id: req.Id,
RuleName: req.RuleName,
CycleDays: req.CycleDays,
StartDate: req.StartDate,
EndDate: req.EndDate,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.RuleEditRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,25 @@
package activity
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/activity/v1"
)
func (c *ControllerV1) RuleList(ctx context.Context, req *v1.RuleListReq) (res *v1.RuleListRes, err error) {
out, err := service.SignInRewardRules().List(ctx, &model.SignInRewardRulesListIn{
Page: req.Page,
RuleName: req.RuleName,
Size: req.Size,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.RuleListRes{
Total: out.Total,
List: out.List,
}, nil
}

View File

@ -0,0 +1,20 @@
package activity
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/activity/v1"
)
func (c *ControllerV1) RuleSetStatus(ctx context.Context, req *v1.RuleSetStatusReq) (res *v1.RuleSetStatusRes, err error) {
out, err := service.SignInRewardRules().SetStatus(ctx, &model.SignInRewardRulesSetStatusIn{
Id: req.Id,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.RuleSetStatusRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,26 @@
package activity
import (
"context"
v1 "server/api/activity/v1"
"server/internal/model"
"server/internal/service"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
func (c *ControllerV1) SignIn(ctx context.Context, req *v1.SignInReq) (res *v1.SignInRes, err error) {
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
in := &model.UserSignInLogSignIn{
UserId: userId,
RuleId: req.RuleId,
RewardDetailId: req.RewardDetailId,
SignInDate: gtime.Now(), // 或根据 req.SignInDate 解析
}
out, err := service.UserSignInLogs().Sign(ctx, in)
if err != nil {
return nil, err
}
return &v1.SignInRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,24 @@
package activity
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/activity/v1"
)
func (c *ControllerV1) SignInList(ctx context.Context, req *v1.SignInListReq) (res *v1.SignInListRes, err error) {
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
out, err := service.SignInRewardRules().SignInList(ctx, &model.SignInListIn{
UserId: userId,
})
if err != nil {
return nil, err
}
res = &v1.SignInListRes{
List: out.List,
}
return &v1.SignInListRes{List: out.List}, nil
}

View File

@ -2,11 +2,12 @@ package admin
import ( import (
"context" "context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model" "server/internal/model"
"server/internal/service" "server/internal/service"
"server/api/admin/v1" "github.com/gogf/gf/v2/frame/g"
v1 "server/api/admin/v1"
) )
func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoRes, err error) { func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoRes, err error) {
@ -17,7 +18,8 @@ func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoR
return nil, err return nil, err
} }
return &v1.InfoRes{ return &v1.InfoRes{
AdminId: out.AdminId, Id: out.Id,
Username: out.Username, Username: out.Username,
Role: out.Role,
}, nil }, nil
} }

View File

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

View File

@ -0,0 +1,15 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package ads
import (
"server/api/ads"
)
type ControllerV1 struct{}
func NewV1() ads.IAdsV1 {
return &ControllerV1{}
}

View File

@ -0,0 +1,27 @@
package ads
import (
"context"
"github.com/gogf/gf/v2/frame/g"
v1 "server/api/ads/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) Upload(ctx context.Context, req *v1.UploadReq) (res *v1.UploadRes, err error) {
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
out, err := service.Ads().Upload(ctx, &model.AdsUploadIn{
UserId: userId,
NodeUid: req.NodeUid,
DeviceCode: req.DeviceCode,
Data: req.Data,
})
if err != nil {
return nil, err
}
return &v1.UploadRes{
Success: out.Success,
}, nil
}

View File

@ -0,0 +1,17 @@
package auth
import (
"context"
v1 "server/api/auth/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) AuthorLogin(ctx context.Context, req *v1.AuthorLoginReq) (res *v1.AuthorLoginRes, err error) {
out, err := service.User().AuthorLogin(ctx, &model.UserLoginIn{Email: req.Email, Password: req.Password})
if err != nil {
return nil, err
}
return &v1.AuthorLoginRes{Token: out.Token}, nil
}

View File

@ -5,7 +5,7 @@ import (
"server/internal/model" "server/internal/model"
"server/internal/service" "server/internal/service"
"server/api/auth/v1" v1 "server/api/auth/v1"
) )
func (c *ControllerV1) UserLogin(ctx context.Context, req *v1.UserLoginReq) (res *v1.UserLoginRes, err error) { func (c *ControllerV1) UserLogin(ctx context.Context, req *v1.UserLoginReq) (res *v1.UserLoginRes, err error) {

View File

@ -0,0 +1,23 @@
package author
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/author/v1"
)
func (c *ControllerV1) Apply(ctx context.Context, req *v1.ApplyReq) (res *v1.ApplyRes, err error) {
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
out, err := service.Author().Apply(ctx, &model.AuthorApplyIn{
UserId: userId,
PenName: req.PenName,
Bio: req.Bio,
})
if err != nil {
return nil, err
}
return &v1.ApplyRes{Success: out.Success, Msg: "Please wait patiently for the management review"}, nil
}

View File

@ -0,0 +1,23 @@
package author
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/author/v1"
)
func (c *ControllerV1) AuthorInfo(ctx context.Context, req *v1.AuthorInfoReq) (res *v1.AuthorInfoRes, err error) {
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
out, err := service.Author().AuthorInfo(ctx, &model.AuthorInfoIn{UserId: userId})
if err != nil {
return nil, err
}
return &v1.AuthorInfoRes{
Id: out.Id,
PenName: out.PenName,
Role: out.Role,
}, nil
}

View File

@ -13,5 +13,5 @@ func (c *ControllerV1) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.D
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &v1.DetailRes{Author: out}, nil return &v1.DetailRes{out}, nil
} }

View File

@ -0,0 +1,21 @@
package author
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/author/v1"
)
func (c *ControllerV1) Review(ctx context.Context, req *v1.ReviewReq) (res *v1.ReviewRes, err error) {
out, err := service.Author().Review(ctx, &model.AuthorReviewIn{
AuthorId: req.AuthorId,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.ReviewRes{Success: out.Success}, nil
}

View File

@ -23,22 +23,29 @@ func (c *ControllerV1) AppDetail(ctx context.Context, req *v1.AppDetailReq) (res
return &v1.AppDetailRes{ return &v1.AppDetailRes{
Id: out.Id, Id: out.Id,
AuthorId: out.AuthorId,
CategoryId: out.CategoryId,
Title: out.Title,
CoverUrl: out.CoverUrl, CoverUrl: out.CoverUrl,
Rating: out.Rating,
Title: out.Title,
Description: out.Description, Description: out.Description,
AuthorId: out.AuthorId,
Author: out.Author,
CategoryId: out.CategoryId,
Category: out.Category,
Status: out.Status, Status: out.Status,
WordsCount: out.WordsCount,
ChaptersCount: out.ChaptersCount,
ReadCount: out.ReadCount,
CurrentReaders: out.CurrentReaders,
Tags: out.Tags, Tags: out.Tags,
IsRecommended: out.IsRecommended, IsRecommended: out.IsRecommended,
Rating: out.Rating,
CurrentReaders: out.CurrentReaders,
CreatedAt: out.CreatedAt.String(), CreatedAt: out.CreatedAt.String(),
UpdatedAt: out.UpdatedAt.String(), UpdatedAt: out.UpdatedAt.String(),
// 添加阅读进度信息 HasRated: out.HasRated,
MyRating: out.MyRating,
HasRead: out.HasRead, HasRead: out.HasRead,
ReadProgress: out.ReadProgress, ReadProgress: out.ReadProgress,
LastChapterId: out.LastChapterId, LastChapterId: out.LastChapterId,
LastReadAt: out.LastReadAt, LastReadAt: out.LastReadAt,
IsInBookshelf: out.IsInBookshelf,
}, nil }, nil
} }

View File

@ -17,6 +17,7 @@ func (c *ControllerV1) AppList(ctx context.Context, req *v1.AppListReq) (res *v1
IsRecommended: req.IsRecommended, IsRecommended: req.IsRecommended,
IsFeatured: req.IsFeatured, IsFeatured: req.IsFeatured,
IsLatest: req.IsLatest, IsLatest: req.IsLatest,
IsHot: req.IsHot,
CategoryId: req.CategoryId, CategoryId: req.CategoryId,
Title: req.Title, Title: req.Title,
AuthorId: req.AuthorId, AuthorId: req.AuthorId,

View File

@ -0,0 +1,24 @@
package book
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/book/v1"
"server/utility/ecode"
"github.com/gogf/gf/v2/errors/gerror"
)
func (c *ControllerV1) BookCoverImage(ctx context.Context, req *v1.BookCoverImageReq) (res *v1.BookCoverImageRes, err error) {
if req.File == nil {
return nil, gerror.NewCode(ecode.Fail.Sub("image_file_required").Code())
}
image, err := service.Upload().UploadImage(ctx, &model.UploadImageIn{File: req.File, Type: "book"})
if err != nil {
return nil, err
}
return &v1.BookCoverImageRes{ImageUrl: image.ImageUrl}, nil
}

View File

@ -3,12 +3,15 @@ package book
import ( import (
"context" "context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"server/api/book/v1" "server/api/book/v1"
"server/internal/model"
"server/internal/service"
) )
func (c *ControllerV1) BookSetFeatured(ctx context.Context, req *v1.BookSetFeaturedReq) (res *v1.BookSetFeaturedRes, err error) { func (c *ControllerV1) BookSetFeatured(ctx context.Context, req *v1.BookSetFeaturedReq) (res *v1.BookSetFeaturedRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented) out, err := service.Book().SetFeatured(ctx, &model.BookSetFeaturedIn{Id: req.Id, IsFeatured: req.IsFeatured})
if err != nil {
return nil, err
}
return &v1.BookSetFeaturedRes{Success: out.Success}, nil
} }

View File

@ -0,0 +1,22 @@
package book
import (
"context"
v1 "server/api/book/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) BookSetHot(ctx context.Context, req *v1.BookSetHotReq) (res *v1.BookSetHotRes, err error) {
out, err := service.Book().SetHot(ctx, &model.BookSetHotIn{
Id: req.Id,
IsHot: req.IsHot,
})
if err != nil {
return nil, err
}
return &v1.BookSetHotRes{
Success: out.Success,
}, nil
}

View File

@ -2,13 +2,16 @@ package book
import ( import (
"context" "context"
"server/internal/model"
"github.com/gogf/gf/v2/errors/gcode" "server/internal/service"
"github.com/gogf/gf/v2/errors/gerror"
"server/api/book/v1" "server/api/book/v1"
) )
func (c *ControllerV1) BookSetRecommended(ctx context.Context, req *v1.BookSetRecommendedReq) (res *v1.BookSetRecommendedRes, err error) { func (c *ControllerV1) BookSetRecommended(ctx context.Context, req *v1.BookSetRecommendedReq) (res *v1.BookSetRecommendedRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented) out, err := service.Book().SetRecommended(ctx, &model.BookSetRecommendedIn{Id: req.Id, IsRecommended: req.IsRecommended})
if err != nil {
return nil, err
}
return &v1.BookSetRecommendedRes{Success: out.Success}, nil
} }

View File

@ -0,0 +1,21 @@
package book
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/book/v1"
)
func (c *ControllerV1) HistoryRemove(ctx context.Context, req *v1.HistoryRemoveReq) (res *v1.HistoryRemoveRes, err error) {
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
out, err := service.UserReadHistory().Remove(ctx, &model.UserReadHistoryDelIn{BookIds: req.BookIds, UserId: userId})
if err != nil {
return nil, err
}
return &v1.HistoryRemoveRes{
Success: out.Success,
}, nil
}

View File

@ -11,10 +11,9 @@ import (
func (c *ControllerV1) AppProgress(ctx context.Context, req *v1.AppProgressReq) (res *v1.AppProgressRes, err error) { func (c *ControllerV1) AppProgress(ctx context.Context, req *v1.AppProgressReq) (res *v1.AppProgressRes, err error) {
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64() userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
out, err := service.Chapter().AppProgress(ctx, &model.ChapterAppProgressIn{ out, err := service.Chapter().AppBatchProgress(ctx, &model.ChapterAppBatchProgressIn{
BookId: req.BookId, BookId: req.BookId,
ChapterId: req.ChapterId, Chapters: req.Chapters,
Progress: req.Progress,
UserId: userId, UserId: userId,
}) })
if err != nil { if err != nil {

View File

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

View File

@ -0,0 +1,15 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package recommend
import (
"server/api/recommend"
)
type ControllerV1 struct{}
func NewV1() recommend.IRecommendV1 {
return &ControllerV1{}
}

View File

@ -0,0 +1,23 @@
package recommend
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/recommend/v1"
)
func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) {
out, err := service.BookRecommendations().Create(ctx, &model.BookRecommendationsCreateIn{
BookId: req.BookId,
Type: req.Type,
CoverUrl: req.CoverUrl,
SortOrder: req.SortOrder,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.AddRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,35 @@
package recommend
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/recommend/v1"
)
func (c *ControllerV1) AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error) {
out, err := service.BookRecommendations().AppList(ctx, &model.BookRecommendationsListIn{
Page: req.Page,
Size: req.Size,
Type: req.Type,
Status: req.Status,
})
if err != nil {
return nil, err
}
// 转换为 RecommendAppItem
list := make([]model.RecommendAppItem, 0, len(out.List))
for _, item := range out.List {
list = append(list, model.RecommendAppItem{
Id: item.Id,
BookId: item.BookId,
CoverUrl: item.CoverUrl,
SortOrder: item.SortOrder,
})
}
return &v1.AppListRes{
Total: out.Total,
List: list,
}, nil
}

View File

@ -0,0 +1,19 @@
package recommend
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/recommend/v1"
)
func (c *ControllerV1) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) {
out, err := service.BookRecommendations().Delete(ctx, &model.BookRecommendationsDeleteIn{
Id: req.Id,
})
if err != nil {
return nil, err
}
return &v1.DelRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,24 @@
package recommend
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/recommend/v1"
)
func (c *ControllerV1) Edit(ctx context.Context, req *v1.EditReq) (res *v1.EditRes, err error) {
out, err := service.BookRecommendations().Update(ctx, &model.BookRecommendationsUpdateIn{
Id: req.Id,
BookId: req.BookId,
Type: req.Type,
CoverUrl: req.CoverUrl,
SortOrder: req.SortOrder,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.EditRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,26 @@
package recommend
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/recommend/v1"
)
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
out, err := service.BookRecommendations().List(ctx, &model.BookRecommendationsListIn{
Page: req.Page,
Size: req.Size,
Type: req.Type,
Status: req.Status,
BookId: req.BookId,
})
if err != nil {
return nil, err
}
return &v1.ListRes{
Total: out.Total,
List: out.List,
}, nil
}

View File

@ -0,0 +1,20 @@
package recommend
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/recommend/v1"
)
func (c *ControllerV1) SetStatus(ctx context.Context, req *v1.SetStatusReq) (res *v1.SetStatusRes, err error) {
out, err := service.BookRecommendations().SetStatus(ctx, &model.BookRecommendationsSetStatusIn{
Id: req.Id,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.SetStatusRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,20 @@
package recommend
import (
"context"
"server/internal/model"
"server/internal/service"
v1 "server/api/recommend/v1"
)
func (c *ControllerV1) SortOrder(ctx context.Context, req *v1.SortOrderReq) (res *v1.SortOrderRes, err error) {
out, err := service.BookRecommendations().SortOrder(ctx, &model.BookRecommendationsSortOrderIn{
Id: req.Id,
SortOrder: req.SortOrder,
})
if err != nil {
return nil, err
}
return &v1.SortOrderRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,16 @@
package recommend
import (
"context"
"server/internal/service"
v1 "server/api/recommend/v1"
)
func (c *ControllerV1) UploadCover(ctx context.Context, req *v1.UploadCoverReq) (res *v1.UploadCoverRes, err error) {
url, err := service.BookRecommendations().UploadCover(ctx, req.File)
if err != nil {
return nil, err
}
return &v1.UploadCoverRes{Url: url}, nil
}

View File

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

View File

@ -0,0 +1,15 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package system
import (
"server/api/system"
)
type ControllerV1 struct{}
func NewV1() system.ISystemV1 {
return &ControllerV1{}
}

View File

@ -0,0 +1,16 @@
package system
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/system/v1"
)
func (c *ControllerV1) SystemSave(ctx context.Context, req *v1.SystemSaveReq) (res *v1.SystemSaveRes, err error) {
return nil, service.System().Save(ctx, &model.SystemSaveInput{
Key: req.Key,
Value: req.Value,
})
}

View File

@ -0,0 +1,16 @@
package system
import (
"context"
"server/internal/service"
"server/api/system/v1"
)
func (c *ControllerV1) SystemVersion(ctx context.Context, req *v1.SystemVersionReq) (res *v1.SystemVersionRes, err error) {
version, err := service.System().Version(ctx)
if err != nil {
return nil, err
}
return &v1.SystemVersionRes{Ios: version.Ios, Android: version.Android}, nil
}

View File

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

View File

@ -0,0 +1,15 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package task
import (
"server/api/task"
)
type ControllerV1 struct{}
func NewV1() task.ITaskV1 {
return &ControllerV1{}
}

View File

@ -0,0 +1,23 @@
package task
import (
"context"
v1 "server/api/task/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) {
out, err := service.Task().Add(ctx, &model.TaskAddIn{
TaskType: req.TaskType,
Title: req.Title,
Description: req.Description,
RewardPoints: req.RewardPoints,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.AddRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,19 @@
package task
import (
"context"
v1 "server/api/task/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error) {
out, err := service.Task().AppList(ctx, &model.TaskAppListIn{})
if err != nil {
return nil, err
}
return &v1.AppListRes{
List: out.List,
}, nil
}

View File

@ -0,0 +1,17 @@
package task
import (
"context"
v1 "server/api/task/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) {
out, err := service.Task().Delete(ctx, &model.TaskDelIn{Id: req.Id})
if err != nil {
return nil, err
}
return &v1.DelRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,24 @@
package task
import (
"context"
v1 "server/api/task/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) Edit(ctx context.Context, req *v1.EditReq) (res *v1.EditRes, err error) {
out, err := service.Task().Edit(ctx, &model.TaskEditIn{
Id: req.Id,
TaskType: req.TaskType,
Title: req.Title,
Description: req.Description,
RewardPoints: req.RewardPoints,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.EditRes{Success: out.Success}, nil
}

View File

@ -0,0 +1,25 @@
package task
import (
"context"
v1 "server/api/task/v1"
"server/internal/model"
"server/internal/service"
)
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
out, err := service.Task().List(ctx, &model.TaskListIn{
Page: req.Page,
Size: req.Size,
Title: req.Title,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &v1.ListRes{
Total: out.Total,
List: out.List,
}, nil
}

View File

@ -23,10 +23,14 @@ func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoR
} }
return &v1.InfoRes{ return &v1.InfoRes{
UserId: out.UserId, Id: out.Id,
Username: out.Username, Username: out.Username,
Avatar: out.Avatar, Avatar: out.Avatar,
Email: out.Email, Email: out.Email,
Points: out.Points, Points: out.Points,
BackgroundUrl: out.BackgroundUrl,
AttentionCount: out.AttentionCount,
IsAuthor: out.IsAuthor,
AuthorStatus: out.AuthorStatus,
}, nil }, nil
} }

View File

@ -2,13 +2,15 @@ package user
import ( import (
"context" "context"
"fmt"
"github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/errors/gerror"
"server/api/user/v1" "server/api/user/v1"
) )
func (c *ControllerV1) Logout(ctx context.Context, req *v1.LogoutReq) (res *v1.LogoutRes, err error) { func (c *ControllerV1) Logout(ctx context.Context, req *v1.LogoutReq) (res *v1.LogoutRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented) g.Redis().Do(ctx, "SETEX", fmt.Sprintf("blacklist:%s", g.RequestFromCtx(ctx).GetCtxVar("jti").String()), "1")
return &v1.LogoutRes{
Success: true,
}, nil
} }

View File

@ -0,0 +1,27 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// internalAdEventLogsDao is an internal type for wrapping the internal DAO implementation.
type internalAdEventLogsDao = *internal.AdEventLogsDao
// adEventLogsDao is the data access object for the table ad_event_logs.
// You can define custom methods on it to extend its functionality as needed.
type adEventLogsDao struct {
internalAdEventLogsDao
}
var (
// AdEventLogs is a globally accessible object for table ad_event_logs operations.
AdEventLogs = adEventLogsDao{
internal.NewAdEventLogsDao(),
}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,27 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// internalAdEventTransitionsDao is an internal type for wrapping the internal DAO implementation.
type internalAdEventTransitionsDao = *internal.AdEventTransitionsDao
// adEventTransitionsDao is the data access object for the table ad_event_transitions.
// You can define custom methods on it to extend its functionality as needed.
type adEventTransitionsDao struct {
internalAdEventTransitionsDao
}
var (
// AdEventTransitions is a globally accessible object for table ad_event_transitions operations.
AdEventTransitions = adEventTransitionsDao{
internal.NewAdEventTransitionsDao(),
}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,27 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// internalBookRecommendationsDao is an internal type for wrapping the internal DAO implementation.
type internalBookRecommendationsDao = *internal.BookRecommendationsDao
// bookRecommendationsDao is the data access object for the table book_recommendations.
// You can define custom methods on it to extend its functionality as needed.
type bookRecommendationsDao struct {
internalBookRecommendationsDao
}
var (
// BookRecommendations is a globally accessible object for table book_recommendations operations.
BookRecommendations = bookRecommendationsDao{
internal.NewBookRecommendationsDao(),
}
)
// Add your custom methods and functionality below.

View File

@ -0,0 +1,97 @@
// ==========================================================================
// 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"
)
// AdEventLogsDao is the data access object for the table ad_event_logs.
type AdEventLogsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns AdEventLogsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// AdEventLogsColumns defines and stores column names for the table ad_event_logs.
type AdEventLogsColumns struct {
Id string // 广告事件ID
UserId string // 用户ID
AdsPlatId string // 平台ID1-META2-ADMOB
AdsCategoryId string // 广告类型1-横幅2-插页3-激励插页4-激励5-原生6-开屏
AppPackage string // App包名
Status string // 广告状态1-拉取失败2-拉取成功3-显示失败4-显示成功5-未观看完成6-观看完成7-未点击8-已点击9-未下载10-已下载
StatusDesc string // 状态描述
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
}
// adEventLogsColumns holds the columns for the table ad_event_logs.
var adEventLogsColumns = AdEventLogsColumns{
Id: "id",
UserId: "user_id",
AdsPlatId: "ads_plat_id",
AdsCategoryId: "ads_category_id",
AppPackage: "app_package",
Status: "status",
StatusDesc: "status_desc",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewAdEventLogsDao creates and returns a new DAO object for table data access.
func NewAdEventLogsDao(handlers ...gdb.ModelHandler) *AdEventLogsDao {
return &AdEventLogsDao{
group: "default",
table: "ad_event_logs",
columns: adEventLogsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *AdEventLogsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *AdEventLogsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *AdEventLogsDao) Columns() AdEventLogsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *AdEventLogsDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *AdEventLogsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *AdEventLogsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,89 @@
// ==========================================================================
// 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"
)
// AdEventTransitionsDao is the data access object for the table ad_event_transitions.
type AdEventTransitionsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns AdEventTransitionsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// AdEventTransitionsColumns defines and stores column names for the table ad_event_transitions.
type AdEventTransitionsColumns struct {
Id string // 状态流转记录ID
EventId string // 所属广告事件ID关联ad_event_logs.id
FromStatus string // 原状态(首次记录为空)
ToStatus string // 目标状态
CreatedAt string // 状态变更时间
DeletedAt string // 软删除时间戳
}
// adEventTransitionsColumns holds the columns for the table ad_event_transitions.
var adEventTransitionsColumns = AdEventTransitionsColumns{
Id: "id",
EventId: "event_id",
FromStatus: "from_status",
ToStatus: "to_status",
CreatedAt: "created_at",
DeletedAt: "deleted_at",
}
// NewAdEventTransitionsDao creates and returns a new DAO object for table data access.
func NewAdEventTransitionsDao(handlers ...gdb.ModelHandler) *AdEventTransitionsDao {
return &AdEventTransitionsDao{
group: "default",
table: "ad_event_transitions",
columns: adEventTransitionsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *AdEventTransitionsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *AdEventTransitionsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *AdEventTransitionsDao) Columns() AdEventTransitionsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *AdEventTransitionsDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *AdEventTransitionsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *AdEventTransitionsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -16,6 +16,7 @@ type AdminsDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns AdminsColumns // columns contains all the column names of Table for convenient usage. columns AdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AdminsColumns defines and stores column names for the table admins. // AdminsColumns defines and stores column names for the table admins.
@ -39,11 +40,12 @@ var adminsColumns = AdminsColumns{
} }
// NewAdminsDao creates and returns a new DAO object for table data access. // NewAdminsDao creates and returns a new DAO object for table data access.
func NewAdminsDao() *AdminsDao { func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao {
return &AdminsDao{ return &AdminsDao{
group: "default", group: "default",
table: "admins", table: "admins",
columns: adminsColumns, columns: adminsColumns,
handlers: handlers,
} }
} }
@ -69,7 +71,11 @@ func (dao *AdminsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type AuthorsDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns AuthorsColumns // columns contains all the column names of Table for convenient usage. columns AuthorsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AuthorsColumns defines and stores column names for the table authors. // AuthorsColumns defines and stores column names for the table authors.
@ -24,7 +25,8 @@ type AuthorsColumns struct {
UserId string // 用户ID UserId string // 用户ID
PenName string // 笔名 PenName string // 笔名
Bio string // 作者简介 Bio string // 作者简介
Status string // 状态1=正常2=禁用 FollowerCount string // 粉丝数量
Status string // 状态1=正常2=待审核, 3=未通过
CreatedAt string // 创建时间 CreatedAt string // 创建时间
UpdatedAt string // 更新时间 UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳 DeletedAt string // 软删除时间戳
@ -36,6 +38,7 @@ var authorsColumns = AuthorsColumns{
UserId: "user_id", UserId: "user_id",
PenName: "pen_name", PenName: "pen_name",
Bio: "bio", Bio: "bio",
FollowerCount: "follower_count",
Status: "status", Status: "status",
CreatedAt: "created_at", CreatedAt: "created_at",
UpdatedAt: "updated_at", UpdatedAt: "updated_at",
@ -43,11 +46,12 @@ var authorsColumns = AuthorsColumns{
} }
// NewAuthorsDao creates and returns a new DAO object for table data access. // NewAuthorsDao creates and returns a new DAO object for table data access.
func NewAuthorsDao() *AuthorsDao { func NewAuthorsDao(handlers ...gdb.ModelHandler) *AuthorsDao {
return &AuthorsDao{ return &AuthorsDao{
group: "default", group: "default",
table: "authors", table: "authors",
columns: authorsColumns, columns: authorsColumns,
handlers: handlers,
} }
} }
@ -73,7 +77,11 @@ func (dao *AuthorsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *AuthorsDao) Ctx(ctx context.Context) *gdb.Model { func (dao *AuthorsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type BookRatingsDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns BookRatingsColumns // columns contains all the column names of Table for convenient usage. columns BookRatingsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// BookRatingsColumns defines and stores column names for the table book_ratings. // BookRatingsColumns defines and stores column names for the table book_ratings.
@ -39,11 +40,12 @@ var bookRatingsColumns = BookRatingsColumns{
} }
// NewBookRatingsDao creates and returns a new DAO object for table data access. // NewBookRatingsDao creates and returns a new DAO object for table data access.
func NewBookRatingsDao() *BookRatingsDao { func NewBookRatingsDao(handlers ...gdb.ModelHandler) *BookRatingsDao {
return &BookRatingsDao{ return &BookRatingsDao{
group: "default", group: "default",
table: "book_ratings", table: "book_ratings",
columns: bookRatingsColumns, columns: bookRatingsColumns,
handlers: handlers,
} }
} }
@ -69,7 +71,11 @@ func (dao *BookRatingsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *BookRatingsDao) Ctx(ctx context.Context) *gdb.Model { func (dao *BookRatingsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -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"
)
// BookRecommendationsDao is the data access object for the table book_recommendations.
type BookRecommendationsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns BookRecommendationsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// BookRecommendationsColumns defines and stores column names for the table book_recommendations.
type BookRecommendationsColumns struct {
Id string // 主键
BookId string // 书籍ID关联 books 表
Type string // 推荐类型1=首页Banner2=编辑推荐3=分类推荐等
CoverUrl string // 推荐封面图(横图)
SortOrder string // 展示排序,越小越靠前
Status string // 是否启用1=启用0=禁用
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
}
// bookRecommendationsColumns holds the columns for the table book_recommendations.
var bookRecommendationsColumns = BookRecommendationsColumns{
Id: "id",
BookId: "book_id",
Type: "type",
CoverUrl: "cover_url",
SortOrder: "sort_order",
Status: "status",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewBookRecommendationsDao creates and returns a new DAO object for table data access.
func NewBookRecommendationsDao(handlers ...gdb.ModelHandler) *BookRecommendationsDao {
return &BookRecommendationsDao{
group: "default",
table: "book_recommendations",
columns: bookRecommendationsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *BookRecommendationsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *BookRecommendationsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *BookRecommendationsDao) Columns() BookRecommendationsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *BookRecommendationsDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *BookRecommendationsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *BookRecommendationsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -16,6 +16,7 @@ type BooksDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns BooksColumns // columns contains all the column names of Table for convenient usage. columns BooksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// BooksColumns defines and stores column names for the table books. // BooksColumns defines and stores column names for the table books.
@ -38,6 +39,7 @@ type BooksColumns struct {
DeletedAt string // 软删除时间戳 DeletedAt string // 软删除时间戳
IsRecommended string // 是否推荐0=否1=是 IsRecommended string // 是否推荐0=否1=是
IsFeatured string // 是否精选0=否1=是 IsFeatured string // 是否精选0=否1=是
IsHot string // 是否热门0=否1=是
Language string // 语言,如 zh=中文en=英文jp=日文 Language string // 语言,如 zh=中文en=英文jp=日文
} }
@ -61,15 +63,17 @@ var booksColumns = BooksColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
IsRecommended: "is_recommended", IsRecommended: "is_recommended",
IsFeatured: "is_featured", IsFeatured: "is_featured",
IsHot: "is_hot",
Language: "language", Language: "language",
} }
// NewBooksDao creates and returns a new DAO object for table data access. // NewBooksDao creates and returns a new DAO object for table data access.
func NewBooksDao() *BooksDao { func NewBooksDao(handlers ...gdb.ModelHandler) *BooksDao {
return &BooksDao{ return &BooksDao{
group: "default", group: "default",
table: "books", table: "books",
columns: booksColumns, columns: booksColumns,
handlers: handlers,
} }
} }
@ -95,7 +99,11 @@ func (dao *BooksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *BooksDao) Ctx(ctx context.Context) *gdb.Model { func (dao *BooksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type BookshelvesDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns BookshelvesColumns // columns contains all the column names of Table for convenient usage. columns BookshelvesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// BookshelvesColumns defines and stores column names for the table bookshelves. // BookshelvesColumns defines and stores column names for the table bookshelves.
@ -43,11 +44,12 @@ var bookshelvesColumns = BookshelvesColumns{
} }
// NewBookshelvesDao creates and returns a new DAO object for table data access. // NewBookshelvesDao creates and returns a new DAO object for table data access.
func NewBookshelvesDao() *BookshelvesDao { func NewBookshelvesDao(handlers ...gdb.ModelHandler) *BookshelvesDao {
return &BookshelvesDao{ return &BookshelvesDao{
group: "default", group: "default",
table: "bookshelves", table: "bookshelves",
columns: bookshelvesColumns, columns: bookshelvesColumns,
handlers: handlers,
} }
} }
@ -73,7 +75,11 @@ func (dao *BookshelvesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *BookshelvesDao) Ctx(ctx context.Context) *gdb.Model { func (dao *BookshelvesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type CategoriesDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns CategoriesColumns // columns contains all the column names of Table for convenient usage. columns CategoriesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// CategoriesColumns defines and stores column names for the table categories. // CategoriesColumns defines and stores column names for the table categories.
@ -39,11 +40,12 @@ var categoriesColumns = CategoriesColumns{
} }
// NewCategoriesDao creates and returns a new DAO object for table data access. // NewCategoriesDao creates and returns a new DAO object for table data access.
func NewCategoriesDao() *CategoriesDao { func NewCategoriesDao(handlers ...gdb.ModelHandler) *CategoriesDao {
return &CategoriesDao{ return &CategoriesDao{
group: "default", group: "default",
table: "categories", table: "categories",
columns: categoriesColumns, columns: categoriesColumns,
handlers: handlers,
} }
} }
@ -69,7 +71,11 @@ func (dao *CategoriesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *CategoriesDao) Ctx(ctx context.Context) *gdb.Model { func (dao *CategoriesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type ChaptersDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns ChaptersColumns // columns contains all the column names of Table for convenient usage. columns ChaptersColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// ChaptersColumns defines and stores column names for the table chapters. // ChaptersColumns defines and stores column names for the table chapters.
@ -49,11 +50,12 @@ var chaptersColumns = ChaptersColumns{
} }
// NewChaptersDao creates and returns a new DAO object for table data access. // NewChaptersDao creates and returns a new DAO object for table data access.
func NewChaptersDao() *ChaptersDao { func NewChaptersDao(handlers ...gdb.ModelHandler) *ChaptersDao {
return &ChaptersDao{ return &ChaptersDao{
group: "default", group: "default",
table: "chapters", table: "chapters",
columns: chaptersColumns, columns: chaptersColumns,
handlers: handlers,
} }
} }
@ -79,7 +81,11 @@ func (dao *ChaptersDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *ChaptersDao) Ctx(ctx context.Context) *gdb.Model { func (dao *ChaptersDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type FeedbacksDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage. columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// FeedbacksColumns defines and stores column names for the table feedbacks. // FeedbacksColumns defines and stores column names for the table feedbacks.
@ -39,11 +40,12 @@ var feedbacksColumns = FeedbacksColumns{
} }
// NewFeedbacksDao creates and returns a new DAO object for table data access. // NewFeedbacksDao creates and returns a new DAO object for table data access.
func NewFeedbacksDao() *FeedbacksDao { func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao {
return &FeedbacksDao{ return &FeedbacksDao{
group: "default", group: "default",
table: "feedbacks", table: "feedbacks",
columns: feedbacksColumns, columns: feedbacksColumns,
handlers: handlers,
} }
} }
@ -69,7 +71,11 @@ func (dao *FeedbacksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model { func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -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"
)
// SignInRewardDetailsDao is the data access object for the table sign_in_reward_details.
type SignInRewardDetailsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns SignInRewardDetailsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// SignInRewardDetailsColumns defines and stores column names for the table sign_in_reward_details.
type SignInRewardDetailsColumns struct {
Id string // 主键
RuleId string // 规则ID关联 sign_in_reward_rules 表
DayNumber string // 签到天数1到cycle_days
RewardType string // 奖励类型1=积分
Quantity string // 奖励数量,如积分数量或礼包数量
Status string // 记录状态1=启用0=禁用
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
}
// signInRewardDetailsColumns holds the columns for the table sign_in_reward_details.
var signInRewardDetailsColumns = SignInRewardDetailsColumns{
Id: "id",
RuleId: "rule_id",
DayNumber: "day_number",
RewardType: "reward_type",
Quantity: "quantity",
Status: "status",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewSignInRewardDetailsDao creates and returns a new DAO object for table data access.
func NewSignInRewardDetailsDao(handlers ...gdb.ModelHandler) *SignInRewardDetailsDao {
return &SignInRewardDetailsDao{
group: "default",
table: "sign_in_reward_details",
columns: signInRewardDetailsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *SignInRewardDetailsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *SignInRewardDetailsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *SignInRewardDetailsDao) Columns() SignInRewardDetailsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *SignInRewardDetailsDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *SignInRewardDetailsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *SignInRewardDetailsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -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"
)
// SignInRewardRulesDao is the data access object for the table sign_in_reward_rules.
type SignInRewardRulesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns SignInRewardRulesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// SignInRewardRulesColumns defines and stores column names for the table sign_in_reward_rules.
type SignInRewardRulesColumns struct {
Id string // 主键
RuleName string // 规则名称如“7天签到活动”
CycleDays string // 奖励周期天数如7天
StartDate string // 活动开始日期
EndDate string // 活动结束日期
Status string // 规则状态1=启用0=禁用
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
}
// signInRewardRulesColumns holds the columns for the table sign_in_reward_rules.
var signInRewardRulesColumns = SignInRewardRulesColumns{
Id: "id",
RuleName: "rule_name",
CycleDays: "cycle_days",
StartDate: "start_date",
EndDate: "end_date",
Status: "status",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewSignInRewardRulesDao creates and returns a new DAO object for table data access.
func NewSignInRewardRulesDao(handlers ...gdb.ModelHandler) *SignInRewardRulesDao {
return &SignInRewardRulesDao{
group: "default",
table: "sign_in_reward_rules",
columns: signInRewardRulesColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *SignInRewardRulesDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *SignInRewardRulesDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *SignInRewardRulesDao) Columns() SignInRewardRulesColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *SignInRewardRulesDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *SignInRewardRulesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *SignInRewardRulesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -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"
)
// SystemDao is the data access object for the table system.
type SystemDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns SystemColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// SystemColumns defines and stores column names for the table system.
type SystemColumns struct {
Key string //
Value string //
}
// systemColumns holds the columns for the table system.
var systemColumns = SystemColumns{
Key: "key",
Value: "value",
}
// NewSystemDao creates and returns a new DAO object for table data access.
func NewSystemDao(handlers ...gdb.ModelHandler) *SystemDao {
return &SystemDao{
group: "default",
table: "system",
columns: systemColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *SystemDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *SystemDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *SystemDao) Columns() SystemColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *SystemDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *SystemDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *SystemDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,93 @@
// ==========================================================================
// 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"
)
// TaskLogsDao is the data access object for the table task_logs.
type TaskLogsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TaskLogsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// TaskLogsColumns defines and stores column names for the table task_logs.
type TaskLogsColumns struct {
Id string // 任务日志ID
TaskId string // 任务ID关联 tasks.id
UserId string // 用户ID关联 users.id
RewardPoints string // 本次任务获得的积分
ActionTime string // 操作时间(如完成时间)
Status string // 日志状态1=有效2=无效
Extra string // 扩展信息例如来源、IP 等
CreatedAt string // 创建时间
}
// taskLogsColumns holds the columns for the table task_logs.
var taskLogsColumns = TaskLogsColumns{
Id: "id",
TaskId: "task_id",
UserId: "user_id",
RewardPoints: "reward_points",
ActionTime: "action_time",
Status: "status",
Extra: "extra",
CreatedAt: "created_at",
}
// NewTaskLogsDao creates and returns a new DAO object for table data access.
func NewTaskLogsDao(handlers ...gdb.ModelHandler) *TaskLogsDao {
return &TaskLogsDao{
group: "default",
table: "task_logs",
columns: taskLogsColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *TaskLogsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *TaskLogsDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *TaskLogsDao) Columns() TaskLogsColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *TaskLogsDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *TaskLogsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *TaskLogsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -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"
)
// TaskTypesDao is the data access object for the table task_types.
type TaskTypesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TaskTypesColumns // columns contains all the column names of Table for convenient usage.
}
// TaskTypesColumns defines and stores column names for the table task_types.
type TaskTypesColumns struct {
Id string // 任务类型ID
Name string // 任务类型名称,例如:广告、写一本书、首次登录
Description string // 任务类型描述
Status string // 状态1=启用2=禁用
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
}
// taskTypesColumns holds the columns for the table task_types.
var taskTypesColumns = TaskTypesColumns{
Id: "id",
Name: "name",
Description: "description",
Status: "status",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
}
// NewTaskTypesDao creates and returns a new DAO object for table data access.
func NewTaskTypesDao() *TaskTypesDao {
return &TaskTypesDao{
group: "default",
table: "task_types",
columns: taskTypesColumns,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *TaskTypesDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *TaskTypesDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *TaskTypesDao) Columns() TaskTypesColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *TaskTypesDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *TaskTypesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *TaskTypesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -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"
)
// TasksDao is the data access object for the table tasks.
type TasksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// TasksColumns defines and stores column names for the table tasks.
type TasksColumns struct {
Id string // 任务ID
TaskType string // 任务类型1=首次登录2=广告3=发布书籍
Title string // 任务标题
Description string // 任务描述
RewardPoints string // 完成任务奖励的积分数
Status string // 状态1=启用2=禁用
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
}
// tasksColumns holds the columns for the table tasks.
var tasksColumns = TasksColumns{
Id: "id",
TaskType: "task_type",
Title: "title",
Description: "description",
RewardPoints: "reward_points",
Status: "status",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewTasksDao creates and returns a new DAO object for table data access.
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
return &TasksDao{
group: "default",
table: "tasks",
columns: tasksColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *TasksDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *TasksDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *TasksDao) Columns() TasksColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *TasksDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *TasksDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

Some files were not shown because too many files have changed in this diff Show More