书籍列表接口新增参数
This commit is contained in:
23
internal/controller/author/author_v1_apply.go
Normal file
23
internal/controller/author/author_v1_apply.go
Normal file
@ -0,0 +1,23 @@
|
||||
package author
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/author/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Apply(ctx context.Context, req *v1.ApplyReq) (res *v1.ApplyRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Author().Apply(ctx, &model.AuthorApplyIn{
|
||||
UserId: userId,
|
||||
PenName: req.PenName,
|
||||
Bio: req.Bio,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ApplyRes{Success: out.Success, Msg: "Please wait patiently for the management review"}, nil
|
||||
}
|
||||
23
internal/controller/author/author_v1_author_info.go
Normal file
23
internal/controller/author/author_v1_author_info.go
Normal file
@ -0,0 +1,23 @@
|
||||
package author
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/author/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AuthorInfo(ctx context.Context, req *v1.AuthorInfoReq) (res *v1.AuthorInfoRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.Author().AuthorInfo(ctx, &model.AuthorInfoIn{UserId: userId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AuthorInfoRes{
|
||||
Id: out.Id,
|
||||
PenName: out.PenName,
|
||||
Role: out.Role,
|
||||
}, nil
|
||||
}
|
||||
@ -13,5 +13,5 @@ func (c *ControllerV1) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.D
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DetailRes{Author: out}, nil
|
||||
return &v1.DetailRes{out}, nil
|
||||
}
|
||||
|
||||
21
internal/controller/author/author_v1_review.go
Normal file
21
internal/controller/author/author_v1_review.go
Normal file
@ -0,0 +1,21 @@
|
||||
package author
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
v1 "server/api/author/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Review(ctx context.Context, req *v1.ReviewReq) (res *v1.ReviewRes, err error) {
|
||||
out, err := service.Author().Review(ctx, &model.AuthorReviewIn{
|
||||
AuthorId: req.AuthorId,
|
||||
Status: req.Status,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ReviewRes{Success: out.Success}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user