初始化项目框架,完成部分接口开发
This commit is contained in:
5
internal/controller/chapter/chapter.go
Normal file
5
internal/controller/chapter/chapter.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package chapter
|
||||
15
internal/controller/chapter/chapter_new.go
Normal file
15
internal/controller/chapter/chapter_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 chapter
|
||||
|
||||
import (
|
||||
"server/api/chapter"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() chapter.IChapterV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
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
|
||||
}
|
||||
19
internal/controller/chapter/chapter_v1_chapter_del.go
Normal file
19
internal/controller/chapter/chapter_v1_chapter_del.go
Normal file
@ -0,0 +1,19 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterDel(ctx context.Context, req *v1.ChapterDelReq) (res *v1.ChapterDelRes, 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
|
||||
}
|
||||
28
internal/controller/chapter/chapter_v1_chapter_edit.go
Normal file
28
internal/controller/chapter/chapter_v1_chapter_edit.go
Normal file
@ -0,0 +1,28 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterEdit(ctx context.Context, req *v1.ChapterEditReq) (res *v1.ChapterEditRes, 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,
|
||||
Title: req.Title,
|
||||
WordCount: req.WordCount,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterEditRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
26
internal/controller/chapter/chapter_v1_chapter_list.go
Normal file
26
internal/controller/chapter/chapter_v1_chapter_list.go
Normal file
@ -0,0 +1,26 @@
|
||||
package chapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/chapter/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) ChapterList(ctx context.Context, req *v1.ChapterListReq) (res *v1.ChapterListRes, err error) {
|
||||
out, err := service.Chapter().List(ctx, &model.ChapterListIn{
|
||||
BookId: req.BookId,
|
||||
IsLocked: req.IsLocked,
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Title: req.Title,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ChapterListRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user