Files
SproutGate/sproutgate-backend/internal/storage/pending.go

35 lines
911 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package storage
import (
"errors"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"sproutgate-backend/internal/models"
)
func (s *Store) SavePending(record models.PendingUser) error {
row := dbPendingFromModel(record)
return s.db.Clauses(clause.OnConflict{UpdateAll: true}).Create(&row).Error
}
func (s *Store) GetPending(account string) (models.PendingUser, bool, error) {
var row DBPendingUser
result := s.db.First(&row, "account = ?", account)
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return models.PendingUser{}, false, nil
}
if result.Error != nil {
return models.PendingUser{}, false, result.Error
}
return row.toModel(), true, nil
}
func (s *Store) DeletePending(account string) error {
return s.db.Delete(&DBPendingUser{}, "account = ?", account).Error
}
// DataDir 返回空字符串MySQL 模式下无本地数据目录)。
func (s *Store) DataDir() string { return "" }