feat: 添加网元配置文件备份的FTP配置管理功能

This commit is contained in:
TsMask
2025-04-11 11:04:39 +08:00
parent 8910008e92
commit ad81d04db1
8 changed files with 258 additions and 54 deletions

View File

@@ -4,8 +4,10 @@ import (
"fmt"
"strconv"
"be.ems/src/framework/config"
"be.ems/src/framework/constants"
"be.ems/src/framework/database/redis"
"be.ems/src/framework/utils/crypto"
"be.ems/src/framework/utils/file"
"be.ems/src/modules/system/model"
"be.ems/src/modules/system/repository"
@@ -145,6 +147,32 @@ func (s SysConfig) FindByKey(configKey string) model.SysConfig {
return model.SysConfig{}
}
// UpdateEncryptValue 更新并加密配置值信息
func (s SysConfig) UpdateEncryptValue(sysConfig model.SysConfig) int64 {
appKey := config.Get("aes.appKey").(string)
bodyEn, err := crypto.AESEncryptBase64(sysConfig.ConfigValue, appKey)
if err != nil {
return 0
}
sysConfig.ConfigValue = bodyEn
return s.Update(sysConfig)
}
// FindByKeyDecryptValue 获取并解密配置值信息
func (s SysConfig) FindByKeyDecryptValue(configKey string) model.SysConfig {
item := s.FindByKey(configKey)
if item.ConfigKey != configKey {
return item
}
appKey := config.Get("aes.appKey").(string)
bodyDe, err := crypto.AESDecryptBase64(item.ConfigValue, appKey)
if err != nil {
return item
}
item.ConfigValue = bodyDe
return item
}
// ExportData 导出数据表格
func (s SysConfig) ExportData(rows []model.SysConfig, fileName string) (string, error) {
// 第一行表头标题