🎨备份导出、导入新增其他配置

This commit is contained in:
coward
2024-11-04 16:50:50 +08:00
parent db065073e2
commit 40019568f0
2 changed files with 34 additions and 0 deletions

View File

@@ -152,6 +152,13 @@ func (s setting) Export() (data vo.Export, err error) {
}
}
// 查询其他配置
var others []vo.Other
if err = s.Model(&model.Setting{}).Where("code not in ?", []string{"WG_SETTING", "WG_SERVER"}).Find(&others).Error; err != nil {
return
}
data.Other = others
cj, _ := json.Marshal(clients)
_ = json.Unmarshal(cj, &data.Clients)
@@ -219,5 +226,17 @@ func (s setting) Import(data *vo.Export, loginUser *vo.User) (err error) {
}
}
// 其他配置写入
for _, v := range data.Other {
if err = s.SetData(&model.Setting{
Code: v.Code,
Data: v.Data,
Describe: v.Describe,
}); err != nil {
slog.Errorf("其他配置[%s]导入失败: %v", v.Code, err)
continue
}
}
return nil
}