作者 tangxuhui

修正搜索结果

... ... @@ -11,6 +11,8 @@ type ListSystemSettingQuery struct {
CompanyId int64 `json:"companyId,omitempty"`
// 设置对应的编码
SettingCode string `json:"settingCode,omitempty"`
//配置名称搜索
SettingName string `json:"settingName"`
}
func (listSystemSettingQuery *ListSystemSettingQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -46,7 +46,7 @@ func (systemSettingService *SystemSettingService) GetSystemSetting(getSystemSett
if len(systemSettings) == 0 {
//获取默认设置项
setting := domain.SystemSetting{}
defaultSet := setting.GetDefaultSetting(getSystemSettingQuery.SettingCode)
defaultSet := setting.GetDefaultSetting(getSystemSettingQuery.SettingCode, "")
if len(defaultSet) == 0 {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取设置项失败,settingCode="+getSystemSettingQuery.SettingCode)
}
... ... @@ -102,7 +102,7 @@ func (systemSettingService *SystemSettingService) ListSystemSetting(listSystemSe
code := systemSettings[i].SettingCode
settingMap[code] = systemSettings[i]
}
defaultSettings := new(domain.SystemSetting).GetDefaultSetting("")
defaultSettings := new(domain.SystemSetting).GetDefaultSetting("", listSystemSettingQuery.SettingName)
for i := range defaultSettings {
if v, ok := settingMap[defaultSettings[i].SettingCode]; ok {
defaultSettings[i].Value = v.Value
... ... @@ -151,7 +151,7 @@ func (systemSettingService *SystemSettingService) UpdateSystemSetting(updateSyst
var systemSetting *domain.SystemSetting
if len(systemSettings) == 0 {
//未找到历史数据,使用默认配置
defaultSet := new(domain.SystemSetting).GetDefaultSetting(updateSystemSettingCommand.SettingCode)
defaultSet := new(domain.SystemSetting).GetDefaultSetting(updateSystemSettingCommand.SettingCode, "")
if len(defaultSet) > 0 {
systemSetting = &domain.SystemSetting{}
*systemSetting = defaultSet[0]
... ...
package domain
import "strings"
// 系统参数设置
type SystemSetting struct {
// 公司id
... ... @@ -73,17 +75,20 @@ var defaultsysSettingList = []SystemSetting{
},
}
func (systemSetting *SystemSetting) GetDefaultSetting(settingCode string) []SystemSetting {
func (systemSetting *SystemSetting) GetDefaultSetting(settingCode string, settingName string) []SystemSetting {
var list []SystemSetting
if len(settingCode) > 0 {
for i := range defaultsysSettingList {
if defaultsysSettingList[i].SettingCode == settingCode {
list = append(list, defaultsysSettingList[i])
settingCodeOk := true
settingNameOk := true
if len(settingCode) > 0 {
settingCodeOk = defaultsysSettingList[i].SettingCode == settingCode
}
if len(settingName) > 0 {
settingNameOk = strings.Contains(defaultsysSettingList[i].SettingName, settingName)
}
if settingCodeOk && settingNameOk {
list = append(list, defaultsysSettingList[i])
}
} else {
list = make([]SystemSetting, len(defaultsysSettingList))
copy(list, defaultsysSettingList)
}
return list
}
... ...