Edit 创建新帖子
(ctx *gin.Context)
| 43 | |
| 44 | // Edit 创建新帖子 |
| 45 | func (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 更新帖子内容 |
| 73 | func (ph *PostHandler) Update(ctx *gin.Context) { |
nothing calls this directly
no test coverage detected