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

@@ -257,3 +257,21 @@ func (m *mediasModel) GetRelations(ctx context.Context, hash string) ([]*model.M
return &media
}), nil
}
// Count
func (m *mediasModel) Count(ctx context.Context) (int64, error) {
tbl := table.Medias
stmt := tbl.SELECT(COUNT(tbl.ID).AS("count"))
m.log.Infof("sql: %s", stmt.DebugSql())
var count struct {
Count int64
}
if err := stmt.QueryContext(ctx, db, &count); err != nil {
m.log.Errorf("error counting media items: %v", err)
return 0, err
}
return count.Count, nil
}