完成安全整改与认证功能重构
This commit is contained in:
1 parent
e91a64136b
commit
51767b9f5b
480 files changed
+57538
-7244
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/ydzydzydz/pmail_telegram_push/db/repository"
|
||||
"github.com/ydzydzydz/pmail_telegram_push/model"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
// SettingDaoImpl 实现了 ISettingDao 接口
|
||||
type SettingDaoImpl struct {
|
||||
db *xorm.Engine
|
||||
}
|
||||
|
||||
var _ ISettingDao = (*SettingDaoImpl)(nil)
|
||||
|
||||
// NewSettingDaoImpl 创建一个新的 SettingDaoImpl 实例
|
||||
func NewSettingDaoImpl(db *xorm.Engine) *SettingDaoImpl {
|
||||
return &SettingDaoImpl{db: db}
|
||||
}
|
||||
|
||||
// GetSetting 获取用户的设置
|
||||
func (d *SettingDaoImpl) GetSetting(userID int) (*model.TelegramPushSetting, error) {
|
||||
settingRepo := repository.NewRepository[model.TelegramPushSetting](d.db)
|
||||
return settingRepo.FindOne(userID)
|
||||
}
|
||||
|
||||
// UpdateSetting 更新用户的设置
|
||||
func (d *SettingDaoImpl) UpdateSetting(userID int, setting *model.TelegramPushSetting) error {
|
||||
settingRepo := repository.NewRepository[model.TelegramPushSetting](d.db)
|
||||
return settingRepo.Update(userID, setting)
|
||||
}
|
||||
|
||||
// CreateSetting 创建用户的设置
|
||||
func (d *SettingDaoImpl) CreateSetting(setting *model.TelegramPushSetting) error {
|
||||
settingRepo := repository.NewRepository[model.TelegramPushSetting](d.db)
|
||||
return settingRepo.Create(setting)
|
||||
}
|
||||
|
||||
// ExistSetting 检查用户的设置是否存在
|
||||
func (d *SettingDaoImpl) ExistSetting(userID int) bool {
|
||||
settingRepo := repository.NewRepository[model.TelegramPushSetting](d.db)
|
||||
return settingRepo.Exist(userID)
|
||||
}
|
||||
Reference in new issue
Block a user