初始化项目框架,完成部分接口开发
This commit is contained in:
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
|
||||
}
|
||||
Reference in New Issue
Block a user