29 lines
612 B
Go
29 lines
612 B
Go
package book
|
|
|
|
import (
|
|
"context"
|
|
v1 "server/api/book/v1"
|
|
"server/internal/model"
|
|
"server/internal/service"
|
|
)
|
|
|
|
func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) {
|
|
out, err := service.Book().Create(ctx, &model.BookAddIn{
|
|
AuthorId: req.AuthorId,
|
|
CategoryId: req.CategoryId,
|
|
Title: req.Title,
|
|
CoverUrl: req.CoverUrl,
|
|
Description: req.Description,
|
|
Status: req.Status,
|
|
Tags: req.Tags,
|
|
IsRecommended: req.IsRecommended,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &v1.AddRes{
|
|
Success: out.Success,
|
|
}, nil
|
|
}
|