31 lines
769 B
Go
31 lines
769 B
Go
package repository
|
|
|
|
import (
|
|
"carrotskin/internal/model"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// yggdrasilRepository YggdrasilRepository的实现
|
|
type yggdrasilRepository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
// NewYggdrasilRepository 创建YggdrasilRepository实例
|
|
func NewYggdrasilRepository(db *gorm.DB) YggdrasilRepository {
|
|
return &yggdrasilRepository{db: db}
|
|
}
|
|
|
|
func (r *yggdrasilRepository) GetPasswordByID(id int64) (string, error) {
|
|
var yggdrasil model.Yggdrasil
|
|
err := r.db.Select("password").Where("id = ?", id).First(&yggdrasil).Error
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return yggdrasil.Password, nil
|
|
}
|
|
|
|
func (r *yggdrasilRepository) ResetPassword(id int64, password string) error {
|
|
return r.db.Model(&model.Yggdrasil{}).Where("id = ?", id).Update("password", password).Error
|
|
}
|