初始化项目框架,完成部分接口开发
This commit is contained in:
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
.buildpath
|
||||
.hgignore.swp
|
||||
.project
|
||||
.orig
|
||||
.swp
|
||||
.idea/
|
||||
.settings/
|
||||
.vscode/
|
||||
bin/
|
||||
**/.DS_Store
|
||||
gf
|
||||
main
|
||||
main.exe
|
||||
output/
|
||||
manifest/output/
|
||||
temp/
|
||||
temp.yaml
|
||||
bin
|
||||
**/config/config.yaml
|
||||
4
README.MD
Normal file
4
README.MD
Normal file
@ -0,0 +1,4 @@
|
||||
# GoFrame Template For SingleRepo
|
||||
|
||||
Quick Start:
|
||||
- https://goframe.org/quick
|
||||
16
api/admin/admin.go
Normal file
16
api/admin/admin.go
Normal file
@ -0,0 +1,16 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/api/admin/v1"
|
||||
)
|
||||
|
||||
type IAdminV1 interface {
|
||||
AdminInfo(ctx context.Context, req *v1.AdminInfoReq) (res *v1.AdminInfoRes, err error)
|
||||
AdminEditPass(ctx context.Context, req *v1.AdminEditPassReq) (res *v1.AdminEditPassRes, err error)
|
||||
}
|
||||
24
api/admin/v1/admin.go
Normal file
24
api/admin/v1/admin.go
Normal file
@ -0,0 +1,24 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type AdminInfoReq struct {
|
||||
g.Meta `path:"/admin/info" tags:"Admin" method:"get" summary:"管理员信息"`
|
||||
}
|
||||
type AdminInfoRes struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
AdminId int64 `json:"adminId"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type AdminEditPassReq struct {
|
||||
g.Meta `path:"/admin/editPass" tags:"Admin" method:"post" summary:"修改密码"`
|
||||
OldPass string `json:"oldPass" v:"required" dc:"旧密码"`
|
||||
NewPass string `json:"newPass" v:"required" dc:"新密码"`
|
||||
}
|
||||
type AdminEditPassRes struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
Success bool
|
||||
}
|
||||
19
api/auth/auth.go
Normal file
19
api/auth/auth.go
Normal file
@ -0,0 +1,19 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
type IAuthV1 interface {
|
||||
AdminLogin(ctx context.Context, req *v1.AdminLoginReq) (res *v1.AdminLoginRes, err error)
|
||||
UserLogin(ctx context.Context, req *v1.UserLoginReq) (res *v1.UserLoginRes, 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)
|
||||
UserCode(ctx context.Context, req *v1.UserCodeReq) (res *v1.UserCodeRes, err error)
|
||||
}
|
||||
47
api/auth/v1/auth.go
Normal file
47
api/auth/v1/auth.go
Normal file
@ -0,0 +1,47 @@
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
type AdminLoginReq struct {
|
||||
g.Meta `path:"/admin/login" tags:"Admin" method:"post" summary:"管理员登录"`
|
||||
Username string `json:"username" v:"required" dc:"用户名"`
|
||||
Password string `json:"password" v:"required" dc:"密码"`
|
||||
}
|
||||
type AdminLoginRes struct {
|
||||
Token string `json:"token" dc:"token"`
|
||||
}
|
||||
type UserLoginReq struct {
|
||||
g.Meta `path:"/user/login" tags:"APP/User" method:"post" summary:"用户登录"`
|
||||
Email string `json:"email" v:"required" dc:"邮箱"`
|
||||
Password string `json:"password" v:"required" dc:"密码"`
|
||||
}
|
||||
type UserLoginRes struct {
|
||||
Token string `json:"token" dc:"token"`
|
||||
}
|
||||
type UserRegisterReq struct {
|
||||
g.Meta `path:"/user/register" tags:"APP/User" method:"post" summary:"用户注册"`
|
||||
Email string `json:"email" v:"required" dc:"邮箱"`
|
||||
Password string `json:"password" v:"required" dc:"密码"`
|
||||
Password2 string `json:"password2" v:"required|same:password" dc:"确认密码"`
|
||||
}
|
||||
type UserRegisterRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
type UserEditPassReq struct {
|
||||
g.Meta `path:"/user/editPass" tags:"APP/User" method:"post" summary:"修改密码"`
|
||||
Email string `json:"email" v:"required" dc:"邮箱"`
|
||||
Password string `json:"password" v:"required" dc:"密码"`
|
||||
Password2 string `json:"password2" v:"required|same:password" dc:"确认密码"`
|
||||
Sign string `json:"sign" v:"required" dc:"验证码"`
|
||||
}
|
||||
|
||||
type UserEditPassRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
type UserCodeReq struct {
|
||||
g.Meta `path:"/user/code" tags:"APP/User" method:"post" summary:"获取验证码"`
|
||||
Email string `json:"email" v:"required" dc:"邮箱"`
|
||||
}
|
||||
type UserCodeRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
18
api/book/book.go
Normal file
18
api/book/book.go
Normal file
@ -0,0 +1,18 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/api/book/v1"
|
||||
)
|
||||
|
||||
type IBookV1 interface {
|
||||
BookList(ctx context.Context, req *v1.BookListReq) (res *v1.BookListRes, err error)
|
||||
BookAdd(ctx context.Context, req *v1.BookAddReq) (res *v1.BookAddRes, err error)
|
||||
BookEdit(ctx context.Context, req *v1.BookEditReq) (res *v1.BookEditRes, err error)
|
||||
BookDel(ctx context.Context, req *v1.BookDelReq) (res *v1.BookDelRes, err error)
|
||||
}
|
||||
61
api/book/v1/book.go
Normal file
61
api/book/v1/book.go
Normal file
@ -0,0 +1,61 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"server/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type BookListReq struct {
|
||||
g.Meta `path:"/book" tags:"Book" method:"get" summary:"获取小说列表"`
|
||||
Page int `json:"page"`
|
||||
Size int `json:"size"`
|
||||
Title string `json:"title"`
|
||||
CategoryId int64 `json:"categoryId"`
|
||||
AuthorId int64 `json:"authorId"`
|
||||
Status int `json:"status"`
|
||||
IsRecommended int `json:"isRecommended"`
|
||||
}
|
||||
type BookListRes struct {
|
||||
Total int `json:"total"`
|
||||
List []model.Book `json:"list"`
|
||||
}
|
||||
|
||||
type BookAddReq struct {
|
||||
g.Meta `path:"/book" tags:"Book" method:"post" summary:"新增小说"`
|
||||
AuthorId int64 `json:"authorId"`
|
||||
CategoryId int64 `json:"categoryId"`
|
||||
Title string `json:"title"`
|
||||
CoverUrl string `json:"coverUrl"`
|
||||
Description string `json:"description"`
|
||||
Status int `json:"status"`
|
||||
Tags string `json:"tags"`
|
||||
IsRecommended int `json:"isRecommended"`
|
||||
}
|
||||
type BookAddRes struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
type BookEditReq struct {
|
||||
g.Meta `path:"/book" tags:"Book" method:"put" summary:"编辑小说"`
|
||||
Id int64 `json:"id"`
|
||||
AuthorId int64 `json:"authorId"`
|
||||
CategoryId int64 `json:"categoryId"`
|
||||
Title string `json:"title"`
|
||||
CoverUrl string `json:"coverUrl"`
|
||||
Description string `json:"description"`
|
||||
Status int `json:"status"`
|
||||
Tags string `json:"tags"`
|
||||
IsRecommended int `json:"isRecommended"`
|
||||
}
|
||||
type BookEditRes struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
type BookDelReq struct {
|
||||
g.Meta `path:"/book" tags:"Book" method:"delete" summary:"删除小说"`
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
type BookDelRes struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
18
api/category/category.go
Normal file
18
api/category/category.go
Normal file
@ -0,0 +1,18 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
type ICategoryV1 interface {
|
||||
CategoryList(ctx context.Context, req *v1.CategoryListReq) (res *v1.CategoryListRes, err error)
|
||||
CategoryAdd(ctx context.Context, req *v1.CategoryAddReq) (res *v1.CategoryAddRes, err error)
|
||||
CategoryEdit(ctx context.Context, req *v1.CategoryEditReq) (res *v1.CategoryEditRes, err error)
|
||||
CategoryDel(ctx context.Context, req *v1.CategoryDelReq) (res *v1.CategoryDelRes, err error)
|
||||
}
|
||||
46
api/category/v1/category.go
Normal file
46
api/category/v1/category.go
Normal file
@ -0,0 +1,46 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"server/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type CategoryListReq struct {
|
||||
g.Meta `path:"/category" tags:"Category" method:"get" summary:"获取分类列表"`
|
||||
Page int `json:"page" dc:"页码"`
|
||||
Size int `json:"size" dc:"每页数量"`
|
||||
Name string `json:"name" dc:"分类名称(模糊搜索)"`
|
||||
Type int `json:"type" dc:"类型,1男频,2女频"`
|
||||
}
|
||||
type CategoryListRes struct {
|
||||
Total int `json:"total" dc:"总数"`
|
||||
List []model.Category `json:"list" dc:"分类列表"`
|
||||
}
|
||||
|
||||
type CategoryAddReq struct {
|
||||
g.Meta `path:"/category" tags:"Category" method:"post" summary:"新增分类"`
|
||||
Name string `json:"name" dc:"分类名称"`
|
||||
Type int `json:"type" dc:"类型,1男频,2女频"`
|
||||
}
|
||||
type CategoryAddRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
|
||||
type CategoryEditReq struct {
|
||||
g.Meta `path:"/category" tags:"Category" method:"put" summary:"编辑分类"`
|
||||
Id int `json:"id" dc:"分类ID"`
|
||||
Name string `json:"name" dc:"分类名称"`
|
||||
Type int `json:"type" dc:"类型,1男频,2女频"`
|
||||
}
|
||||
type CategoryEditRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
|
||||
type CategoryDelReq struct {
|
||||
g.Meta `path:"/category" tags:"Category" method:"delete" summary:"删除分类"`
|
||||
Id int `json:"id" dc:"分类ID"`
|
||||
}
|
||||
type CategoryDelRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
18
api/chapter/chapter.go
Normal file
18
api/chapter/chapter.go
Normal file
@ -0,0 +1,18 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
type IChapterV1 interface {
|
||||
ChapterList(ctx context.Context, req *v1.ChapterListReq) (res *v1.ChapterListRes, err error)
|
||||
ChapterAdd(ctx context.Context, req *v1.ChapterAddReq) (res *v1.ChapterAddRes, err error)
|
||||
ChapterEdit(ctx context.Context, req *v1.ChapterEditReq) (res *v1.ChapterEditRes, err error)
|
||||
ChapterDel(ctx context.Context, req *v1.ChapterDelReq) (res *v1.ChapterDelRes, err error)
|
||||
}
|
||||
57
api/chapter/v1/chapter.go
Normal file
57
api/chapter/v1/chapter.go
Normal file
@ -0,0 +1,57 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"server/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type ChapterListReq struct {
|
||||
g.Meta `path:"/chapter" tags:"Chapter" method:"get" summary:"获取章节列表"`
|
||||
Page int `json:"page" dc:"页码"`
|
||||
Size int `json:"size" dc:"每页数量"`
|
||||
BookId int64 `json:"bookId" dc:"小说ID"`
|
||||
Title string `json:"title" dc:"章节标题(模糊搜索)"`
|
||||
IsLocked int `json:"isLocked" dc:"是否锁定:0免费,1需积分解锁"`
|
||||
}
|
||||
type ChapterListRes struct {
|
||||
Total int `json:"total" dc:"总数"`
|
||||
List []model.Chapter `json:"list" dc:"章节列表"`
|
||||
}
|
||||
|
||||
type ChapterAddReq struct {
|
||||
g.Meta `path:"/chapter" tags:"Chapter" method:"post" summary:"新增章节"`
|
||||
BookId int64 `json:"bookId" dc:"小说ID"`
|
||||
Title string `json:"title" dc:"章节标题"`
|
||||
Content string `json:"content" dc:"章节内容"`
|
||||
WordCount int `json:"wordCount" dc:"章节字数"`
|
||||
Sort int `json:"sort" dc:"排序序号"`
|
||||
IsLocked int `json:"isLocked" dc:"是否锁定:0免费,1需积分解锁"`
|
||||
RequiredScore int `json:"requiredScore" dc:"解锁所需积分"`
|
||||
}
|
||||
type ChapterAddRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
|
||||
type ChapterEditReq struct {
|
||||
g.Meta `path:"/chapter" tags:"Chapter" method:"put" summary:"编辑章节"`
|
||||
Id int64 `json:"id" dc:"章节ID"`
|
||||
BookId int64 `json:"bookId" dc:"小说ID"`
|
||||
Title string `json:"title" dc:"章节标题"`
|
||||
Content string `json:"content" dc:"章节内容"`
|
||||
WordCount int `json:"wordCount" dc:"章节字数"`
|
||||
Sort int `json:"sort" dc:"排序序号"`
|
||||
IsLocked int `json:"isLocked" dc:"是否锁定:0免费,1需积分解锁"`
|
||||
RequiredScore int `json:"requiredScore" dc:"解锁所需积分"`
|
||||
}
|
||||
type ChapterEditRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
|
||||
type ChapterDelReq struct {
|
||||
g.Meta `path:"/chapter" tags:"Chapter" method:"delete" summary:"删除章节"`
|
||||
Id int64 `json:"id" dc:"章节ID"`
|
||||
}
|
||||
type ChapterDelRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
16
api/feedback/feedback.go
Normal file
16
api/feedback/feedback.go
Normal file
@ -0,0 +1,16 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package feedback
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/api/feedback/v1"
|
||||
)
|
||||
|
||||
type IFeedbackV1 interface {
|
||||
FeedbackList(ctx context.Context, req *v1.FeedbackListReq) (res *v1.FeedbackListRes, err error)
|
||||
FeedbackAdd(ctx context.Context, req *v1.FeedbackAddReq) (res *v1.FeedbackAddRes, err error)
|
||||
}
|
||||
27
api/feedback/v1/feedback.go
Normal file
27
api/feedback/v1/feedback.go
Normal file
@ -0,0 +1,27 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"server/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type FeedbackListReq struct {
|
||||
g.Meta `path:"/feedback" tags:"Feedback" method:"get" summary:"获取反馈列表"`
|
||||
Page int `json:"page" dc:"页码"`
|
||||
Size int `json:"size" dc:"每页数量"`
|
||||
UserId int64 `json:"userId" dc:"用户ID"`
|
||||
Status int `json:"status" dc:"处理状态:1未处理,2处理中,3已处理"`
|
||||
}
|
||||
type FeedbackListRes struct {
|
||||
Total int `json:"total" dc:"总数"`
|
||||
List []model.Feedback `json:"list" dc:"反馈列表"`
|
||||
}
|
||||
|
||||
type FeedbackAddReq struct {
|
||||
g.Meta `path:"/feedback" tags:"APP/Feedback" method:"post" summary:"新增反馈"`
|
||||
Content string `json:"content" dc:"反馈内容"`
|
||||
}
|
||||
type FeedbackAddRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
17
api/user/user.go
Normal file
17
api/user/user.go
Normal file
@ -0,0 +1,17 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/api/user/v1"
|
||||
)
|
||||
|
||||
type IUserV1 interface {
|
||||
UserInfo(ctx context.Context, req *v1.UserInfoReq) (res *v1.UserInfoRes, err error)
|
||||
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
|
||||
Logout(ctx context.Context, req *v1.LogoutReq) (res *v1.LogoutRes, err error)
|
||||
}
|
||||
33
api/user/v1/user.go
Normal file
33
api/user/v1/user.go
Normal file
@ -0,0 +1,33 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type UserInfoReq struct {
|
||||
g.Meta `path:"/user/info" tags:"APP/User" method:"get" summary:"获取用户信息"`
|
||||
}
|
||||
type UserInfoRes struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
UserId int64 `json:"userId"`
|
||||
Username string `json:"username"` // 用户名
|
||||
Avatar string `json:"avatar"` // 头像 URL
|
||||
Email string `json:"email"` // 邮箱
|
||||
Points uint64 `json:"points"`
|
||||
}
|
||||
|
||||
type DeleteReq struct {
|
||||
g.Meta `path:"/user/delete" tags:"APP/User" method:"post" summary:"删除用户"`
|
||||
Password string `json:"password" v:"required" dc:"密码"`
|
||||
}
|
||||
|
||||
type DeleteRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
|
||||
type LogoutReq struct {
|
||||
g.Meta `path:"/user/logout" tags:"APP/User" method:"post" summary:"登出"`
|
||||
}
|
||||
type LogoutRes struct {
|
||||
Success bool `json:"success" dc:"是否成功"`
|
||||
}
|
||||
53
go.mod
Normal file
53
go.mod
Normal file
@ -0,0 +1,53 @@
|
||||
module server
|
||||
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.24.3
|
||||
|
||||
require (
|
||||
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
|
||||
github.com/casbin/casbin/v2 v2.108.0
|
||||
github.com/gogf/gf v1.16.9
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0
|
||||
github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0
|
||||
github.com/gogf/gf/v2 v2.9.0
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/hailaz/gf-casbin-adapter/v2 v2.8.1
|
||||
golang.org/x/crypto v0.30.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
|
||||
github.com/casbin/govaluate v1.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
||||
github.com/gomodule/redigo v1.8.5 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.9 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/redis/go-redis/v9 v9.7.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
go.opentelemetry.io/otel v1.32.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.32.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.32.0 // indirect
|
||||
golang.org/x/net v0.32.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
golang.org/x/time v0.12.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
147
go.sum
Normal file
147
go.sum
Normal file
@ -0,0 +1,147 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g=
|
||||
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
|
||||
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
|
||||
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/casbin/casbin/v2 v2.108.0 h1:aMc3I81wfLpQe/uzMdElB1OBhEmPZoWMPb2nfEaKygY=
|
||||
github.com/casbin/casbin/v2 v2.108.0/go.mod h1:Ee33aqGrmES+GNL17L0h9X28wXuo829wnNUnS0edAco=
|
||||
github.com/casbin/govaluate v1.3.0 h1:VA0eSY0M2lA86dYd5kPPuNZMUD9QkWnOCnavGrw9myc=
|
||||
github.com/casbin/govaluate v1.3.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 h1:LdXxtjzvZYhhUaonAaAKArG3pyC67kGL3YY+6hGG8G4=
|
||||
github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
||||
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/gogf/gf v1.16.9 h1:Q803UmmRo59+Ws08sMVFOcd8oNpkSWL9vS33hlo/Cyk=
|
||||
github.com/gogf/gf v1.16.9/go.mod h1:8Q/kw05nlVRp+4vv7XASBsMe9L1tsVKiGoeP2AHnlkk=
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0 h1:1f7EeD0lfPHoXfaJDSL7cxRcSRelbsAKgF3MGXY+Uyo=
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0/go.mod h1:tToO1PjGkLIR+9DbJ0wrKicYma0H/EUHXOpwel6Dw+0=
|
||||
github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0 h1:EEZqu1PNRSmm+7Cqm9A/8+ObgfbMzhE1ps9Z3LD7HgM=
|
||||
github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0/go.mod h1:LHrxY+2IzNTHVTPG/s5yaz1VmXbj+CQ7Hr5SeVkHiTw=
|
||||
github.com/gogf/gf/v2 v2.9.0 h1:semN5Q5qGjDQEv4620VzxcJzJlSD07gmyJ9Sy9zfbHk=
|
||||
github.com/gogf/gf/v2 v2.9.0/go.mod h1:sWGQw+pLILtuHmbOxoe0D+0DdaXxbleT57axOLH2vKI=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/gomodule/redigo v1.8.5 h1:nRAxCa+SVsyjSBrtZmG/cqb6VbTmuRzpg/PoTFlpumc=
|
||||
github.com/gomodule/redigo v1.8.5/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4=
|
||||
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc=
|
||||
github.com/hailaz/gf-casbin-adapter/v2 v2.8.1 h1:ZFIlfQAYmrL2Fe6/dZz6vCA5hYK0NxhnoKMQpbklgqc=
|
||||
github.com/hailaz/gf-casbin-adapter/v2 v2.8.1/go.mod h1:Jk91dRBZuMVjBMu2oQmqMRc6xuL5V+rzgHeFWvI+wlg=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
|
||||
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
|
||||
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
|
||||
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
|
||||
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
|
||||
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
|
||||
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
|
||||
go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4=
|
||||
go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU=
|
||||
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs=
|
||||
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
|
||||
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
|
||||
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
|
||||
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
|
||||
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
9
hack/config.yaml
Normal file
9
hack/config.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
# CLI tool, only in development environment.
|
||||
# https://goframe.org/docs/cli
|
||||
gfcli:
|
||||
gen:
|
||||
dao:
|
||||
- link: "mysql:root:MSms0427@tcp(127.0.0.1:3306)/novel"
|
||||
descriptionTag: true
|
||||
tablesEx: "casbin_rule"
|
||||
50
internal/cmd/cmd.go
Normal file
50
internal/cmd/cmd.go
Normal file
@ -0,0 +1,50 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/controller/admin"
|
||||
"server/internal/controller/auth"
|
||||
"server/internal/controller/book"
|
||||
"server/internal/controller/category"
|
||||
"server/internal/controller/chapter"
|
||||
"server/internal/controller/feedback"
|
||||
"server/internal/controller/user"
|
||||
"server/internal/middleware"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
)
|
||||
|
||||
var (
|
||||
Main = gcmd.Command{
|
||||
Name: "main",
|
||||
Usage: "main",
|
||||
Brief: "start http server",
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
s := g.Server()
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(middleware.Language) // 语言检测中间件
|
||||
group.Middleware(middleware.Response)
|
||||
group.Middleware(ghttp.MiddlewareCORS)
|
||||
group.Bind(
|
||||
auth.NewV1(),
|
||||
)
|
||||
group.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(middleware.Auth)
|
||||
group.Middleware(middleware.Casbin)
|
||||
group.Bind(
|
||||
admin.NewV1(),
|
||||
book.NewV1(),
|
||||
category.NewV1(),
|
||||
chapter.NewV1(),
|
||||
feedback.NewV1(),
|
||||
user.NewV1(),
|
||||
)
|
||||
})
|
||||
})
|
||||
s.Run()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
)
|
||||
1
internal/consts/consts.go
Normal file
1
internal/consts/consts.go
Normal file
@ -0,0 +1 @@
|
||||
package consts
|
||||
8
internal/consts/role.go
Normal file
8
internal/consts/role.go
Normal file
@ -0,0 +1,8 @@
|
||||
package consts
|
||||
|
||||
const (
|
||||
GuestRoleCode = "guest"
|
||||
UserRoleCode = "user"
|
||||
AuthorRoleCode = "author"
|
||||
AdminRoleCode = "admin"
|
||||
)
|
||||
6
internal/consts/user.go
Normal file
6
internal/consts/user.go
Normal file
@ -0,0 +1,6 @@
|
||||
package consts
|
||||
|
||||
const (
|
||||
UserEnable = iota + 1
|
||||
UserDisable
|
||||
)
|
||||
5
internal/controller/admin/admin.go
Normal file
5
internal/controller/admin/admin.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package admin
|
||||
15
internal/controller/admin/admin_new.go
Normal file
15
internal/controller/admin/admin_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"server/api/admin"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() admin.IAdminV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
17
internal/controller/admin/admin_v1_admin_edit_pass.go
Normal file
17
internal/controller/admin/admin_v1_admin_edit_pass.go
Normal file
@ -0,0 +1,17 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/admin/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AdminEditPass(ctx context.Context, req *v1.AdminEditPassReq) (res *v1.AdminEditPassRes, err error) {
|
||||
out, err := service.Admin().EditPass(ctx, &model.AdminEditPassIn{NewPass: req.NewPass, OldPass: req.OldPass})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AdminEditPassRes{Success: out.Success}, nil
|
||||
}
|
||||
22
internal/controller/admin/admin_v1_admin_info.go
Normal file
22
internal/controller/admin/admin_v1_admin_info.go
Normal file
@ -0,0 +1,22 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/admin/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AdminInfo(ctx context.Context, req *v1.AdminInfoReq) (res *v1.AdminInfoRes, err error) {
|
||||
adminId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Admin().Info(ctx, &model.AdminInfoIn{AdminId: adminId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AdminInfoRes{
|
||||
AdminId: out.AdminId,
|
||||
Username: out.Username,
|
||||
}, nil
|
||||
}
|
||||
5
internal/controller/auth/auth.go
Normal file
5
internal/controller/auth/auth.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package auth
|
||||
15
internal/controller/auth/auth_new.go
Normal file
15
internal/controller/auth/auth_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package auth
|
||||
|
||||
import (
|
||||
"server/api/auth"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() auth.IAuthV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_admin_login.go
Normal file
17
internal/controller/auth/auth_v1_admin_login.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AdminLogin(ctx context.Context, req *v1.AdminLoginReq) (res *v1.AdminLoginRes, err error) {
|
||||
out, err := service.Admin().Login(ctx, &model.AdminLoginIn{Username: req.Username, Password: req.Password})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AdminLoginRes{Token: out.Token}, nil
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_user_code.go
Normal file
17
internal/controller/auth/auth_v1_user_code.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserCode(ctx context.Context, req *v1.UserCodeReq) (res *v1.UserCodeRes, err error) {
|
||||
out, err := service.User().Code(ctx, &model.UserCodeIn{Email: req.Email})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UserCodeRes{Success: out.Success}, nil
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_user_edit_pass.go
Normal file
17
internal/controller/auth/auth_v1_user_edit_pass.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserEditPass(ctx context.Context, req *v1.UserEditPassReq) (res *v1.UserEditPassRes, err error) {
|
||||
out, err := service.User().EditPass(ctx, &model.UserEditPassIn{Email: req.Email, Password: req.Password, Password2: req.Password2, Sign: req.Sign})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UserEditPassRes{Success: out.Success}, nil
|
||||
}
|
||||
18
internal/controller/auth/auth_v1_user_login.go
Normal file
18
internal/controller/auth/auth_v1_user_login.go
Normal file
@ -0,0 +1,18 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserLogin(ctx context.Context, req *v1.UserLoginReq) (res *v1.UserLoginRes, err error) {
|
||||
out, err := service.User().Login(ctx, &model.UserLoginIn{Email: req.Email, Password: req.Password})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.UserLoginRes{Token: out.Token}, nil
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_user_register.go
Normal file
17
internal/controller/auth/auth_v1_user_register.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserRegister(ctx context.Context, req *v1.UserRegisterReq) (res *v1.UserRegisterRes, err error) {
|
||||
out, err := service.User().Register(ctx, &model.UserRegisterIn{Email: req.Email, Password: req.Password, Password2: req.Password2})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UserRegisterRes{Success: out.Success}, nil
|
||||
}
|
||||
5
internal/controller/book/book.go
Normal file
5
internal/controller/book/book.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package book
|
||||
15
internal/controller/book/book_new.go
Normal file
15
internal/controller/book/book_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package book
|
||||
|
||||
import (
|
||||
"server/api/book"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() book.IBookV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
26
internal/controller/book/book_v1_book_add.go
Normal file
26
internal/controller/book/book_v1_book_add.go
Normal file
@ -0,0 +1,26 @@
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/book/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BookAdd(ctx context.Context, req *v1.BookAddReq) (res *v1.BookAddRes, err error) {
|
||||
out, err := service.Book().Create(ctx, &model.BookAddIn{
|
||||
AuthorId: req.AuthorId,
|
||||
CategoryId: req.CategoryId,
|
||||
CoverUrl: req.CoverUrl,
|
||||
Description: req.Description,
|
||||
IsRecommended: req.IsRecommended,
|
||||
Status: req.Status,
|
||||
Tags: req.Tags,
|
||||
Title: req.Title,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BookAddRes{Success: out.Success}, nil
|
||||
}
|
||||
19
internal/controller/book/book_v1_book_del.go
Normal file
19
internal/controller/book/book_v1_book_del.go
Normal file
@ -0,0 +1,19 @@
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/book/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BookDel(ctx context.Context, req *v1.BookDelReq) (res *v1.BookDelRes, err error) {
|
||||
out, err := service.Book().Delete(ctx, &model.BookDelIn{
|
||||
Id: req.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BookDelRes{Success: out.Success}, nil
|
||||
}
|
||||
27
internal/controller/book/book_v1_book_edit.go
Normal file
27
internal/controller/book/book_v1_book_edit.go
Normal file
@ -0,0 +1,27 @@
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/book/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BookEdit(ctx context.Context, req *v1.BookEditReq) (res *v1.BookEditRes, err error) {
|
||||
out, err := service.Book().Update(ctx, &model.BookEditIn{
|
||||
AuthorId: req.AuthorId,
|
||||
CategoryId: req.CategoryId,
|
||||
CoverUrl: req.CoverUrl,
|
||||
Description: req.Description,
|
||||
Id: req.Id,
|
||||
IsRecommended: req.IsRecommended,
|
||||
Status: req.Status,
|
||||
Tags: req.Tags,
|
||||
Title: req.Title,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BookEditRes{Success: out.Success}, nil
|
||||
}
|
||||
28
internal/controller/book/book_v1_book_list.go
Normal file
28
internal/controller/book/book_v1_book_list.go
Normal file
@ -0,0 +1,28 @@
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/book/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BookList(ctx context.Context, req *v1.BookListReq) (res *v1.BookListRes, err error) {
|
||||
out, err := service.Book().List(ctx, &model.BookListIn{
|
||||
AuthorId: req.AuthorId,
|
||||
CategoryId: req.CategoryId,
|
||||
IsRecommended: req.IsRecommended,
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Status: req.Status,
|
||||
Title: req.Title,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BookListRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
5
internal/controller/category/category.go
Normal file
5
internal/controller/category/category.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package category
|
||||
15
internal/controller/category/category_new.go
Normal file
15
internal/controller/category/category_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package category
|
||||
|
||||
import (
|
||||
"server/api/category"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() category.ICategoryV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
22
internal/controller/category/category_v1_category_add.go
Normal file
22
internal/controller/category/category_v1_category_add.go
Normal file
@ -0,0 +1,22 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CategoryAdd(ctx context.Context, req *v1.CategoryAddReq) (res *v1.CategoryAddRes, err error) {
|
||||
out, err := service.Category().Create(ctx, &model.CategoryAddIn{
|
||||
Name: req.Name,
|
||||
Type: req.Type,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CategoryAddRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
21
internal/controller/category/category_v1_category_del.go
Normal file
21
internal/controller/category/category_v1_category_del.go
Normal file
@ -0,0 +1,21 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CategoryDel(ctx context.Context, req *v1.CategoryDelReq) (res *v1.CategoryDelRes, err error) {
|
||||
out, err := service.Category().Delete(ctx, &model.CategoryDelIn{
|
||||
Id: req.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CategoryDelRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
23
internal/controller/category/category_v1_category_edit.go
Normal file
23
internal/controller/category/category_v1_category_edit.go
Normal file
@ -0,0 +1,23 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CategoryEdit(ctx context.Context, req *v1.CategoryEditReq) (res *v1.CategoryEditRes, err error) {
|
||||
out, err := service.Category().Update(ctx, &model.CategoryEditIn{
|
||||
Id: req.Id,
|
||||
Name: req.Name,
|
||||
Type: req.Type,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CategoryEditRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
25
internal/controller/category/category_v1_category_list.go
Normal file
25
internal/controller/category/category_v1_category_list.go
Normal file
@ -0,0 +1,25 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CategoryList(ctx context.Context, req *v1.CategoryListReq) (res *v1.CategoryListRes, err error) {
|
||||
out, err := service.Category().List(ctx, &model.CategoryListIn{
|
||||
Name: req.Name,
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Type: req.Type,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CategoryListRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
5
internal/controller/chapter/chapter.go
Normal file
5
internal/controller/chapter/chapter.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package chapter
|
||||
15
internal/controller/chapter/chapter_new.go
Normal file
15
internal/controller/chapter/chapter_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"server/api/chapter"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() chapter.IChapterV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
27
internal/controller/chapter/chapter_v1_chapter_add.go
Normal file
27
internal/controller/chapter/chapter_v1_chapter_add.go
Normal file
@ -0,0 +1,27 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterAdd(ctx context.Context, req *v1.ChapterAddReq) (res *v1.ChapterAddRes, err error) {
|
||||
out, err := service.Chapter().Create(ctx, &model.ChapterAddIn{
|
||||
BookId: req.BookId,
|
||||
Content: req.Content,
|
||||
IsLocked: req.IsLocked,
|
||||
RequiredScore: req.RequiredScore,
|
||||
Sort: req.Sort,
|
||||
Title: req.Title,
|
||||
WordCount: req.WordCount,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterAddRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
19
internal/controller/chapter/chapter_v1_chapter_del.go
Normal file
19
internal/controller/chapter/chapter_v1_chapter_del.go
Normal file
@ -0,0 +1,19 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterDel(ctx context.Context, req *v1.ChapterDelReq) (res *v1.ChapterDelRes, err error) {
|
||||
out, err := service.Chapter().Delete(ctx, &model.ChapterDelIn{
|
||||
Id: req.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterDelRes{Success: out.Success}, nil
|
||||
}
|
||||
28
internal/controller/chapter/chapter_v1_chapter_edit.go
Normal file
28
internal/controller/chapter/chapter_v1_chapter_edit.go
Normal file
@ -0,0 +1,28 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterEdit(ctx context.Context, req *v1.ChapterEditReq) (res *v1.ChapterEditRes, err error) {
|
||||
out, err := service.Chapter().Update(ctx, &model.ChapterEditIn{
|
||||
BookId: req.BookId,
|
||||
Content: req.Content,
|
||||
Id: req.Id,
|
||||
IsLocked: req.IsLocked,
|
||||
RequiredScore: req.RequiredScore,
|
||||
Sort: req.Sort,
|
||||
Title: req.Title,
|
||||
WordCount: req.WordCount,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterEditRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
26
internal/controller/chapter/chapter_v1_chapter_list.go
Normal file
26
internal/controller/chapter/chapter_v1_chapter_list.go
Normal file
@ -0,0 +1,26 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterList(ctx context.Context, req *v1.ChapterListReq) (res *v1.ChapterListRes, err error) {
|
||||
out, err := service.Chapter().List(ctx, &model.ChapterListIn{
|
||||
BookId: req.BookId,
|
||||
IsLocked: req.IsLocked,
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Title: req.Title,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterListRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
5
internal/controller/feedback/feedback.go
Normal file
5
internal/controller/feedback/feedback.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package feedback
|
||||
15
internal/controller/feedback/feedback_new.go
Normal file
15
internal/controller/feedback/feedback_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package feedback
|
||||
|
||||
import (
|
||||
"server/api/feedback"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() feedback.IFeedbackV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
24
internal/controller/feedback/feedback_v1_feedback_add.go
Normal file
24
internal/controller/feedback/feedback_v1_feedback_add.go
Normal file
@ -0,0 +1,24 @@
|
||||
package feedback
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/feedback/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) FeedbackAdd(ctx context.Context, req *v1.FeedbackAddReq) (res *v1.FeedbackAddRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Feedback().Create(ctx, &model.FeedbackAddIn{
|
||||
Content: req.Content,
|
||||
UserId: userId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.FeedbackAddRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
25
internal/controller/feedback/feedback_v1_feedback_list.go
Normal file
25
internal/controller/feedback/feedback_v1_feedback_list.go
Normal file
@ -0,0 +1,25 @@
|
||||
package feedback
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/feedback/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) FeedbackList(ctx context.Context, req *v1.FeedbackListReq) (res *v1.FeedbackListRes, err error) {
|
||||
out, err := service.Feedback().List(ctx, &model.FeedbackListIn{
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Status: req.Status,
|
||||
UserId: req.UserId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.FeedbackListRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
5
internal/controller/user/user.go
Normal file
5
internal/controller/user/user.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package user
|
||||
15
internal/controller/user/user_new.go
Normal file
15
internal/controller/user/user_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
"server/api/user"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() user.IUserV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
19
internal/controller/user/user_v1_delete.go
Normal file
19
internal/controller/user/user_v1_delete.go
Normal file
@ -0,0 +1,19 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/user/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.User().Delete(ctx, &model.UserDeleteIn{UserId: userId, Password: req.Password})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DeleteRes{Success: out.Success}, nil
|
||||
}
|
||||
14
internal/controller/user/user_v1_logout.go
Normal file
14
internal/controller/user/user_v1_logout.go
Normal file
@ -0,0 +1,14 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
|
||||
"server/api/user/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Logout(ctx context.Context, req *v1.LogoutReq) (res *v1.LogoutRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
}
|
||||
24
internal/controller/user/user_v1_user_info.go
Normal file
24
internal/controller/user/user_v1_user_info.go
Normal file
@ -0,0 +1,24 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/user/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserInfo(ctx context.Context, req *v1.UserInfoReq) (res *v1.UserInfoRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
info, err := service.User().Info(ctx, &model.UserInfoIn{UserId: userId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UserInfoRes{
|
||||
Username: info.Username,
|
||||
Avatar: info.Avatar,
|
||||
Email: info.Email,
|
||||
Points: info.Points,
|
||||
}, nil
|
||||
}
|
||||
27
internal/dao/admins.go
Normal file
27
internal/dao/admins.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalAdminsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalAdminsDao = *internal.AdminsDao
|
||||
|
||||
// adminsDao is the data access object for the table admins.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminsDao struct {
|
||||
internalAdminsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Admins is a globally accessible object for table admins operations.
|
||||
Admins = adminsDao{
|
||||
internal.NewAdminsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/authors.go
Normal file
27
internal/dao/authors.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalAuthorsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalAuthorsDao = *internal.AuthorsDao
|
||||
|
||||
// authorsDao is the data access object for the table authors.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type authorsDao struct {
|
||||
internalAuthorsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Authors is a globally accessible object for table authors operations.
|
||||
Authors = authorsDao{
|
||||
internal.NewAuthorsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/book_ratings.go
Normal file
27
internal/dao/book_ratings.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalBookRatingsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalBookRatingsDao = *internal.BookRatingsDao
|
||||
|
||||
// bookRatingsDao is the data access object for the table book_ratings.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type bookRatingsDao struct {
|
||||
internalBookRatingsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// BookRatings is a globally accessible object for table book_ratings operations.
|
||||
BookRatings = bookRatingsDao{
|
||||
internal.NewBookRatingsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/books.go
Normal file
27
internal/dao/books.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalBooksDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalBooksDao = *internal.BooksDao
|
||||
|
||||
// booksDao is the data access object for the table books.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type booksDao struct {
|
||||
internalBooksDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Books is a globally accessible object for table books operations.
|
||||
Books = booksDao{
|
||||
internal.NewBooksDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/bookshelves.go
Normal file
27
internal/dao/bookshelves.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalBookshelvesDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalBookshelvesDao = *internal.BookshelvesDao
|
||||
|
||||
// bookshelvesDao is the data access object for the table bookshelves.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type bookshelvesDao struct {
|
||||
internalBookshelvesDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Bookshelves is a globally accessible object for table bookshelves operations.
|
||||
Bookshelves = bookshelvesDao{
|
||||
internal.NewBookshelvesDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/categories.go
Normal file
27
internal/dao/categories.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalCategoriesDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalCategoriesDao = *internal.CategoriesDao
|
||||
|
||||
// categoriesDao is the data access object for the table categories.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type categoriesDao struct {
|
||||
internalCategoriesDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Categories is a globally accessible object for table categories operations.
|
||||
Categories = categoriesDao{
|
||||
internal.NewCategoriesDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/chapters.go
Normal file
27
internal/dao/chapters.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalChaptersDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalChaptersDao = *internal.ChaptersDao
|
||||
|
||||
// chaptersDao is the data access object for the table chapters.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type chaptersDao struct {
|
||||
internalChaptersDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Chapters is a globally accessible object for table chapters operations.
|
||||
Chapters = chaptersDao{
|
||||
internal.NewChaptersDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/feedbacks.go
Normal file
27
internal/dao/feedbacks.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalFeedbacksDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalFeedbacksDao = *internal.FeedbacksDao
|
||||
|
||||
// feedbacksDao is the data access object for the table feedbacks.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type feedbacksDao struct {
|
||||
internalFeedbacksDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Feedbacks is a globally accessible object for table feedbacks operations.
|
||||
Feedbacks = feedbacksDao{
|
||||
internal.NewFeedbacksDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
83
internal/dao/internal/admins.go
Normal file
83
internal/dao/internal/admins.go
Normal 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"
|
||||
)
|
||||
|
||||
// AdminsDao is the data access object for the table admins.
|
||||
type AdminsDao 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 AdminsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AdminsColumns defines and stores column names for the table admins.
|
||||
type AdminsColumns struct {
|
||||
Id string // 管理员ID
|
||||
Username string // 管理员用户名
|
||||
PasswordHash string // 密码哈希
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// adminsColumns holds the columns for the table admins.
|
||||
var adminsColumns = AdminsColumns{
|
||||
Id: "id",
|
||||
Username: "username",
|
||||
PasswordHash: "password_hash",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAdminsDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminsDao() *AdminsDao {
|
||||
return &AdminsDao{
|
||||
group: "default",
|
||||
table: "admins",
|
||||
columns: adminsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *AdminsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *AdminsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *AdminsDao) Columns() AdminsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *AdminsDao) 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 *AdminsDao) 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 *AdminsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
87
internal/dao/internal/authors.go
Normal file
87
internal/dao/internal/authors.go
Normal file
@ -0,0 +1,87 @@
|
||||
// ==========================================================================
|
||||
// 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"
|
||||
)
|
||||
|
||||
// AuthorsDao is the data access object for the table authors.
|
||||
type AuthorsDao 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 AuthorsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// AuthorsColumns defines and stores column names for the table authors.
|
||||
type AuthorsColumns struct {
|
||||
Id string // 作者ID
|
||||
UserId string // 用户ID
|
||||
PenName string // 笔名
|
||||
Bio string // 作者简介
|
||||
Status string // 状态:1=正常,2=禁用
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// authorsColumns holds the columns for the table authors.
|
||||
var authorsColumns = AuthorsColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
PenName: "pen_name",
|
||||
Bio: "bio",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewAuthorsDao creates and returns a new DAO object for table data access.
|
||||
func NewAuthorsDao() *AuthorsDao {
|
||||
return &AuthorsDao{
|
||||
group: "default",
|
||||
table: "authors",
|
||||
columns: authorsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *AuthorsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *AuthorsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *AuthorsDao) Columns() AuthorsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *AuthorsDao) 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 *AuthorsDao) 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 *AuthorsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
83
internal/dao/internal/book_ratings.go
Normal file
83
internal/dao/internal/book_ratings.go
Normal 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"
|
||||
)
|
||||
|
||||
// BookRatingsDao is the data access object for the table book_ratings.
|
||||
type BookRatingsDao 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 BookRatingsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// BookRatingsColumns defines and stores column names for the table book_ratings.
|
||||
type BookRatingsColumns struct {
|
||||
Id string // 评分ID
|
||||
UserId string // 用户ID
|
||||
BookId string // 小说ID
|
||||
Score string // 评分(0~10)
|
||||
Comment string // 用户评论
|
||||
CreatedAt string // 创建时间
|
||||
}
|
||||
|
||||
// bookRatingsColumns holds the columns for the table book_ratings.
|
||||
var bookRatingsColumns = BookRatingsColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
BookId: "book_id",
|
||||
Score: "score",
|
||||
Comment: "comment",
|
||||
CreatedAt: "created_at",
|
||||
}
|
||||
|
||||
// NewBookRatingsDao creates and returns a new DAO object for table data access.
|
||||
func NewBookRatingsDao() *BookRatingsDao {
|
||||
return &BookRatingsDao{
|
||||
group: "default",
|
||||
table: "book_ratings",
|
||||
columns: bookRatingsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *BookRatingsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *BookRatingsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *BookRatingsDao) Columns() BookRatingsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *BookRatingsDao) 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 *BookRatingsDao) 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 *BookRatingsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
105
internal/dao/internal/books.go
Normal file
105
internal/dao/internal/books.go
Normal file
@ -0,0 +1,105 @@
|
||||
// ==========================================================================
|
||||
// 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"
|
||||
)
|
||||
|
||||
// BooksDao is the data access object for the table books.
|
||||
type BooksDao 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 BooksColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// BooksColumns defines and stores column names for the table books.
|
||||
type BooksColumns struct {
|
||||
Id string // 小说ID
|
||||
AuthorId string // 作者ID
|
||||
CategoryId string // 分类ID
|
||||
Title string // 小说标题
|
||||
CoverUrl string // 封面图片URL
|
||||
Description string // 小说简介
|
||||
Status string // 状态:1=连载中,2=完结,3=下架
|
||||
WordsCount string // 字数
|
||||
ChaptersCount string // 章节数
|
||||
LatestChapterId string // 最新章节ID
|
||||
Rating string // 评分(0.00~10.00)
|
||||
ReadCount string // 阅读人数
|
||||
Tags string // 标签(逗号分隔)
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
IsRecommended string // 是否推荐:0=否,1=是
|
||||
}
|
||||
|
||||
// booksColumns holds the columns for the table books.
|
||||
var booksColumns = BooksColumns{
|
||||
Id: "id",
|
||||
AuthorId: "author_id",
|
||||
CategoryId: "category_id",
|
||||
Title: "title",
|
||||
CoverUrl: "cover_url",
|
||||
Description: "description",
|
||||
Status: "status",
|
||||
WordsCount: "words_count",
|
||||
ChaptersCount: "chapters_count",
|
||||
LatestChapterId: "latest_chapter_id",
|
||||
Rating: "rating",
|
||||
ReadCount: "read_count",
|
||||
Tags: "tags",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
IsRecommended: "is_recommended",
|
||||
}
|
||||
|
||||
// NewBooksDao creates and returns a new DAO object for table data access.
|
||||
func NewBooksDao() *BooksDao {
|
||||
return &BooksDao{
|
||||
group: "default",
|
||||
table: "books",
|
||||
columns: booksColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *BooksDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *BooksDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *BooksDao) Columns() BooksColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *BooksDao) 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 *BooksDao) 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 *BooksDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
85
internal/dao/internal/bookshelves.go
Normal file
85
internal/dao/internal/bookshelves.go
Normal file
@ -0,0 +1,85 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// BookshelvesDao is the data access object for the table bookshelves.
|
||||
type BookshelvesDao 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 BookshelvesColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// BookshelvesColumns defines and stores column names for the table bookshelves.
|
||||
type BookshelvesColumns struct {
|
||||
Id string // 记录ID
|
||||
UserId string // 用户ID
|
||||
BookId string // 小说ID
|
||||
AddedAt string // 加入书架时间
|
||||
LastReadChapterId string // 最后阅读章节ID
|
||||
LastReadPercent string // 阅读进度百分比(0.00~100.00)
|
||||
LastReadAt string // 最后阅读时间
|
||||
}
|
||||
|
||||
// bookshelvesColumns holds the columns for the table bookshelves.
|
||||
var bookshelvesColumns = BookshelvesColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
BookId: "book_id",
|
||||
AddedAt: "added_at",
|
||||
LastReadChapterId: "last_read_chapter_id",
|
||||
LastReadPercent: "last_read_percent",
|
||||
LastReadAt: "last_read_at",
|
||||
}
|
||||
|
||||
// NewBookshelvesDao creates and returns a new DAO object for table data access.
|
||||
func NewBookshelvesDao() *BookshelvesDao {
|
||||
return &BookshelvesDao{
|
||||
group: "default",
|
||||
table: "bookshelves",
|
||||
columns: bookshelvesColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *BookshelvesDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *BookshelvesDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *BookshelvesDao) Columns() BookshelvesColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *BookshelvesDao) 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 *BookshelvesDao) 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 *BookshelvesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
83
internal/dao/internal/categories.go
Normal file
83
internal/dao/internal/categories.go
Normal 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"
|
||||
)
|
||||
|
||||
// CategoriesDao is the data access object for the table categories.
|
||||
type CategoriesDao 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 CategoriesColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// CategoriesColumns defines and stores column names for the table categories.
|
||||
type CategoriesColumns struct {
|
||||
Id string // 分类ID
|
||||
Name string // 分类名称
|
||||
Type string // 分类类型:1=男频, 2=女频
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// categoriesColumns holds the columns for the table categories.
|
||||
var categoriesColumns = CategoriesColumns{
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
Type: "type",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewCategoriesDao creates and returns a new DAO object for table data access.
|
||||
func NewCategoriesDao() *CategoriesDao {
|
||||
return &CategoriesDao{
|
||||
group: "default",
|
||||
table: "categories",
|
||||
columns: categoriesColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *CategoriesDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *CategoriesDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *CategoriesDao) Columns() CategoriesColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *CategoriesDao) 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 *CategoriesDao) 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 *CategoriesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
93
internal/dao/internal/chapters.go
Normal file
93
internal/dao/internal/chapters.go
Normal 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"
|
||||
)
|
||||
|
||||
// ChaptersDao is the data access object for the table chapters.
|
||||
type ChaptersDao 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 ChaptersColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// ChaptersColumns defines and stores column names for the table chapters.
|
||||
type ChaptersColumns struct {
|
||||
Id string // 章节ID
|
||||
BookId string // 小说ID
|
||||
Title string // 章节标题
|
||||
Content string // 章节内容
|
||||
WordCount string // 章节字数
|
||||
Sort string // 排序序号
|
||||
IsLocked string // 是否锁定:0=免费,1=需积分解锁
|
||||
RequiredScore string // 解锁该章节所需积分
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// chaptersColumns holds the columns for the table chapters.
|
||||
var chaptersColumns = ChaptersColumns{
|
||||
Id: "id",
|
||||
BookId: "book_id",
|
||||
Title: "title",
|
||||
Content: "content",
|
||||
WordCount: "word_count",
|
||||
Sort: "sort",
|
||||
IsLocked: "is_locked",
|
||||
RequiredScore: "required_score",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewChaptersDao creates and returns a new DAO object for table data access.
|
||||
func NewChaptersDao() *ChaptersDao {
|
||||
return &ChaptersDao{
|
||||
group: "default",
|
||||
table: "chapters",
|
||||
columns: chaptersColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *ChaptersDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *ChaptersDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *ChaptersDao) Columns() ChaptersColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *ChaptersDao) 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 *ChaptersDao) 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 *ChaptersDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
83
internal/dao/internal/feedbacks.go
Normal file
83
internal/dao/internal/feedbacks.go
Normal 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"
|
||||
)
|
||||
|
||||
// FeedbacksDao is the data access object for the table feedbacks.
|
||||
type FeedbacksDao 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 FeedbacksColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// FeedbacksColumns defines and stores column names for the table feedbacks.
|
||||
type FeedbacksColumns struct {
|
||||
Id string // 反馈ID
|
||||
UserId string // 用户ID
|
||||
Content string // 反馈内容
|
||||
Status string // 处理状态:1=未处理,2=处理中,3=已处理
|
||||
CreatedAt string // 反馈时间
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// feedbacksColumns holds the columns for the table feedbacks.
|
||||
var feedbacksColumns = FeedbacksColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
Content: "content",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewFeedbacksDao creates and returns a new DAO object for table data access.
|
||||
func NewFeedbacksDao() *FeedbacksDao {
|
||||
return &FeedbacksDao{
|
||||
group: "default",
|
||||
table: "feedbacks",
|
||||
columns: feedbacksColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *FeedbacksDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *FeedbacksDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *FeedbacksDao) Columns() FeedbacksColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *FeedbacksDao) 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 *FeedbacksDao) 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 *FeedbacksDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
81
internal/dao/internal/read_records.go
Normal file
81
internal/dao/internal/read_records.go
Normal 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"
|
||||
)
|
||||
|
||||
// ReadRecordsDao is the data access object for the table read_records.
|
||||
type ReadRecordsDao 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 ReadRecordsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// ReadRecordsColumns defines and stores column names for the table read_records.
|
||||
type ReadRecordsColumns struct {
|
||||
Id string // 记录ID
|
||||
UserId string // 用户ID
|
||||
BookId string // 小说ID
|
||||
ChapterId string // 章节ID
|
||||
ReadAt string // 阅读时间
|
||||
}
|
||||
|
||||
// readRecordsColumns holds the columns for the table read_records.
|
||||
var readRecordsColumns = ReadRecordsColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
BookId: "book_id",
|
||||
ChapterId: "chapter_id",
|
||||
ReadAt: "read_at",
|
||||
}
|
||||
|
||||
// NewReadRecordsDao creates and returns a new DAO object for table data access.
|
||||
func NewReadRecordsDao() *ReadRecordsDao {
|
||||
return &ReadRecordsDao{
|
||||
group: "default",
|
||||
table: "read_records",
|
||||
columns: readRecordsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *ReadRecordsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *ReadRecordsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *ReadRecordsDao) Columns() ReadRecordsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *ReadRecordsDao) 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 *ReadRecordsDao) 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 *ReadRecordsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
83
internal/dao/internal/tags.go
Normal file
83
internal/dao/internal/tags.go
Normal 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"
|
||||
)
|
||||
|
||||
// TagsDao is the data access object for the table tags.
|
||||
type TagsDao 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 TagsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// TagsColumns defines and stores column names for the table tags.
|
||||
type TagsColumns struct {
|
||||
Id string // 标签ID
|
||||
Name string // 标签名称
|
||||
Type string // 标签类型:1=主题, 2=角色, 3=情节
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// tagsColumns holds the columns for the table tags.
|
||||
var tagsColumns = TagsColumns{
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
Type: "type",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewTagsDao creates and returns a new DAO object for table data access.
|
||||
func NewTagsDao() *TagsDao {
|
||||
return &TagsDao{
|
||||
group: "default",
|
||||
table: "tags",
|
||||
columns: tagsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *TagsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *TagsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *TagsDao) Columns() TagsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *TagsDao) 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 *TagsDao) 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 *TagsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
83
internal/dao/internal/user_chapter_purchases.go
Normal file
83
internal/dao/internal/user_chapter_purchases.go
Normal 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"
|
||||
)
|
||||
|
||||
// UserChapterPurchasesDao is the data access object for the table user_chapter_purchases.
|
||||
type UserChapterPurchasesDao 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 UserChapterPurchasesColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// UserChapterPurchasesColumns defines and stores column names for the table user_chapter_purchases.
|
||||
type UserChapterPurchasesColumns struct {
|
||||
Id string // 购买记录ID
|
||||
UserId string // 用户ID
|
||||
BookId string // 小说ID
|
||||
ChapterId string // 章节ID
|
||||
PointsUsed string // 消耗积分数
|
||||
PurchaseTime string // 购买时间
|
||||
}
|
||||
|
||||
// userChapterPurchasesColumns holds the columns for the table user_chapter_purchases.
|
||||
var userChapterPurchasesColumns = UserChapterPurchasesColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
BookId: "book_id",
|
||||
ChapterId: "chapter_id",
|
||||
PointsUsed: "points_used",
|
||||
PurchaseTime: "purchase_time",
|
||||
}
|
||||
|
||||
// NewUserChapterPurchasesDao creates and returns a new DAO object for table data access.
|
||||
func NewUserChapterPurchasesDao() *UserChapterPurchasesDao {
|
||||
return &UserChapterPurchasesDao{
|
||||
group: "default",
|
||||
table: "user_chapter_purchases",
|
||||
columns: userChapterPurchasesColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *UserChapterPurchasesDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *UserChapterPurchasesDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *UserChapterPurchasesDao) Columns() UserChapterPurchasesColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *UserChapterPurchasesDao) 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 *UserChapterPurchasesDao) 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 *UserChapterPurchasesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
79
internal/dao/internal/user_follow_authors.go
Normal file
79
internal/dao/internal/user_follow_authors.go
Normal file
@ -0,0 +1,79 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// UserFollowAuthorsDao is the data access object for the table user_follow_authors.
|
||||
type UserFollowAuthorsDao 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 UserFollowAuthorsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// UserFollowAuthorsColumns defines and stores column names for the table user_follow_authors.
|
||||
type UserFollowAuthorsColumns struct {
|
||||
Id string // 关注ID
|
||||
UserId string // 用户ID
|
||||
AuthorId string // 作者ID
|
||||
FollowedAt string // 关注时间
|
||||
}
|
||||
|
||||
// userFollowAuthorsColumns holds the columns for the table user_follow_authors.
|
||||
var userFollowAuthorsColumns = UserFollowAuthorsColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
AuthorId: "author_id",
|
||||
FollowedAt: "followed_at",
|
||||
}
|
||||
|
||||
// NewUserFollowAuthorsDao creates and returns a new DAO object for table data access.
|
||||
func NewUserFollowAuthorsDao() *UserFollowAuthorsDao {
|
||||
return &UserFollowAuthorsDao{
|
||||
group: "default",
|
||||
table: "user_follow_authors",
|
||||
columns: userFollowAuthorsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *UserFollowAuthorsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *UserFollowAuthorsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *UserFollowAuthorsDao) Columns() UserFollowAuthorsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *UserFollowAuthorsDao) 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 *UserFollowAuthorsDao) 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 *UserFollowAuthorsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
79
internal/dao/internal/user_points.go
Normal file
79
internal/dao/internal/user_points.go
Normal file
@ -0,0 +1,79 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// UserPointsDao is the data access object for the table user_points.
|
||||
type UserPointsDao 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 UserPointsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// UserPointsColumns defines and stores column names for the table user_points.
|
||||
type UserPointsColumns struct {
|
||||
Id string // 积分账户ID
|
||||
UserId string // 用户ID
|
||||
PointsBalance string // 当前积分余额
|
||||
UpdatedAt string // 更新时间
|
||||
}
|
||||
|
||||
// userPointsColumns holds the columns for the table user_points.
|
||||
var userPointsColumns = UserPointsColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
PointsBalance: "points_balance",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewUserPointsDao creates and returns a new DAO object for table data access.
|
||||
func NewUserPointsDao() *UserPointsDao {
|
||||
return &UserPointsDao{
|
||||
group: "default",
|
||||
table: "user_points",
|
||||
columns: userPointsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *UserPointsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *UserPointsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *UserPointsDao) Columns() UserPointsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *UserPointsDao) 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 *UserPointsDao) 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 *UserPointsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
85
internal/dao/internal/user_points_logs.go
Normal file
85
internal/dao/internal/user_points_logs.go
Normal file
@ -0,0 +1,85 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// UserPointsLogsDao is the data access object for the table user_points_logs.
|
||||
type UserPointsLogsDao 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 UserPointsLogsColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// UserPointsLogsColumns defines and stores column names for the table user_points_logs.
|
||||
type UserPointsLogsColumns struct {
|
||||
Id string // 积分流水ID
|
||||
UserId string // 用户ID
|
||||
ChangeType string // 变动类型,例如 earn、spend、refund 等
|
||||
PointsChange string // 积分变化数,正数增加,负数减少
|
||||
RelatedOrderId string // 关联订单ID
|
||||
Description string // 变动说明
|
||||
CreatedAt string // 变动时间
|
||||
}
|
||||
|
||||
// userPointsLogsColumns holds the columns for the table user_points_logs.
|
||||
var userPointsLogsColumns = UserPointsLogsColumns{
|
||||
Id: "id",
|
||||
UserId: "user_id",
|
||||
ChangeType: "change_type",
|
||||
PointsChange: "points_change",
|
||||
RelatedOrderId: "related_order_id",
|
||||
Description: "description",
|
||||
CreatedAt: "created_at",
|
||||
}
|
||||
|
||||
// NewUserPointsLogsDao creates and returns a new DAO object for table data access.
|
||||
func NewUserPointsLogsDao() *UserPointsLogsDao {
|
||||
return &UserPointsLogsDao{
|
||||
group: "default",
|
||||
table: "user_points_logs",
|
||||
columns: userPointsLogsColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *UserPointsLogsDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *UserPointsLogsDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *UserPointsLogsDao) Columns() UserPointsLogsColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *UserPointsLogsDao) 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 *UserPointsLogsDao) 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 *UserPointsLogsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
89
internal/dao/internal/users.go
Normal file
89
internal/dao/internal/users.go
Normal 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"
|
||||
)
|
||||
|
||||
// UsersDao is the data access object for the table users.
|
||||
type UsersDao 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 UsersColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// UsersColumns defines and stores column names for the table users.
|
||||
type UsersColumns struct {
|
||||
Id string // 用户ID
|
||||
Username string // 用户名
|
||||
PasswordHash string // 密码哈希
|
||||
Avatar string // 头像URL
|
||||
Email string // 邮箱
|
||||
Points string // 积分
|
||||
CreatedAt string // 注册时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// usersColumns holds the columns for the table users.
|
||||
var usersColumns = UsersColumns{
|
||||
Id: "id",
|
||||
Username: "username",
|
||||
PasswordHash: "password_hash",
|
||||
Avatar: "avatar",
|
||||
Email: "email",
|
||||
Points: "points",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewUsersDao creates and returns a new DAO object for table data access.
|
||||
func NewUsersDao() *UsersDao {
|
||||
return &UsersDao{
|
||||
group: "default",
|
||||
table: "users",
|
||||
columns: usersColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *UsersDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *UsersDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *UsersDao) Columns() UsersColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *UsersDao) 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 *UsersDao) 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 *UsersDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
27
internal/dao/read_records.go
Normal file
27
internal/dao/read_records.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalReadRecordsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalReadRecordsDao = *internal.ReadRecordsDao
|
||||
|
||||
// readRecordsDao is the data access object for the table read_records.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type readRecordsDao struct {
|
||||
internalReadRecordsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// ReadRecords is a globally accessible object for table read_records operations.
|
||||
ReadRecords = readRecordsDao{
|
||||
internal.NewReadRecordsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/tags.go
Normal file
27
internal/dao/tags.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalTagsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalTagsDao = *internal.TagsDao
|
||||
|
||||
// tagsDao is the data access object for the table tags.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type tagsDao struct {
|
||||
internalTagsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Tags is a globally accessible object for table tags operations.
|
||||
Tags = tagsDao{
|
||||
internal.NewTagsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/user_chapter_purchases.go
Normal file
27
internal/dao/user_chapter_purchases.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalUserChapterPurchasesDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalUserChapterPurchasesDao = *internal.UserChapterPurchasesDao
|
||||
|
||||
// userChapterPurchasesDao is the data access object for the table user_chapter_purchases.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type userChapterPurchasesDao struct {
|
||||
internalUserChapterPurchasesDao
|
||||
}
|
||||
|
||||
var (
|
||||
// UserChapterPurchases is a globally accessible object for table user_chapter_purchases operations.
|
||||
UserChapterPurchases = userChapterPurchasesDao{
|
||||
internal.NewUserChapterPurchasesDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/user_follow_authors.go
Normal file
27
internal/dao/user_follow_authors.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalUserFollowAuthorsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalUserFollowAuthorsDao = *internal.UserFollowAuthorsDao
|
||||
|
||||
// userFollowAuthorsDao is the data access object for the table user_follow_authors.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type userFollowAuthorsDao struct {
|
||||
internalUserFollowAuthorsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// UserFollowAuthors is a globally accessible object for table user_follow_authors operations.
|
||||
UserFollowAuthors = userFollowAuthorsDao{
|
||||
internal.NewUserFollowAuthorsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/user_points.go
Normal file
27
internal/dao/user_points.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalUserPointsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalUserPointsDao = *internal.UserPointsDao
|
||||
|
||||
// userPointsDao is the data access object for the table user_points.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type userPointsDao struct {
|
||||
internalUserPointsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// UserPoints is a globally accessible object for table user_points operations.
|
||||
UserPoints = userPointsDao{
|
||||
internal.NewUserPointsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/user_points_logs.go
Normal file
27
internal/dao/user_points_logs.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalUserPointsLogsDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalUserPointsLogsDao = *internal.UserPointsLogsDao
|
||||
|
||||
// userPointsLogsDao is the data access object for the table user_points_logs.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type userPointsLogsDao struct {
|
||||
internalUserPointsLogsDao
|
||||
}
|
||||
|
||||
var (
|
||||
// UserPointsLogs is a globally accessible object for table user_points_logs operations.
|
||||
UserPointsLogs = userPointsLogsDao{
|
||||
internal.NewUserPointsLogsDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
27
internal/dao/users.go
Normal file
27
internal/dao/users.go
Normal 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"
|
||||
)
|
||||
|
||||
// internalUsersDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalUsersDao = *internal.UsersDao
|
||||
|
||||
// usersDao is the data access object for the table users.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type usersDao struct {
|
||||
internalUsersDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Users is a globally accessible object for table users operations.
|
||||
Users = usersDao{
|
||||
internal.NewUsersDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
92
internal/logic/admin/admin.go
Normal file
92
internal/logic/admin/admin.go
Normal file
@ -0,0 +1,92 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/consts"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/model/entity"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
"server/utility/encrypt"
|
||||
"server/utility/jwt"
|
||||
)
|
||||
|
||||
type sAdmin struct{}
|
||||
|
||||
func init() {
|
||||
service.RegisterAdmin(New())
|
||||
}
|
||||
|
||||
func New() service.IAdmin {
|
||||
return &sAdmin{}
|
||||
}
|
||||
|
||||
func (s *sAdmin) Login(ctx context.Context, in *model.AdminLoginIn) (out *model.AdminLoginOut, err error) {
|
||||
admin, err := dao.Admins.Ctx(ctx).Where(dao.Admins.Columns().Username, in.Username).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("database_query_failed")
|
||||
}
|
||||
|
||||
if admin.IsEmpty() {
|
||||
return nil, ecode.Auth
|
||||
}
|
||||
|
||||
if !encrypt.ComparePassword(admin[dao.Admins.Columns().PasswordHash].String(), in.Password) {
|
||||
return nil, ecode.Password
|
||||
}
|
||||
token, err := jwt.GenerateToken(&jwt.TokenIn{
|
||||
Role: consts.AdminRoleCode,
|
||||
UserId: admin[dao.Admins.Columns().Id].Int64(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("token_generation_failed")
|
||||
}
|
||||
return &model.AdminLoginOut{
|
||||
Token: token,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sAdmin) Info(ctx context.Context, in *model.AdminInfoIn) (out *model.AdminInfoOut, err error) {
|
||||
exist, err := dao.Admins.Ctx(ctx).WherePri(in.AdminId).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("admin_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Auth.Sub("admin_not_found")
|
||||
}
|
||||
var admin entity.Admins
|
||||
err = dao.Admins.Ctx(ctx).WherePri(in.AdminId).Scan(&admin)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("admin_query_failed")
|
||||
}
|
||||
return &model.AdminInfoOut{
|
||||
AdminId: admin.Id,
|
||||
Username: admin.Username,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sAdmin) EditPass(ctx context.Context, in *model.AdminEditPassIn) (out *model.AdminEditPassOut, err error) {
|
||||
admin, err := dao.Admins.Ctx(ctx).WherePri(in.AdminId).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("admin_query_failed")
|
||||
}
|
||||
if admin.IsEmpty() {
|
||||
return nil, ecode.Auth.Sub("admin_not_found")
|
||||
}
|
||||
if !encrypt.ComparePassword(admin[dao.Admins.Columns().PasswordHash].String(), in.OldPass) {
|
||||
return nil, ecode.Password.Sub("password_incorrect")
|
||||
}
|
||||
hash, err := encrypt.EncryptPassword(in.NewPass)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("password_encryption_failed")
|
||||
}
|
||||
_, err = dao.Admins.Ctx(ctx).WherePri(in.AdminId).Data(do.Admins{PasswordHash: hash}).Update()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("password_update_failed")
|
||||
}
|
||||
return &model.AdminEditPassOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
138
internal/logic/book/book.go
Normal file
138
internal/logic/book/book.go
Normal file
@ -0,0 +1,138 @@
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sBook struct{}
|
||||
|
||||
func New() service.IBook {
|
||||
return &sBook{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterBook(New())
|
||||
}
|
||||
|
||||
// List retrieves a paginated list of books
|
||||
func (s *sBook) List(ctx context.Context, in *model.BookListIn) (out *model.BookListOut, err error) {
|
||||
out = &model.BookListOut{}
|
||||
m := dao.Books.Ctx(ctx)
|
||||
if in.Title != "" {
|
||||
m = m.Where(dao.Books.Columns().Title+" like ?", "%"+in.Title+"%")
|
||||
}
|
||||
if in.CategoryId != 0 {
|
||||
m = m.Where(dao.Books.Columns().CategoryId, in.CategoryId)
|
||||
}
|
||||
if in.AuthorId != 0 {
|
||||
m = m.Where(dao.Books.Columns().AuthorId, in.AuthorId)
|
||||
}
|
||||
if in.Status != 0 {
|
||||
m = m.Where(dao.Books.Columns().Status, in.Status)
|
||||
}
|
||||
if in.IsRecommended != 0 {
|
||||
m = m.Where(dao.Books.Columns().IsRecommended, in.IsRecommended)
|
||||
}
|
||||
if err = m.Page(in.Page, in.Size).ScanAndCount(&out.List, &out.Total, false); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBook) Create(ctx context.Context, in *model.BookAddIn) (out *model.BookCRUDOut, err error) {
|
||||
exist, err := dao.Books.Ctx(ctx).
|
||||
Where(dao.Books.Columns().Title, in.Title).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("book_query_failed")
|
||||
}
|
||||
if exist {
|
||||
return nil, ecode.Params.Sub("book_exists")
|
||||
}
|
||||
|
||||
if _, err := dao.Books.Ctx(ctx).Data(do.Books{
|
||||
AuthorId: in.AuthorId,
|
||||
CategoryId: in.CategoryId,
|
||||
Title: in.Title,
|
||||
CoverUrl: in.CoverUrl,
|
||||
Description: in.Description,
|
||||
Status: in.Status,
|
||||
Tags: in.Tags,
|
||||
IsRecommended: in.IsRecommended,
|
||||
}).Insert(); err != nil {
|
||||
return nil, ecode.Fail.Sub("book_create_failed")
|
||||
}
|
||||
|
||||
return &model.BookCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sBook) Update(ctx context.Context, in *model.BookEditIn) (out *model.BookCRUDOut, err error) {
|
||||
exist, err := dao.Books.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("book_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("book_not_found")
|
||||
}
|
||||
|
||||
exist, err = dao.Books.Ctx(ctx).
|
||||
Where(dao.Books.Columns().Title, in.Title).
|
||||
Where("id != ?", in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("book_query_failed")
|
||||
}
|
||||
if exist {
|
||||
return nil, ecode.Params.Sub("book_exists")
|
||||
}
|
||||
|
||||
_, err = dao.Books.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Data(do.Books{
|
||||
AuthorId: in.AuthorId,
|
||||
CategoryId: in.CategoryId,
|
||||
Title: in.Title,
|
||||
CoverUrl: in.CoverUrl,
|
||||
Description: in.Description,
|
||||
Status: in.Status,
|
||||
Tags: in.Tags,
|
||||
IsRecommended: in.IsRecommended,
|
||||
}).Update()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("book_update_failed")
|
||||
}
|
||||
|
||||
return &model.BookCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sBook) Delete(ctx context.Context, in *model.BookDelIn) (out *model.BookCRUDOut, err error) {
|
||||
exist, err := dao.Books.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("book_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("book_not_found")
|
||||
}
|
||||
|
||||
_, err = dao.Books.Ctx(ctx).WherePri(in.Id).Delete()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("book_delete_failed")
|
||||
}
|
||||
|
||||
return &model.BookCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
123
internal/logic/category/category.go
Normal file
123
internal/logic/category/category.go
Normal file
@ -0,0 +1,123 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sCategory struct {
|
||||
}
|
||||
|
||||
func New() service.ICategory {
|
||||
return &sCategory{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterCategory(New())
|
||||
}
|
||||
|
||||
// List retrieves a paginated list of categories
|
||||
func (s *sCategory) List(ctx context.Context, in *model.CategoryListIn) (out *model.CategoryListOut, err error) {
|
||||
out = &model.CategoryListOut{}
|
||||
m := dao.Categories.Ctx(ctx)
|
||||
if in.Type != 0 {
|
||||
m = m.Where(dao.Categories.Columns().Type, in.Type)
|
||||
}
|
||||
if err = m.Page(in.Page, in.Size).ScanAndCount(&out.List, &out.Total, false); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sCategory) Create(ctx context.Context, in *model.CategoryAddIn) (out *model.CategoryCRUDOut, err error) {
|
||||
if in.Type != 1 && in.Type != 2 {
|
||||
return nil, ecode.Params.Sub("category_type_invalid")
|
||||
}
|
||||
exist, err := dao.Categories.Ctx(ctx).
|
||||
Where(dao.Categories.Columns().Name, in.Name).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("category_query_failed")
|
||||
}
|
||||
if exist {
|
||||
return nil, ecode.Params.Sub("category_exists")
|
||||
}
|
||||
|
||||
if _, err := dao.Categories.Ctx(ctx).Data(do.Categories{
|
||||
Name: in.Name,
|
||||
Type: in.Type,
|
||||
}).Insert(); err != nil {
|
||||
return nil, ecode.Fail.Sub("category_create_failed")
|
||||
}
|
||||
|
||||
return &model.CategoryCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sCategory) Update(ctx context.Context, in *model.CategoryEditIn) (out *model.CategoryCRUDOut, err error) {
|
||||
if in.Type != 1 && in.Type != 2 {
|
||||
return nil, ecode.Params.Sub("category_type_invalid")
|
||||
}
|
||||
exist, err := dao.Categories.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("category_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("category_not_found")
|
||||
}
|
||||
|
||||
exist, err = dao.Categories.Ctx(ctx).
|
||||
Where(dao.Categories.Columns().Name, in.Name).
|
||||
Where("id != ?", in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("category_query_failed")
|
||||
}
|
||||
if exist {
|
||||
return nil, ecode.Params.Sub("category_exists")
|
||||
}
|
||||
|
||||
// Update category
|
||||
_, err = dao.Categories.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Data(do.Categories{
|
||||
Name: in.Name,
|
||||
Type: in.Type,
|
||||
}).Update()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("category_update_failed")
|
||||
}
|
||||
|
||||
return &model.CategoryCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sCategory) Delete(ctx context.Context, in *model.CategoryDelIn) (out *model.CategoryCRUDOut, err error) {
|
||||
exist, err := dao.Categories.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("category_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("category_not_found")
|
||||
}
|
||||
|
||||
// Soft delete category
|
||||
_, err = dao.Categories.Ctx(ctx).WherePri(in.Id).Delete()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("category_delete_failed")
|
||||
}
|
||||
|
||||
return &model.CategoryCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
98
internal/logic/chapter/chapter.go
Normal file
98
internal/logic/chapter/chapter.go
Normal file
@ -0,0 +1,98 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sChapter struct{}
|
||||
|
||||
func New() service.IChapter {
|
||||
return &sChapter{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterChapter(New())
|
||||
}
|
||||
|
||||
// List retrieves a paginated list of chapters
|
||||
func (s *sChapter) List(ctx context.Context, in *model.ChapterListIn) (out *model.ChapterListOut, err error) {
|
||||
out = &model.ChapterListOut{}
|
||||
m := dao.Chapters.Ctx(ctx)
|
||||
if in.BookId != 0 {
|
||||
m = m.Where(dao.Chapters.Columns().BookId, in.BookId)
|
||||
}
|
||||
if in.Title != "" {
|
||||
m = m.Where(dao.Chapters.Columns().Title+" like ?", "%"+in.Title+"%")
|
||||
}
|
||||
if in.IsLocked != 0 {
|
||||
m = m.Where(dao.Chapters.Columns().IsLocked, in.IsLocked)
|
||||
}
|
||||
if err = m.Page(in.Page, in.Size).ScanAndCount(&out.List, &out.Total, false); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sChapter) Create(ctx context.Context, in *model.ChapterAddIn) (out *model.ChapterCRUDOut, err error) {
|
||||
if _, err := dao.Chapters.Ctx(ctx).Data(do.Chapters{
|
||||
BookId: in.BookId,
|
||||
Title: in.Title,
|
||||
Content: in.Content,
|
||||
WordCount: in.WordCount,
|
||||
Sort: in.Sort,
|
||||
IsLocked: in.IsLocked,
|
||||
RequiredScore: in.RequiredScore,
|
||||
}).Insert(); err != nil {
|
||||
return nil, ecode.Fail.Sub("chapter_create_failed")
|
||||
}
|
||||
return &model.ChapterCRUDOut{Success: true}, nil
|
||||
}
|
||||
|
||||
func (s *sChapter) Update(ctx context.Context, in *model.ChapterEditIn) (out *model.ChapterCRUDOut, err error) {
|
||||
exist, err := dao.Chapters.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("chapter_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("chapter_not_found")
|
||||
}
|
||||
_, err = dao.Chapters.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Data(do.Chapters{
|
||||
BookId: in.BookId,
|
||||
Title: in.Title,
|
||||
Content: in.Content,
|
||||
WordCount: in.WordCount,
|
||||
Sort: in.Sort,
|
||||
IsLocked: in.IsLocked,
|
||||
RequiredScore: in.RequiredScore,
|
||||
}).Update()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("chapter_update_failed")
|
||||
}
|
||||
return &model.ChapterCRUDOut{Success: true}, nil
|
||||
}
|
||||
|
||||
func (s *sChapter) Delete(ctx context.Context, in *model.ChapterDelIn) (out *model.ChapterCRUDOut, err error) {
|
||||
exist, err := dao.Chapters.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("chapter_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("chapter_not_found")
|
||||
}
|
||||
_, err = dao.Chapters.Ctx(ctx).WherePri(in.Id).Delete()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("chapter_delete_failed")
|
||||
}
|
||||
return &model.ChapterCRUDOut{Success: true}, nil
|
||||
}
|
||||
47
internal/logic/feedback/feedback.go
Normal file
47
internal/logic/feedback/feedback.go
Normal file
@ -0,0 +1,47 @@
|
||||
package feedback
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sFeedback struct{}
|
||||
|
||||
func New() service.IFeedback {
|
||||
return &sFeedback{}
|
||||
}
|
||||
func init() {
|
||||
service.RegisterFeedback(New())
|
||||
}
|
||||
|
||||
// List retrieves a paginated list of feedbacks
|
||||
func (s *sFeedback) List(ctx context.Context, in *model.FeedbackListIn) (out *model.FeedbackListOut, err error) {
|
||||
out = &model.FeedbackListOut{}
|
||||
m := dao.Feedbacks.Ctx(ctx)
|
||||
if in.UserId != 0 {
|
||||
m = m.Where(dao.Feedbacks.Columns().UserId, in.UserId)
|
||||
}
|
||||
if in.Status != 0 {
|
||||
m = m.Where(dao.Feedbacks.Columns().Status, in.Status)
|
||||
}
|
||||
if err = m.Page(in.Page, in.Size).ScanAndCount(&out.List, &out.Total, false); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Create adds a new feedback
|
||||
func (s *sFeedback) Create(ctx context.Context, in *model.FeedbackAddIn) (out *model.FeedbackCRUDOut, err error) {
|
||||
if _, err := dao.Feedbacks.Ctx(ctx).Data(do.Feedbacks{
|
||||
UserId: in.UserId,
|
||||
Content: in.Content,
|
||||
Status: 1, // 默认未处理
|
||||
}).Insert(); err != nil {
|
||||
return nil, ecode.Fail.Sub("feedback_create_failed")
|
||||
}
|
||||
return &model.FeedbackCRUDOut{Success: true}, nil
|
||||
}
|
||||
16
internal/logic/logic.go
Normal file
16
internal/logic/logic.go
Normal file
@ -0,0 +1,16 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package logic
|
||||
|
||||
import (
|
||||
_ "server/internal/logic/admin"
|
||||
_ "server/internal/logic/book"
|
||||
_ "server/internal/logic/category"
|
||||
_ "server/internal/logic/chapter"
|
||||
_ "server/internal/logic/feedback"
|
||||
_ "server/internal/logic/read_record"
|
||||
_ "server/internal/logic/tag"
|
||||
_ "server/internal/logic/user"
|
||||
)
|
||||
68
internal/logic/read_record/read_record.go
Normal file
68
internal/logic/read_record/read_record.go
Normal file
@ -0,0 +1,68 @@
|
||||
package read_record
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sReadRecord struct{}
|
||||
|
||||
func New() service.IReadRecord {
|
||||
return &sReadRecord{}
|
||||
}
|
||||
func init() {
|
||||
service.RegisterReadRecord(New())
|
||||
}
|
||||
|
||||
// List retrieves a paginated list of read records
|
||||
func (s *sReadRecord) List(ctx context.Context, in *model.ReadRecordListIn) (out *model.ReadRecordListOut, err error) {
|
||||
out = &model.ReadRecordListOut{}
|
||||
m := dao.ReadRecords.Ctx(ctx)
|
||||
if in.UserId != 0 {
|
||||
m = m.Where(dao.ReadRecords.Columns().UserId, in.UserId)
|
||||
}
|
||||
if in.BookId != 0 {
|
||||
m = m.Where(dao.ReadRecords.Columns().BookId, in.BookId)
|
||||
}
|
||||
if in.ChapterId != 0 {
|
||||
m = m.Where(dao.ReadRecords.Columns().ChapterId, in.ChapterId)
|
||||
}
|
||||
if err = m.Page(in.Page, in.Size).ScanAndCount(&out.List, &out.Total, false); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Create adds a new read record
|
||||
func (s *sReadRecord) Create(ctx context.Context, in *model.ReadRecordAddIn) (out *model.ReadRecordCRUDOut, err error) {
|
||||
if _, err := dao.ReadRecords.Ctx(ctx).Data(do.ReadRecords{
|
||||
UserId: in.UserId,
|
||||
BookId: in.BookId,
|
||||
ChapterId: in.ChapterId,
|
||||
}).Insert(); err != nil {
|
||||
return nil, ecode.Fail.Sub("read_record_create_failed")
|
||||
}
|
||||
return &model.ReadRecordCRUDOut{Success: true}, nil
|
||||
}
|
||||
|
||||
// Delete removes a read record by id
|
||||
func (s *sReadRecord) Delete(ctx context.Context, in *model.ReadRecordDelIn) (out *model.ReadRecordCRUDOut, err error) {
|
||||
exist, err := dao.ReadRecords.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("read_record_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("read_record_not_found")
|
||||
}
|
||||
_, err = dao.ReadRecords.Ctx(ctx).WherePri(in.Id).Delete()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("read_record_delete_failed")
|
||||
}
|
||||
return &model.ReadRecordCRUDOut{Success: true}, nil
|
||||
}
|
||||
119
internal/logic/tag/tag.go
Normal file
119
internal/logic/tag/tag.go
Normal file
@ -0,0 +1,119 @@
|
||||
package tag
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sTag struct{}
|
||||
|
||||
func New() service.ITag {
|
||||
return &sTag{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterTag(New())
|
||||
}
|
||||
|
||||
// List retrieves a paginated list of tags
|
||||
func (s *sTag) List(ctx context.Context, in *model.TagListIn) (out *model.TagListOut, err error) {
|
||||
out = &model.TagListOut{}
|
||||
m := dao.Tags.Ctx(ctx)
|
||||
if in.Name != "" {
|
||||
m = m.Where(dao.Tags.Columns().Name+" like ?", "%"+in.Name+"%")
|
||||
}
|
||||
if in.Type != 0 {
|
||||
m = m.Where(dao.Tags.Columns().Type, in.Type)
|
||||
}
|
||||
if err = m.Page(in.Page, in.Size).ScanAndCount(&out.List, &out.Total, false); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sTag) Create(ctx context.Context, in *model.TagAddIn) (out *model.TagCRUDOut, err error) {
|
||||
exist, err := dao.Tags.Ctx(ctx).
|
||||
Where(dao.Tags.Columns().Name, in.Name).
|
||||
Where(dao.Tags.Columns().Type, in.Type).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("tag_query_failed")
|
||||
}
|
||||
if exist {
|
||||
return nil, ecode.Params.Sub("tag_exists")
|
||||
}
|
||||
|
||||
if _, err := dao.Tags.Ctx(ctx).Data(do.Tags{
|
||||
Name: in.Name,
|
||||
Type: in.Type,
|
||||
}).Insert(); err != nil {
|
||||
return nil, ecode.Fail.Sub("tag_create_failed")
|
||||
}
|
||||
|
||||
return &model.TagCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sTag) Update(ctx context.Context, in *model.TagEditIn) (out *model.TagCRUDOut, err error) {
|
||||
exist, err := dao.Tags.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("tag_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("tag_not_found")
|
||||
}
|
||||
|
||||
exist, err = dao.Tags.Ctx(ctx).
|
||||
Where(dao.Tags.Columns().Name, in.Name).
|
||||
Where(dao.Tags.Columns().Type, in.Type).
|
||||
Where("id != ?", in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("tag_query_failed")
|
||||
}
|
||||
if exist {
|
||||
return nil, ecode.Params.Sub("tag_exists")
|
||||
}
|
||||
|
||||
_, err = dao.Tags.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Data(do.Tags{
|
||||
Name: in.Name,
|
||||
Type: in.Type,
|
||||
}).Update()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("tag_update_failed")
|
||||
}
|
||||
|
||||
return &model.TagCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sTag) Delete(ctx context.Context, in *model.TagDelIn) (out *model.TagCRUDOut, err error) {
|
||||
exist, err := dao.Tags.Ctx(ctx).
|
||||
WherePri(in.Id).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("tag_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.NotFound.Sub("tag_not_found")
|
||||
}
|
||||
|
||||
_, err = dao.Tags.Ctx(ctx).WherePri(in.Id).Delete()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("tag_delete_failed")
|
||||
}
|
||||
|
||||
return &model.TagCRUDOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
136
internal/logic/user/user.go
Normal file
136
internal/logic/user/user.go
Normal file
@ -0,0 +1,136 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/model/entity"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
"server/utility/encrypt"
|
||||
"server/utility/jwt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type sUser struct{}
|
||||
|
||||
func New() service.IUser {
|
||||
return &sUser{}
|
||||
}
|
||||
func init() {
|
||||
service.RegisterUser(New())
|
||||
}
|
||||
|
||||
func (s *sUser) Login(ctx context.Context, in *model.UserLoginIn) (out *model.UserLoginOut, err error) {
|
||||
user, err := dao.Users.Ctx(ctx).Where(do.Users{Email: in.Email}).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("database_query_failed")
|
||||
}
|
||||
if user == nil {
|
||||
return nil, ecode.Auth // 账户名或密码不正确
|
||||
}
|
||||
var entityUser entity.Users
|
||||
if err = user.Struct(&entityUser); err != nil {
|
||||
return nil, ecode.Fail.Sub("data_conversion_failed")
|
||||
}
|
||||
if !encrypt.ComparePassword(entityUser.PasswordHash, in.Password) {
|
||||
return nil, ecode.Password // 密码不正确
|
||||
}
|
||||
token, err := jwt.GenerateToken(&jwt.TokenIn{UserId: entityUser.Id, Role: "user"})
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("token_generation_failed")
|
||||
}
|
||||
return &model.UserLoginOut{Token: token}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) Register(ctx context.Context, in *model.UserRegisterIn) (out *model.UserRegisterOut, err error) {
|
||||
if in.Password != in.Password2 {
|
||||
return nil, ecode.Password.Sub("password_mismatch")
|
||||
}
|
||||
exist, err := dao.Users.Ctx(ctx).Where(do.Users{Email: in.Email}).Count()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("database_query_failed")
|
||||
}
|
||||
if exist > 0 {
|
||||
return nil, ecode.EmailExist // 该邮箱已被注册
|
||||
}
|
||||
hash, err := encrypt.EncryptPassword(in.Password)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("password_encryption_failed")
|
||||
}
|
||||
_, err = dao.Users.Ctx(ctx).Data(do.Users{
|
||||
Email: in.Email,
|
||||
PasswordHash: hash,
|
||||
Username: strings.Split(in.Email, "@")[0],
|
||||
}).Insert()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("registration_failed")
|
||||
}
|
||||
return &model.UserRegisterOut{Success: true}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) Info(ctx context.Context, in *model.UserInfoIn) (out *model.UserInfoOut, err error) {
|
||||
user, err := dao.Users.Ctx(ctx).Where(do.Users{Id: in.UserId}).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("database_query_failed")
|
||||
}
|
||||
if user == nil {
|
||||
return nil, ecode.Auth.Sub("user_not_found")
|
||||
}
|
||||
var entityUser entity.Users
|
||||
if err = user.Struct(&entityUser); err != nil {
|
||||
return nil, ecode.Fail.Sub("data_conversion_failed")
|
||||
}
|
||||
return &model.UserInfoOut{
|
||||
UserId: entityUser.Id,
|
||||
Username: entityUser.Username,
|
||||
Email: entityUser.Email,
|
||||
Avatar: entityUser.Avatar,
|
||||
Points: entityUser.Points, // 如有积分表可补充
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) Delete(ctx context.Context, in *model.UserDeleteIn) (out *model.UserDeleteOut, err error) {
|
||||
// FIXME
|
||||
|
||||
return &model.UserDeleteOut{Success: true}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) Code(ctx context.Context, in *model.UserCodeIn) (out *model.UserCodeOut, err error) {
|
||||
exist, err := dao.Users.Ctx(ctx).Where(do.Users{Email: in.Email}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("database_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("email_not_found")
|
||||
}
|
||||
return &model.UserCodeOut{Success: true}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) EditPass(ctx context.Context, in *model.UserEditPassIn) (out *model.UserEditPassOut, err error) {
|
||||
exist, err := dao.Users.Ctx(ctx).Where(do.Users{Email: in.Email}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("database_query_failed")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("email_not_found")
|
||||
}
|
||||
if in.Sign != "123456" {
|
||||
return nil, ecode.Params.Sub("sign_error")
|
||||
}
|
||||
if in.Password != in.Password2 {
|
||||
return nil, ecode.Password.Sub("password_mismatch")
|
||||
}
|
||||
hash, err := encrypt.EncryptPassword(in.Password)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("password_encryption_failed")
|
||||
}
|
||||
_, err = dao.Users.Ctx(ctx).Where(do.Users{Email: in.Email}).Data(do.Users{PasswordHash: hash}).Update()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("password_update_failed")
|
||||
}
|
||||
return &model.UserEditPassOut{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user