mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-09 05:59:50 +00:00
25 lines
623 B
Go
25 lines
623 B
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/usual2970/certimate/internal/domain"
|
|
"github.com/usual2970/certimate/internal/utils/app"
|
|
)
|
|
|
|
type CertificateRepository struct{}
|
|
|
|
func NewCertificateRepository() *CertificateRepository {
|
|
return &CertificateRepository{}
|
|
}
|
|
|
|
func (c *CertificateRepository) GetExpireSoon(ctx context.Context) ([]domain.Certificate, error) {
|
|
rs := []domain.Certificate{}
|
|
if err := app.GetApp().Dao().DB().
|
|
NewQuery("select * from certificate where expireAt > datetime('now') and expireAt < datetime('now', '+20 days')").
|
|
All(&rs); err != nil {
|
|
return nil, err
|
|
}
|
|
return rs, nil
|
|
}
|