feat: add wxshare
This commit is contained in:
@@ -18,9 +18,10 @@ type ListQuery struct {
|
||||
type posts struct{}
|
||||
|
||||
// List posts
|
||||
// @Router /admin/posts [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
//
|
||||
// @Router /admin/posts [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery) (*requests.Pager, error) {
|
||||
cond := models.Posts.BuildConditionWithKey(query.Keyword)
|
||||
pager, err := models.Posts.List(ctx.Context(), pagination, cond)
|
||||
@@ -63,8 +64,9 @@ type PostForm struct {
|
||||
}
|
||||
|
||||
// Create
|
||||
// @Router /admin/posts [post]
|
||||
// @Bind form body
|
||||
//
|
||||
// @Router /admin/posts [post]
|
||||
// @Bind form body
|
||||
func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
||||
post := model.Posts{
|
||||
Title: form.Title,
|
||||
@@ -100,9 +102,10 @@ func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
||||
}
|
||||
|
||||
// Update posts
|
||||
// @Router /admin/posts/:id [put]
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
//
|
||||
// @Router /admin/posts/:id [put]
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (ctl *posts) Update(ctx fiber.Ctx, id int64, form *PostForm) error {
|
||||
oldPost, err := models.Posts.GetByID(ctx.Context(), id)
|
||||
if err != nil {
|
||||
@@ -148,8 +151,9 @@ func (ctl *posts) Update(ctx fiber.Ctx, id int64, form *PostForm) error {
|
||||
}
|
||||
|
||||
// Delete posts
|
||||
// @Router /admin/posts/:id [delete]
|
||||
// @Bind id path
|
||||
//
|
||||
// @Router /admin/posts/:id [delete]
|
||||
// @Bind id path
|
||||
func (ctl *posts) Delete(ctx fiber.Ctx, id int64) error {
|
||||
post, err := models.Posts.GetByID(ctx.Context(), id)
|
||||
if err != nil {
|
||||
@@ -172,8 +176,9 @@ type PostItem struct {
|
||||
}
|
||||
|
||||
// Show posts by id
|
||||
// @Router /admin/posts/:id [get]
|
||||
// @Bind id path
|
||||
//
|
||||
// @Router /admin/posts/:id [get]
|
||||
// @Bind id path
|
||||
func (ctl *posts) Show(ctx fiber.Ctx, id int64) (*PostItem, error) {
|
||||
post, err := models.Posts.GetByID(ctx.Context(), id)
|
||||
if err != nil {
|
||||
@@ -193,9 +198,10 @@ func (ctl *posts) Show(ctx fiber.Ctx, id int64) (*PostItem, error) {
|
||||
}
|
||||
|
||||
// SendTo
|
||||
// @Router /admin/posts/:id/send-to/:userId [post]
|
||||
// @Bind id path
|
||||
// @Bind userId path
|
||||
//
|
||||
// @Router /admin/posts/:id/send-to/:userId [post]
|
||||
// @Bind id path
|
||||
// @Bind userId path
|
||||
func (ctl *posts) SendTo(ctx fiber.Ctx, id, userId int64) error {
|
||||
if _, err := models.Posts.GetByID(ctx.Context(), id); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user