GetPostsCount 获取帖子总数
(ctx context.Context)
| 339 | |
| 340 | // GetPostsCount 获取帖子总数 |
| 341 | func (p *postDAO) GetPostsCount(ctx context.Context) (int64, error) { |
| 342 | var count int64 |
| 343 | if err := p.db.WithContext(ctx).Model(&Post{}).Count(&count).Error; err != nil { |
| 344 | p.l.Error("获取帖子总数失败", zap.Error(err)) |
| 345 | return 0, err |
| 346 | } |
| 347 | return count, nil |
| 348 | } |
| 349 | |
| 350 | // GetPostsByPlate 根据板块获取帖子 |
| 351 | func (p *postDAO) GetPostsByPlate(ctx context.Context, plateId int64, pagination domain.Pagination) ([]Post, error) { |