书籍列表接口新增参数
This commit is contained in:
5
internal/controller/activity/activity.go
Normal file
5
internal/controller/activity/activity.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package activity
|
||||
15
internal/controller/activity/activity_new.go
Normal file
15
internal/controller/activity/activity_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 activity
|
||||
|
||||
import (
|
||||
"server/api/activity"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() activity.IActivityV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
23
internal/controller/activity/activity_v1_item_add.go
Normal file
23
internal/controller/activity/activity_v1_item_add.go
Normal file
@ -0,0 +1,23 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/activity/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ItemAdd(ctx context.Context, req *v1.ItemAddReq) (res *v1.ItemAddRes, err error) {
|
||||
id, err := service.SignInRewardDetails().Create(ctx, &model.SignInRewardDetail{
|
||||
RuleId: req.RuleId,
|
||||
DayNumber: req.DayNumber,
|
||||
RewardType: req.RewardType,
|
||||
Quantity: req.Quantity,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ItemAddRes{Id: id, Success: true}, nil
|
||||
}
|
||||
17
internal/controller/activity/activity_v1_item_del.go
Normal file
17
internal/controller/activity/activity_v1_item_del.go
Normal file
@ -0,0 +1,17 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/activity/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ItemDel(ctx context.Context, req *v1.ItemDelReq) (res *v1.ItemDelRes, err error) {
|
||||
out, err := service.SignInRewardDetails().Delete(ctx, &model.SignInRewardDetailDeleteIn{Id: req.Id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ItemDelRes{Success: out.Success}, nil
|
||||
}
|
||||
24
internal/controller/activity/activity_v1_item_edit.go
Normal file
24
internal/controller/activity/activity_v1_item_edit.go
Normal file
@ -0,0 +1,24 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/activity/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ItemEdit(ctx context.Context, req *v1.ItemEditReq) (res *v1.ItemEditRes, err error) {
|
||||
err = service.SignInRewardDetails().Update(ctx, &model.SignInRewardDetail{
|
||||
Id: req.Id,
|
||||
RuleId: req.RuleId,
|
||||
DayNumber: req.DayNumber,
|
||||
RewardType: req.RewardType,
|
||||
Quantity: req.Quantity,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ItemEditRes{Success: true}, nil
|
||||
}
|
||||
17
internal/controller/activity/activity_v1_item_get.go
Normal file
17
internal/controller/activity/activity_v1_item_get.go
Normal file
@ -0,0 +1,17 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/activity/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ItemGet(ctx context.Context, req *v1.ItemGetReq) (res *v1.ItemGetRes, err error) {
|
||||
out, err := service.SignInRewardDetails().Get(ctx, &model.SignInRewardDetailGetIn{Id: req.Id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ItemGetRes{SignInRewardDetail: out.SignInRewardDetail}, nil
|
||||
}
|
||||
20
internal/controller/activity/activity_v1_item_list.go
Normal file
20
internal/controller/activity/activity_v1_item_list.go
Normal file
@ -0,0 +1,20 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "server/api/activity/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ItemList(ctx context.Context, req *v1.ItemListReq) (res *v1.ItemListRes, err error) {
|
||||
out, err := service.SignInRewardDetails().List(ctx, &model.SignInRewardDetailListIn{
|
||||
RuleId: req.RuleId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ItemListRes{
|
||||
List: out.List,
|
||||
}, nil
|
||||
}
|
||||
19
internal/controller/activity/activity_v1_item_set_status.go
Normal file
19
internal/controller/activity/activity_v1_item_set_status.go
Normal file
@ -0,0 +1,19 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "server/api/activity/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ItemSetStatus(ctx context.Context, req *v1.ItemSetStatusReq) (res *v1.ItemSetStatusRes, err error) {
|
||||
out, err := service.SignInRewardDetails().SetStatus(ctx, &model.SignInRewardDetailSetStatusIn{
|
||||
Id: req.Id,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ItemSetStatusRes{Success: out.Success}, nil
|
||||
}
|
||||
23
internal/controller/activity/activity_v1_rule_add.go
Normal file
23
internal/controller/activity/activity_v1_rule_add.go
Normal file
@ -0,0 +1,23 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/activity/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) RuleAdd(ctx context.Context, req *v1.RuleAddReq) (res *v1.RuleAddRes, err error) {
|
||||
out, err := service.SignInRewardRules().Create(ctx, &model.SignInRewardRulesCreateIn{
|
||||
RuleName: req.RuleName,
|
||||
StartDate: req.StartDate,
|
||||
EndDate: req.EndDate,
|
||||
CycleDays: req.CycleDays,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.RuleAddRes{Success: out.Success}, nil
|
||||
}
|
||||
19
internal/controller/activity/activity_v1_rule_del.go
Normal file
19
internal/controller/activity/activity_v1_rule_del.go
Normal file
@ -0,0 +1,19 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/activity/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) RuleDel(ctx context.Context, req *v1.RuleDelReq) (res *v1.RuleDelRes, err error) {
|
||||
out, err := service.SignInRewardRules().Delete(ctx, &model.SignInRewardRulesDeleteIn{
|
||||
Id: req.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.RuleDelRes{Success: out.Success}, nil
|
||||
}
|
||||
24
internal/controller/activity/activity_v1_rule_edit.go
Normal file
24
internal/controller/activity/activity_v1_rule_edit.go
Normal file
@ -0,0 +1,24 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/activity/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) RuleEdit(ctx context.Context, req *v1.RuleEditReq) (res *v1.RuleEditRes, err error) {
|
||||
out, err := service.SignInRewardRules().Update(ctx, &model.SignInRewardRulesUpdateIn{
|
||||
Id: req.Id,
|
||||
RuleName: req.RuleName,
|
||||
CycleDays: req.CycleDays,
|
||||
StartDate: req.StartDate,
|
||||
EndDate: req.EndDate,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.RuleEditRes{Success: out.Success}, nil
|
||||
}
|
||||
25
internal/controller/activity/activity_v1_rule_list.go
Normal file
25
internal/controller/activity/activity_v1_rule_list.go
Normal file
@ -0,0 +1,25 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/activity/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) RuleList(ctx context.Context, req *v1.RuleListReq) (res *v1.RuleListRes, err error) {
|
||||
out, err := service.SignInRewardRules().List(ctx, &model.SignInRewardRulesListIn{
|
||||
Page: req.Page,
|
||||
RuleName: req.RuleName,
|
||||
Size: req.Size,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.RuleListRes{
|
||||
Total: out.Total,
|
||||
List: out.List,
|
||||
}, nil
|
||||
}
|
||||
20
internal/controller/activity/activity_v1_rule_set_status.go
Normal file
20
internal/controller/activity/activity_v1_rule_set_status.go
Normal file
@ -0,0 +1,20 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/activity/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) RuleSetStatus(ctx context.Context, req *v1.RuleSetStatusReq) (res *v1.RuleSetStatusRes, err error) {
|
||||
out, err := service.SignInRewardRules().SetStatus(ctx, &model.SignInRewardRulesSetStatusIn{
|
||||
Id: req.Id,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.RuleSetStatusRes{Success: out.Success}, nil
|
||||
}
|
||||
26
internal/controller/activity/activity_v1_sign_in.go
Normal file
26
internal/controller/activity/activity_v1_sign_in.go
Normal file
@ -0,0 +1,26 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "server/api/activity/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) SignIn(ctx context.Context, req *v1.SignInReq) (res *v1.SignInRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
in := &model.UserSignInLogSignIn{
|
||||
UserId: userId,
|
||||
RuleId: req.RuleId,
|
||||
RewardDetailId: req.RewardDetailId,
|
||||
SignInDate: gtime.Now(), // 或根据 req.SignInDate 解析
|
||||
}
|
||||
out, err := service.UserSignInLogs().Sign(ctx, in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.SignInRes{Success: out.Success}, nil
|
||||
}
|
||||
24
internal/controller/activity/activity_v1_sign_in_list.go
Normal file
24
internal/controller/activity/activity_v1_sign_in_list.go
Normal file
@ -0,0 +1,24 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/activity/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) SignInList(ctx context.Context, req *v1.SignInListReq) (res *v1.SignInListRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.SignInRewardRules().SignInList(ctx, &model.SignInListIn{
|
||||
UserId: userId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &v1.SignInListRes{
|
||||
List: out.List,
|
||||
}
|
||||
return &v1.SignInListRes{List: out.List}, nil
|
||||
}
|
||||
@ -2,11 +2,12 @@ package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/admin/v1"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
v1 "server/api/admin/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoRes, err error) {
|
||||
@ -17,7 +18,8 @@ func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoR
|
||||
return nil, err
|
||||
}
|
||||
return &v1.InfoRes{
|
||||
AdminId: out.AdminId,
|
||||
Id: out.Id,
|
||||
Username: out.Username,
|
||||
Role: out.Role,
|
||||
}, nil
|
||||
}
|
||||
|
||||
5
internal/controller/ads/ads.go
Normal file
5
internal/controller/ads/ads.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package ads
|
||||
15
internal/controller/ads/ads_new.go
Normal file
15
internal/controller/ads/ads_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 ads
|
||||
|
||||
import (
|
||||
"server/api/ads"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() ads.IAdsV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
27
internal/controller/ads/ads_v1_upload.go
Normal file
27
internal/controller/ads/ads_v1_upload.go
Normal file
@ -0,0 +1,27 @@
|
||||
package ads
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
v1 "server/api/ads/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Upload(ctx context.Context, req *v1.UploadReq) (res *v1.UploadRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Ads().Upload(ctx, &model.AdsUploadIn{
|
||||
UserId: userId,
|
||||
NodeUid: req.NodeUid,
|
||||
DeviceCode: req.DeviceCode,
|
||||
Data: req.Data,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UploadRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_author_login.go
Normal file
17
internal/controller/auth/auth_v1_author_login.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/auth/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AuthorLogin(ctx context.Context, req *v1.AuthorLoginReq) (res *v1.AuthorLoginRes, err error) {
|
||||
out, err := service.User().AuthorLogin(ctx, &model.UserLoginIn{Email: req.Email, Password: req.Password})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AuthorLoginRes{Token: out.Token}, nil
|
||||
}
|
||||
@ -5,7 +5,7 @@ import (
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
v1 "server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserLogin(ctx context.Context, req *v1.UserLoginReq) (res *v1.UserLoginRes, err error) {
|
||||
|
||||
23
internal/controller/author/author_v1_apply.go
Normal file
23
internal/controller/author/author_v1_apply.go
Normal file
@ -0,0 +1,23 @@
|
||||
package author
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/author/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Apply(ctx context.Context, req *v1.ApplyReq) (res *v1.ApplyRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Author().Apply(ctx, &model.AuthorApplyIn{
|
||||
UserId: userId,
|
||||
PenName: req.PenName,
|
||||
Bio: req.Bio,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ApplyRes{Success: out.Success, Msg: "Please wait patiently for the management review"}, nil
|
||||
}
|
||||
23
internal/controller/author/author_v1_author_info.go
Normal file
23
internal/controller/author/author_v1_author_info.go
Normal file
@ -0,0 +1,23 @@
|
||||
package author
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/author/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AuthorInfo(ctx context.Context, req *v1.AuthorInfoReq) (res *v1.AuthorInfoRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Author().AuthorInfo(ctx, &model.AuthorInfoIn{UserId: userId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AuthorInfoRes{
|
||||
Id: out.Id,
|
||||
PenName: out.PenName,
|
||||
Role: out.Role,
|
||||
}, nil
|
||||
}
|
||||
@ -13,5 +13,5 @@ func (c *ControllerV1) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.D
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DetailRes{Author: out}, nil
|
||||
return &v1.DetailRes{out}, nil
|
||||
}
|
||||
|
||||
21
internal/controller/author/author_v1_review.go
Normal file
21
internal/controller/author/author_v1_review.go
Normal file
@ -0,0 +1,21 @@
|
||||
package author
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/author/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Review(ctx context.Context, req *v1.ReviewReq) (res *v1.ReviewRes, err error) {
|
||||
out, err := service.Author().Review(ctx, &model.AuthorReviewIn{
|
||||
AuthorId: req.AuthorId,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ReviewRes{Success: out.Success}, nil
|
||||
}
|
||||
@ -23,22 +23,29 @@ func (c *ControllerV1) AppDetail(ctx context.Context, req *v1.AppDetailReq) (res
|
||||
|
||||
return &v1.AppDetailRes{
|
||||
Id: out.Id,
|
||||
AuthorId: out.AuthorId,
|
||||
CategoryId: out.CategoryId,
|
||||
Title: out.Title,
|
||||
CoverUrl: out.CoverUrl,
|
||||
Rating: out.Rating,
|
||||
Title: out.Title,
|
||||
Description: out.Description,
|
||||
AuthorId: out.AuthorId,
|
||||
Author: out.Author,
|
||||
CategoryId: out.CategoryId,
|
||||
Category: out.Category,
|
||||
Status: out.Status,
|
||||
WordsCount: out.WordsCount,
|
||||
ChaptersCount: out.ChaptersCount,
|
||||
ReadCount: out.ReadCount,
|
||||
CurrentReaders: out.CurrentReaders,
|
||||
Tags: out.Tags,
|
||||
IsRecommended: out.IsRecommended,
|
||||
Rating: out.Rating,
|
||||
CurrentReaders: out.CurrentReaders,
|
||||
CreatedAt: out.CreatedAt.String(),
|
||||
UpdatedAt: out.UpdatedAt.String(),
|
||||
// 添加阅读进度信息
|
||||
HasRead: out.HasRead,
|
||||
ReadProgress: out.ReadProgress,
|
||||
LastChapterId: out.LastChapterId,
|
||||
LastReadAt: out.LastReadAt,
|
||||
HasRated: out.HasRated,
|
||||
MyRating: out.MyRating,
|
||||
HasRead: out.HasRead,
|
||||
ReadProgress: out.ReadProgress,
|
||||
LastChapterId: out.LastChapterId,
|
||||
LastReadAt: out.LastReadAt,
|
||||
IsInBookshelf: out.IsInBookshelf,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ func (c *ControllerV1) AppList(ctx context.Context, req *v1.AppListReq) (res *v1
|
||||
IsRecommended: req.IsRecommended,
|
||||
IsFeatured: req.IsFeatured,
|
||||
IsLatest: req.IsLatest,
|
||||
IsHot: req.IsHot,
|
||||
CategoryId: req.CategoryId,
|
||||
Title: req.Title,
|
||||
AuthorId: req.AuthorId,
|
||||
|
||||
24
internal/controller/book/book_v1_book_cover_image.go
Normal file
24
internal/controller/book/book_v1_book_cover_image.go
Normal file
@ -0,0 +1,24 @@
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/book/v1"
|
||||
|
||||
"server/utility/ecode"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BookCoverImage(ctx context.Context, req *v1.BookCoverImageReq) (res *v1.BookCoverImageRes, err error) {
|
||||
if req.File == nil {
|
||||
return nil, gerror.NewCode(ecode.Fail.Sub("image_file_required").Code())
|
||||
}
|
||||
image, err := service.Upload().UploadImage(ctx, &model.UploadImageIn{File: req.File, Type: "book"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BookCoverImageRes{ImageUrl: image.ImageUrl}, nil
|
||||
}
|
||||
@ -3,12 +3,15 @@ package book
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
|
||||
"server/api/book/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BookSetFeatured(ctx context.Context, req *v1.BookSetFeaturedReq) (res *v1.BookSetFeaturedRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
out, err := service.Book().SetFeatured(ctx, &model.BookSetFeaturedIn{Id: req.Id, IsFeatured: req.IsFeatured})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BookSetFeaturedRes{Success: out.Success}, nil
|
||||
}
|
||||
|
||||
22
internal/controller/book/book_v1_book_set_hot.go
Normal file
22
internal/controller/book/book_v1_book_set_hot.go
Normal file
@ -0,0 +1,22 @@
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/book/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BookSetHot(ctx context.Context, req *v1.BookSetHotReq) (res *v1.BookSetHotRes, err error) {
|
||||
out, err := service.Book().SetHot(ctx, &model.BookSetHotIn{
|
||||
Id: req.Id,
|
||||
IsHot: req.IsHot,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BookSetHotRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
@ -2,13 +2,16 @@ package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/book/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) BookSetRecommended(ctx context.Context, req *v1.BookSetRecommendedReq) (res *v1.BookSetRecommendedRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
out, err := service.Book().SetRecommended(ctx, &model.BookSetRecommendedIn{Id: req.Id, IsRecommended: req.IsRecommended})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.BookSetRecommendedRes{Success: out.Success}, nil
|
||||
}
|
||||
|
||||
21
internal/controller/book/book_v1_history_remove.go
Normal file
21
internal/controller/book/book_v1_history_remove.go
Normal file
@ -0,0 +1,21 @@
|
||||
package book
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/book/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) HistoryRemove(ctx context.Context, req *v1.HistoryRemoveReq) (res *v1.HistoryRemoveRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.UserReadHistory().Remove(ctx, &model.UserReadHistoryDelIn{BookIds: req.BookIds, UserId: userId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.HistoryRemoveRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
@ -11,11 +11,10 @@ import (
|
||||
|
||||
func (c *ControllerV1) AppProgress(ctx context.Context, req *v1.AppProgressReq) (res *v1.AppProgressRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Chapter().AppProgress(ctx, &model.ChapterAppProgressIn{
|
||||
BookId: req.BookId,
|
||||
ChapterId: req.ChapterId,
|
||||
Progress: req.Progress,
|
||||
UserId: userId,
|
||||
out, err := service.Chapter().AppBatchProgress(ctx, &model.ChapterAppBatchProgressIn{
|
||||
BookId: req.BookId,
|
||||
Chapters: req.Chapters,
|
||||
UserId: userId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
5
internal/controller/recommend/recommend.go
Normal file
5
internal/controller/recommend/recommend.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package recommend
|
||||
15
internal/controller/recommend/recommend_new.go
Normal file
15
internal/controller/recommend/recommend_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 recommend
|
||||
|
||||
import (
|
||||
"server/api/recommend"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() recommend.IRecommendV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
23
internal/controller/recommend/recommend_v1_add.go
Normal file
23
internal/controller/recommend/recommend_v1_add.go
Normal file
@ -0,0 +1,23 @@
|
||||
package recommend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/recommend/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) {
|
||||
out, err := service.BookRecommendations().Create(ctx, &model.BookRecommendationsCreateIn{
|
||||
BookId: req.BookId,
|
||||
Type: req.Type,
|
||||
CoverUrl: req.CoverUrl,
|
||||
SortOrder: req.SortOrder,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AddRes{Success: out.Success}, nil
|
||||
}
|
||||
35
internal/controller/recommend/recommend_v1_app_list.go
Normal file
35
internal/controller/recommend/recommend_v1_app_list.go
Normal file
@ -0,0 +1,35 @@
|
||||
package recommend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/recommend/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error) {
|
||||
out, err := service.BookRecommendations().AppList(ctx, &model.BookRecommendationsListIn{
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Type: req.Type,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 转换为 RecommendAppItem
|
||||
list := make([]model.RecommendAppItem, 0, len(out.List))
|
||||
for _, item := range out.List {
|
||||
list = append(list, model.RecommendAppItem{
|
||||
Id: item.Id,
|
||||
BookId: item.BookId,
|
||||
CoverUrl: item.CoverUrl,
|
||||
SortOrder: item.SortOrder,
|
||||
})
|
||||
}
|
||||
return &v1.AppListRes{
|
||||
Total: out.Total,
|
||||
List: list,
|
||||
}, nil
|
||||
}
|
||||
19
internal/controller/recommend/recommend_v1_del.go
Normal file
19
internal/controller/recommend/recommend_v1_del.go
Normal file
@ -0,0 +1,19 @@
|
||||
package recommend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/recommend/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) {
|
||||
out, err := service.BookRecommendations().Delete(ctx, &model.BookRecommendationsDeleteIn{
|
||||
Id: req.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DelRes{Success: out.Success}, nil
|
||||
}
|
||||
24
internal/controller/recommend/recommend_v1_edit.go
Normal file
24
internal/controller/recommend/recommend_v1_edit.go
Normal file
@ -0,0 +1,24 @@
|
||||
package recommend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/recommend/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Edit(ctx context.Context, req *v1.EditReq) (res *v1.EditRes, err error) {
|
||||
out, err := service.BookRecommendations().Update(ctx, &model.BookRecommendationsUpdateIn{
|
||||
Id: req.Id,
|
||||
BookId: req.BookId,
|
||||
Type: req.Type,
|
||||
CoverUrl: req.CoverUrl,
|
||||
SortOrder: req.SortOrder,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.EditRes{Success: out.Success}, nil
|
||||
}
|
||||
26
internal/controller/recommend/recommend_v1_list.go
Normal file
26
internal/controller/recommend/recommend_v1_list.go
Normal file
@ -0,0 +1,26 @@
|
||||
package recommend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/recommend/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
|
||||
out, err := service.BookRecommendations().List(ctx, &model.BookRecommendationsListIn{
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Type: req.Type,
|
||||
Status: req.Status,
|
||||
BookId: req.BookId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ListRes{
|
||||
Total: out.Total,
|
||||
List: out.List,
|
||||
}, nil
|
||||
}
|
||||
20
internal/controller/recommend/recommend_v1_set_status.go
Normal file
20
internal/controller/recommend/recommend_v1_set_status.go
Normal file
@ -0,0 +1,20 @@
|
||||
package recommend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/recommend/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) SetStatus(ctx context.Context, req *v1.SetStatusReq) (res *v1.SetStatusRes, err error) {
|
||||
out, err := service.BookRecommendations().SetStatus(ctx, &model.BookRecommendationsSetStatusIn{
|
||||
Id: req.Id,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.SetStatusRes{Success: out.Success}, nil
|
||||
}
|
||||
20
internal/controller/recommend/recommend_v1_sort_order.go
Normal file
20
internal/controller/recommend/recommend_v1_sort_order.go
Normal file
@ -0,0 +1,20 @@
|
||||
package recommend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/recommend/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) SortOrder(ctx context.Context, req *v1.SortOrderReq) (res *v1.SortOrderRes, err error) {
|
||||
out, err := service.BookRecommendations().SortOrder(ctx, &model.BookRecommendationsSortOrderIn{
|
||||
Id: req.Id,
|
||||
SortOrder: req.SortOrder,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.SortOrderRes{Success: out.Success}, nil
|
||||
}
|
||||
16
internal/controller/recommend/recommend_v1_upload_cover.go
Normal file
16
internal/controller/recommend/recommend_v1_upload_cover.go
Normal file
@ -0,0 +1,16 @@
|
||||
package recommend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/recommend/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UploadCover(ctx context.Context, req *v1.UploadCoverReq) (res *v1.UploadCoverRes, err error) {
|
||||
url, err := service.BookRecommendations().UploadCover(ctx, req.File)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UploadCoverRes{Url: url}, nil
|
||||
}
|
||||
5
internal/controller/system/system.go
Normal file
5
internal/controller/system/system.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package system
|
||||
15
internal/controller/system/system_new.go
Normal file
15
internal/controller/system/system_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 system
|
||||
|
||||
import (
|
||||
"server/api/system"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() system.ISystemV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
16
internal/controller/system/system_v1_system_save.go
Normal file
16
internal/controller/system/system_v1_system_save.go
Normal file
@ -0,0 +1,16 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/system/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) SystemSave(ctx context.Context, req *v1.SystemSaveReq) (res *v1.SystemSaveRes, err error) {
|
||||
return nil, service.System().Save(ctx, &model.SystemSaveInput{
|
||||
Key: req.Key,
|
||||
Value: req.Value,
|
||||
})
|
||||
}
|
||||
16
internal/controller/system/system_v1_system_version.go
Normal file
16
internal/controller/system/system_v1_system_version.go
Normal file
@ -0,0 +1,16 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/system/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) SystemVersion(ctx context.Context, req *v1.SystemVersionReq) (res *v1.SystemVersionRes, err error) {
|
||||
version, err := service.System().Version(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.SystemVersionRes{Ios: version.Ios, Android: version.Android}, nil
|
||||
}
|
||||
5
internal/controller/task/task.go
Normal file
5
internal/controller/task/task.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package task
|
||||
15
internal/controller/task/task_new.go
Normal file
15
internal/controller/task/task_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 task
|
||||
|
||||
import (
|
||||
"server/api/task"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() task.ITaskV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
23
internal/controller/task/task_v1_add.go
Normal file
23
internal/controller/task/task_v1_add.go
Normal file
@ -0,0 +1,23 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/task/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) {
|
||||
out, err := service.Task().Add(ctx, &model.TaskAddIn{
|
||||
TaskType: req.TaskType,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
RewardPoints: req.RewardPoints,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AddRes{Success: out.Success}, nil
|
||||
}
|
||||
19
internal/controller/task/task_v1_app_list.go
Normal file
19
internal/controller/task/task_v1_app_list.go
Normal file
@ -0,0 +1,19 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/task/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error) {
|
||||
out, err := service.Task().AppList(ctx, &model.TaskAppListIn{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AppListRes{
|
||||
List: out.List,
|
||||
}, nil
|
||||
}
|
||||
17
internal/controller/task/task_v1_del.go
Normal file
17
internal/controller/task/task_v1_del.go
Normal file
@ -0,0 +1,17 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/task/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) {
|
||||
out, err := service.Task().Delete(ctx, &model.TaskDelIn{Id: req.Id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DelRes{Success: out.Success}, nil
|
||||
}
|
||||
24
internal/controller/task/task_v1_edit.go
Normal file
24
internal/controller/task/task_v1_edit.go
Normal file
@ -0,0 +1,24 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/task/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Edit(ctx context.Context, req *v1.EditReq) (res *v1.EditRes, err error) {
|
||||
out, err := service.Task().Edit(ctx, &model.TaskEditIn{
|
||||
Id: req.Id,
|
||||
TaskType: req.TaskType,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
RewardPoints: req.RewardPoints,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.EditRes{Success: out.Success}, nil
|
||||
}
|
||||
25
internal/controller/task/task_v1_list.go
Normal file
25
internal/controller/task/task_v1_list.go
Normal file
@ -0,0 +1,25 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "server/api/task/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
|
||||
out, err := service.Task().List(ctx, &model.TaskListIn{
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Title: req.Title,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ListRes{
|
||||
Total: out.Total,
|
||||
List: out.List,
|
||||
}, nil
|
||||
}
|
||||
@ -23,10 +23,14 @@ func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoR
|
||||
}
|
||||
|
||||
return &v1.InfoRes{
|
||||
UserId: out.UserId,
|
||||
Username: out.Username,
|
||||
Avatar: out.Avatar,
|
||||
Email: out.Email,
|
||||
Points: out.Points,
|
||||
Id: out.Id,
|
||||
Username: out.Username,
|
||||
Avatar: out.Avatar,
|
||||
Email: out.Email,
|
||||
Points: out.Points,
|
||||
BackgroundUrl: out.BackgroundUrl,
|
||||
AttentionCount: out.AttentionCount,
|
||||
IsAuthor: out.IsAuthor,
|
||||
AuthorStatus: out.AuthorStatus,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -2,13 +2,15 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"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)
|
||||
g.Redis().Do(ctx, "SETEX", fmt.Sprintf("blacklist:%s", g.RequestFromCtx(ctx).GetCtxVar("jti").String()), "1")
|
||||
return &v1.LogoutRes{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user