Publish 发布帖子
(ctx *gin.Context)
| 98 | |
| 99 | // Publish 发布帖子 |
| 100 | func (ph *PostHandler) Publish(ctx *gin.Context) { |
| 101 | var req req.PublishReq |
| 102 | if err := ctx.ShouldBindJSON(&req); err != nil { |
| 103 | apiresponse.ErrorWithMessage(ctx, "无效的请求参数") |
| 104 | return |
| 105 | } |
| 106 | |
| 107 | uc, ok := requireUser(ctx) |
| 108 | if !ok { |
| 109 | return |
| 110 | } |
| 111 | |
| 112 | if err := ph.svc.Publish(ctx, req.PostId, uc.Uid); err != nil { |
| 113 | apiresponse.ErrorWithMessage(ctx, err.Error()) |
| 114 | return |
| 115 | } |
| 116 | |
| 117 | apiresponse.SuccessWithData(ctx, req.PostId) |
| 118 | } |
| 119 | |
| 120 | // Withdraw 撤回帖子 |
| 121 | func (ph *PostHandler) Withdraw(ctx *gin.Context) { |
nothing calls this directly
no test coverage detected