List 获取个人帖子列表
(ctx *gin.Context)
| 140 | |
| 141 | // List 获取个人帖子列表 |
| 142 | func (ph *PostHandler) List(ctx *gin.Context) { |
| 143 | var req req.ListReq |
| 144 | if err := ctx.ShouldBindJSON(&req); err != nil { |
| 145 | apiresponse.ErrorWithMessage(ctx, "无效的请求参数") |
| 146 | return |
| 147 | } |
| 148 | |
| 149 | uc, ok := requireUser(ctx) |
| 150 | if !ok { |
| 151 | return |
| 152 | } |
| 153 | |
| 154 | du, err := ph.svc.ListPosts(ctx, domain.Pagination{ |
| 155 | Page: req.Page, |
| 156 | Size: req.Size, |
| 157 | Uid: uc.Uid, |
| 158 | }) |
| 159 | if err != nil { |
| 160 | apiresponse.ErrorWithMessage(ctx, err.Error()) |
| 161 | return |
| 162 | } |
| 163 | |
| 164 | apiresponse.SuccessWithData(ctx, du) |
| 165 | } |
| 166 | |
| 167 | // ListPub 获取公开帖子列表 |
| 168 | func (ph *PostHandler) ListPub(ctx *gin.Context) { |
nothing calls this directly
no test coverage detected