MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / Update

Method Update

internal/api/post.go:73–97  ·  view source on GitHub ↗

Update 更新帖子内容

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

71
72// Update 更新帖子内容
73func (ph *PostHandler) Update(ctx *gin.Context) {
74 var req req.UpdateReq
75 if err := ctx.ShouldBindJSON(&req); err != nil {
76 apiresponse.ErrorWithMessage(ctx, "无效的请求参数")
77 return
78 }
79
80 uc, ok := requireUser(ctx)
81 if !ok {
82 return
83 }
84
85 if err := ph.svc.Update(ctx, domain.Post{
86 ID: req.PostId,
87 Content: req.Content,
88 Title: req.Title,
89 PlateID: req.PlateID,
90 Uid: uc.Uid,
91 }); err != nil {
92 apiresponse.ErrorWithMessage(ctx, err.Error())
93 return
94 }
95
96 apiresponse.Success(ctx)
97}
98
99// Publish 发布帖子
100func (ph *PostHandler) Publish(ctx *gin.Context) {

Callers

nothing calls this directly

Calls 4

ErrorWithMessageFunction · 0.92
SuccessFunction · 0.92
requireUserFunction · 0.85
UpdateMethod · 0.65

Tested by

no test coverage detected