Skip to content

Commit

Permalink
Fix bookmark api
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Sep 10, 2023
1 parent 89ad6b5 commit 7245746
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/api/creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (a *Creation) Create(ctx *gear.Context) error {
Language: output.Language,
Version: output.Version,
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.CreationOutput]{Result: output})
Expand Down Expand Up @@ -130,7 +130,7 @@ func (a *Creation) Update(ctx *gear.Context) error {
Language: output.Language,
Version: output.Version,
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.CreationOutput]{Result: output})
Expand Down Expand Up @@ -161,7 +161,7 @@ func (a *Creation) Delete(ctx *gear.Context) error {
CID: input.ID,
Status: util.Ptr(int8(-2)),
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[bool]{Result: output})
Expand Down Expand Up @@ -239,7 +239,7 @@ func (a *Creation) Archive(ctx *gear.Context) error {
CID: input.ID,
Status: util.Ptr(int8(-1)),
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.CreationOutput]{Result: output})
Expand Down Expand Up @@ -267,7 +267,7 @@ func (a *Creation) Redraft(ctx *gear.Context) error {
CID: input.ID,
Status: util.Ptr(int8(0)),
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.CreationOutput]{Result: output})
Expand Down Expand Up @@ -480,7 +480,7 @@ func (a *Creation) UpdateContent(ctx *gear.Context) error {
Language: output.Language,
Version: output.Version,
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.CreationOutput]{Result: output})
Expand Down
18 changes: 9 additions & 9 deletions src/api/publication.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func (a *Publication) Update(ctx *gear.Context) error {
Version: &input.Version,
Status: output.Status,
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.PublicationOutput]{Result: output})
Expand Down Expand Up @@ -565,7 +565,7 @@ func (a *Publication) Delete(ctx *gear.Context) error {
Version: &input.Version,
Status: util.Ptr(int8(-2)),
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[bool]{Result: output})
Expand Down Expand Up @@ -752,7 +752,7 @@ func (a *Publication) Archive(ctx *gear.Context) error {
Version: &input.Version,
Status: util.Ptr(int8(-1)),
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.PublicationOutput]{Result: output})
Expand Down Expand Up @@ -786,7 +786,7 @@ func (a *Publication) Redraft(ctx *gear.Context) error {
Version: &input.Version,
Status: util.Ptr(int8(0)),
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.PublicationOutput]{Result: output})
Expand Down Expand Up @@ -828,7 +828,7 @@ func (a *Publication) Publish(ctx *gear.Context) error {
Version: &input.Version,
Status: util.Ptr(int8(2)),
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.PublicationOutput]{Result: output})
Expand Down Expand Up @@ -874,13 +874,13 @@ func (a *Publication) UpdateContent(ctx *gear.Context) error {
Version: &input.Version,
Status: output.Status,
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.PublicationOutput]{Result: output})
}

func (a *Publication) Collect(ctx *gear.Context) error {
func (a *Publication) Bookmark(ctx *gear.Context) error {
input := &bll.CreateBookmarkInput{}
if err := ctx.ParseBody(input); err != nil {
return err
Expand All @@ -896,13 +896,13 @@ func (a *Publication) Collect(ctx *gear.Context) error {
}

sess := gear.CtxValue[middleware.Session](ctx)
if _, err = a.blls.Logbase.Log(ctx, bll.LogActionUserCollect, 1, sess.UserID, &bll.LogPayload{
if _, err = a.blls.Logbase.Log(ctx, bll.LogActionUserBookmark, 1, sess.UserID, &bll.LogPayload{
GID: input.GID,
CID: input.CID,
Language: &input.Language,
Version: &input.Version,
}); err != nil {
return gear.ErrInternalServerError.From(err)
logging.SetTo(ctx, "writeLogError", err.Error())
}

return ctx.OkSend(bll.SuccessResponse[*bll.BookmarkOutput]{Result: output})
Expand Down
2 changes: 1 addition & 1 deletion src/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func newRouters(apis *APIs) []*gear.Router {
router.Patch("/v1/publication/publish", middleware.AuthToken.Auth, apis.Publication.Publish)
router.Put("/v1/publication/update_content", middleware.AuthToken.Auth, apis.Publication.UpdateContent)
router.Post("/v1/publication/assist", middleware.AuthToken.Auth, todo) // 暂不实现
router.Post("/v1/publication/collect", middleware.AuthToken.Auth, apis.Publication.Collect)
router.Post("/v1/publication/bookmark", middleware.AuthToken.Auth, apis.Publication.Bookmark)
router.Post("/v1/publication/upload", middleware.AuthToken.Auth, apis.Publication.UploadFile)

router.Patch("/v1/bookmark", middleware.AuthToken.Auth, apis.Bookmark.Update)
Expand Down
2 changes: 1 addition & 1 deletion src/bll/logbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
LogActionUserUpdate = "user.update"
LogActionUserUpdateCN = "user.update.cn"
LogActionUserLogout = "user.logout"
LogActionUserCollect = "user.collect"
LogActionUserBookmark = "user.bookmark"
LogActionUserFollow = "user.follow"
LogActionUserSubscribe = "user.subscribe"
LogActionUserSponsor = "user.sponsor"
Expand Down

0 comments on commit 7245746

Please sign in to comment.