sms_code.go 478 B

1234567891011121314151617
  1. package entity
  2. import "time"
  3. type SMSCode struct {
  4. Code string `db:"code"`
  5. Mobile string `db:"mobile"`
  6. CodeType int `db:"code_type"`
  7. IsUsed int `db:"is_used"`
  8. CreatedAt string `db:"created_at"`
  9. UpdatedAt string `db:"updated_at"`
  10. }
  11. func (code *SMSCode) IsExpired(period time.Duration) bool {
  12. cat, _ := time.Parse("2006-01-02 15:04:05", code.CreatedAt)
  13. return cat.Add(period).Format("2006-01-02 15:04:05") < time.Now().Format("2006-01-02 15:04:05")
  14. }