书籍列表接口新增参数
This commit is contained in:
@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user