完善功能
This commit is contained in:
@ -8,7 +8,7 @@ import (
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterAdd(ctx context.Context, req *v1.ChapterAddReq) (res *v1.ChapterAddRes, err error) {
|
||||
func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) {
|
||||
out, err := service.Chapter().Create(ctx, &model.ChapterAddIn{
|
||||
BookId: req.BookId,
|
||||
Content: req.Content,
|
||||
@ -21,7 +21,7 @@ func (c *ControllerV1) ChapterAdd(ctx context.Context, req *v1.ChapterAddReq) (r
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterAddRes{
|
||||
return &v1.AddRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
29
internal/controller/chapter/chapter_v1_app_detail.go
Normal file
29
internal/controller/chapter/chapter_v1_app_detail.go
Normal file
@ -0,0 +1,29 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "server/api/chapter/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AppDetail(ctx context.Context, req *v1.AppDetailReq) (res *v1.AppDetailRes, err error) {
|
||||
out, err := service.Chapter().AppDetail(ctx, &model.ChapterAppDetailIn{
|
||||
Id: req.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.AppDetailRes{
|
||||
Id: out.Id,
|
||||
BookId: out.BookId,
|
||||
Title: out.Title,
|
||||
Content: out.Content,
|
||||
WordCount: out.WordCount,
|
||||
Sort: out.Sort,
|
||||
IsLocked: out.IsLocked,
|
||||
RequiredScore: out.RequiredScore,
|
||||
UpdatedAt: out.UpdatedAt.String(),
|
||||
}, nil
|
||||
}
|
||||
29
internal/controller/chapter/chapter_v1_app_list.go
Normal file
29
internal/controller/chapter/chapter_v1_app_list.go
Normal file
@ -0,0 +1,29 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "server/api/chapter/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AppList(ctx context.Context, req *v1.AppListReq) (res *v1.AppListRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Chapter().AppList(ctx, &model.ChapterAppListIn{
|
||||
BookId: req.BookId,
|
||||
IsDesc: req.IsDesc,
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
UserId: userId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.AppListRes{
|
||||
Total: out.Total,
|
||||
List: out.List,
|
||||
}, nil
|
||||
}
|
||||
27
internal/controller/chapter/chapter_v1_app_progress.go
Normal file
27
internal/controller/chapter/chapter_v1_app_progress.go
Normal file
@ -0,0 +1,27 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "server/api/chapter/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
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,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.AppProgressRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
25
internal/controller/chapter/chapter_v1_app_purchase.go
Normal file
25
internal/controller/chapter/chapter_v1_app_purchase.go
Normal file
@ -0,0 +1,25 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "server/api/chapter/v1"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AppPurchase(ctx context.Context, req *v1.AppPurchaseReq) (res *v1.AppPurchaseRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Chapter().AppPurchase(ctx, &model.ChapterAppPurchaseIn{
|
||||
Id: req.Id,
|
||||
UserId: userId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.AppPurchaseRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
@ -8,12 +8,12 @@ import (
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterDel(ctx context.Context, req *v1.ChapterDelReq) (res *v1.ChapterDelRes, err error) {
|
||||
func (c *ControllerV1) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, 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
|
||||
return &v1.DelRes{Success: out.Success}, nil
|
||||
}
|
||||
@ -8,21 +8,21 @@ import (
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterEdit(ctx context.Context, req *v1.ChapterEditReq) (res *v1.ChapterEditRes, err error) {
|
||||
func (c *ControllerV1) Edit(ctx context.Context, req *v1.EditReq) (res *v1.EditRes, 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,
|
||||
BookId: req.BookId,
|
||||
Title: req.Title,
|
||||
Sort: req.Sort,
|
||||
IsLocked: req.IsLocked,
|
||||
Content: req.Content,
|
||||
WordCount: req.WordCount,
|
||||
RequiredScore: req.RequiredScore,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterEditRes{
|
||||
return &v1.EditRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterList(ctx context.Context, req *v1.ChapterListReq) (res *v1.ChapterListRes, err error) {
|
||||
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
|
||||
out, err := service.Chapter().List(ctx, &model.ChapterListIn{
|
||||
BookId: req.BookId,
|
||||
IsLocked: req.IsLocked,
|
||||
@ -19,7 +19,7 @@ func (c *ControllerV1) ChapterList(ctx context.Context, req *v1.ChapterListReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterListRes{
|
||||
return &v1.ListRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
Reference in New Issue
Block a user