package book import ( "context" v1 "server/api/book/v1" "server/internal/model" "server/internal/service" "github.com/gogf/gf/v2/frame/g" ) func (c *ControllerV1) AppDetail(ctx context.Context, req *v1.AppDetailReq) (res *v1.AppDetailRes, err error) { // 从 ctx 获取用户ID userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64() out, err := service.Book().AppDetail(ctx, &model.BookAppDetailIn{ Id: req.Id, UserId: userId, }) if err != nil { return nil, err } return &v1.AppDetailRes{ Id: out.Id, AuthorId: out.AuthorId, CategoryId: out.CategoryId, Title: out.Title, CoverUrl: out.CoverUrl, Description: out.Description, Status: out.Status, 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, }, nil }