feat: update admin

This commit is contained in:
yanghao05
2025-04-28 19:12:31 +08:00
parent 82c112b1eb
commit 685c87207f
12 changed files with 251 additions and 238 deletions

View File

@@ -395,3 +395,21 @@ func (m *postsModel) GetMediaByIds(ctx context.Context, ids []int64) ([]model.Me
return medias, nil
}
// Count
func (m *postsModel) Count(ctx context.Context, cond BoolExpression) (int64, error) {
tbl := table.Posts
stmt := tbl.
SELECT(COUNT(tbl.ID).AS("count")).
WHERE(cond)
var count struct {
Count int64
}
if err := stmt.QueryContext(ctx, db, &count); err != nil {
m.log.Errorf("error counting posts: %v", err)
return 0, err
}
return count.Count, nil
}