新增签到日历筛选

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-16 20:49:21 +08:00
co-authored by Claude
parent d36455ce71
commit 8690265fa0
6 changed files with 275 additions and 5 deletions
+18
View File
@@ -19,12 +19,30 @@ func (s *store) ListSigns(opts listOptions) ([]signRecord, error) {
return rows, q.Find(&rows).Error
}
type signDayCount struct {
Date string `gorm:"column:sign_date"`
Count int64 `gorm:"column:count"`
}
func (s *store) CountSigns(opts listOptions) (int64, error) {
var total int64
q := applySignFilters(s.db.Model(&signRecord{}), opts)
return total, q.Count(&total).Error
}
func (s *store) CountSignsByDay(opts listOptions) ([]signDayCount, error) {
var rows []signDayCount
dateExpr := "date(sign_time)"
if s.driver == databaseDriverMySQL {
dateExpr = "DATE(sign_time)"
}
q := applySignFilters(s.db.Model(&signRecord{}), opts).
Select(dateExpr + " AS sign_date, COUNT(*) AS count").
Group(dateExpr).
Order("sign_date DESC")
return rows, q.Scan(&rows).Error
}
func (s *store) GetSignByID(id uint64) (*signRecord, error) {
var row signRecord
if err := s.db.Where("id = ?", id).Take(&row).Error; err != nil {