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

Method Edit

internal/api/post.go:45–70  ·  view source on GitHub ↗

Edit 创建新帖子

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

43
44// Edit 创建新帖子
45func (ph *PostHandler) Edit(ctx *gin.Context) {
46 var req req.EditReq
47 if err := ctx.ShouldBindJSON(&req); err != nil {
48 apiresponse.ErrorWithMessage(ctx, "无效的请求参数")
49 return
50 }
51
52 uc, ok := requireUser(ctx)
53 if !ok {
54 return
55 }
56
57 id, err := ph.svc.Create(ctx, domain.Post{
58 ID: req.PostId,
59 Content: req.Content,
60 Title: req.Title,
61 PlateID: req.PlateID,
62 Uid: uc.Uid,
63 })
64 if err != nil {
65 apiresponse.ErrorWithMessage(ctx, err.Error())
66 return
67 }
68
69 apiresponse.SuccessWithData(ctx, id)
70}
71
72// Update 更新帖子内容
73func (ph *PostHandler) Update(ctx *gin.Context) {

Callers

nothing calls this directly

Calls 4

ErrorWithMessageFunction · 0.92
SuccessWithDataFunction · 0.92
requireUserFunction · 0.85
CreateMethod · 0.65

Tested by

no test coverage detected