mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-03 15:56:22 +00:00
24 lines
525 B
Go
24 lines
525 B
Go
package repo
|
|
|
|
import "github.com/snowykami/neo-blog/internal/model"
|
|
|
|
type sessionRepo struct{}
|
|
|
|
var Session = sessionRepo{}
|
|
|
|
func (s *sessionRepo) SaveSession(sessionKey string) error {
|
|
session := &model.Session{
|
|
SessionKey: sessionKey,
|
|
}
|
|
return db.Create(session).Error
|
|
}
|
|
|
|
func (s *sessionRepo) IsSessionValid(sessionKey string) (bool, error) {
|
|
var count int64
|
|
err := db.Model(&model.Session{}).Where("session_key = ?", sessionKey).Count(&count).Error
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return count > 0, nil
|
|
}
|