增加基础设置页面

This commit is contained in:
2026-07-29 16:45:22 +08:00
parent 0b22d4f126
commit a9a890a849
15 changed files with 472 additions and 84 deletions
+3 -6
View File
@@ -226,12 +226,9 @@ func GetOptionsByUser(db *gorm.DB, userID uint) (map[string]string, error) {
func BatchSetOptions(db *gorm.DB, userID uint, options map[string]string) error {
return db.Transaction(func(tx *gorm.DB) error {
for name, value := range options {
opt := Option{
Name: name,
UserID: userID,
Value: value,
}
if err := tx.Save(&opt).Error; err != nil {
// 复合主键在 SQLite 旧表上可能缺失唯一约束,Save 会重复插入,
// 改用查找-更新-不存在才插入的方式保证幂等
if err := SetOptionValue(tx, name, userID, value); err != nil {
slog.Error("保存配置失败", "name", name, "error", err)
return err
}