作者 tangxuhui

修正搜索结果

@@ -11,6 +11,8 @@ type ListSystemSettingQuery struct { @@ -11,6 +11,8 @@ type ListSystemSettingQuery struct {
11 CompanyId int64 `json:"companyId,omitempty"` 11 CompanyId int64 `json:"companyId,omitempty"`
12 // 设置对应的编码 12 // 设置对应的编码
13 SettingCode string `json:"settingCode,omitempty"` 13 SettingCode string `json:"settingCode,omitempty"`
  14 + //配置名称搜索
  15 + SettingName string `json:"settingName"`
14 } 16 }
15 17
16 func (listSystemSettingQuery *ListSystemSettingQuery) Valid(validation *validation.Validation) { 18 func (listSystemSettingQuery *ListSystemSettingQuery) Valid(validation *validation.Validation) {
@@ -46,7 +46,7 @@ func (systemSettingService *SystemSettingService) GetSystemSetting(getSystemSett @@ -46,7 +46,7 @@ func (systemSettingService *SystemSettingService) GetSystemSetting(getSystemSett
46 if len(systemSettings) == 0 { 46 if len(systemSettings) == 0 {
47 //获取默认设置项 47 //获取默认设置项
48 setting := domain.SystemSetting{} 48 setting := domain.SystemSetting{}
49 - defaultSet := setting.GetDefaultSetting(getSystemSettingQuery.SettingCode) 49 + defaultSet := setting.GetDefaultSetting(getSystemSettingQuery.SettingCode, "")
50 if len(defaultSet) == 0 { 50 if len(defaultSet) == 0 {
51 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取设置项失败,settingCode="+getSystemSettingQuery.SettingCode) 51 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取设置项失败,settingCode="+getSystemSettingQuery.SettingCode)
52 } 52 }
@@ -102,7 +102,7 @@ func (systemSettingService *SystemSettingService) ListSystemSetting(listSystemSe @@ -102,7 +102,7 @@ func (systemSettingService *SystemSettingService) ListSystemSetting(listSystemSe
102 code := systemSettings[i].SettingCode 102 code := systemSettings[i].SettingCode
103 settingMap[code] = systemSettings[i] 103 settingMap[code] = systemSettings[i]
104 } 104 }
105 - defaultSettings := new(domain.SystemSetting).GetDefaultSetting("") 105 + defaultSettings := new(domain.SystemSetting).GetDefaultSetting("", listSystemSettingQuery.SettingName)
106 for i := range defaultSettings { 106 for i := range defaultSettings {
107 if v, ok := settingMap[defaultSettings[i].SettingCode]; ok { 107 if v, ok := settingMap[defaultSettings[i].SettingCode]; ok {
108 defaultSettings[i].Value = v.Value 108 defaultSettings[i].Value = v.Value
@@ -151,7 +151,7 @@ func (systemSettingService *SystemSettingService) UpdateSystemSetting(updateSyst @@ -151,7 +151,7 @@ func (systemSettingService *SystemSettingService) UpdateSystemSetting(updateSyst
151 var systemSetting *domain.SystemSetting 151 var systemSetting *domain.SystemSetting
152 if len(systemSettings) == 0 { 152 if len(systemSettings) == 0 {
153 //未找到历史数据,使用默认配置 153 //未找到历史数据,使用默认配置
154 - defaultSet := new(domain.SystemSetting).GetDefaultSetting(updateSystemSettingCommand.SettingCode) 154 + defaultSet := new(domain.SystemSetting).GetDefaultSetting(updateSystemSettingCommand.SettingCode, "")
155 if len(defaultSet) > 0 { 155 if len(defaultSet) > 0 {
156 systemSetting = &domain.SystemSetting{} 156 systemSetting = &domain.SystemSetting{}
157 *systemSetting = defaultSet[0] 157 *systemSetting = defaultSet[0]
1 package domain 1 package domain
2 2
  3 +import "strings"
  4 +
3 // 系统参数设置 5 // 系统参数设置
4 type SystemSetting struct { 6 type SystemSetting struct {
5 // 公司id 7 // 公司id
@@ -73,17 +75,20 @@ var defaultsysSettingList = []SystemSetting{ @@ -73,17 +75,20 @@ var defaultsysSettingList = []SystemSetting{
73 }, 75 },
74 } 76 }
75 77
76 -func (systemSetting *SystemSetting) GetDefaultSetting(settingCode string) []SystemSetting { 78 +func (systemSetting *SystemSetting) GetDefaultSetting(settingCode string, settingName string) []SystemSetting {
77 var list []SystemSetting 79 var list []SystemSetting
78 - if len(settingCode) > 0 {  
79 for i := range defaultsysSettingList { 80 for i := range defaultsysSettingList {
80 - if defaultsysSettingList[i].SettingCode == settingCode {  
81 - list = append(list, defaultsysSettingList[i]) 81 + settingCodeOk := true
  82 + settingNameOk := true
  83 + if len(settingCode) > 0 {
  84 + settingCodeOk = defaultsysSettingList[i].SettingCode == settingCode
  85 + }
  86 + if len(settingName) > 0 {
  87 + settingNameOk = strings.Contains(defaultsysSettingList[i].SettingName, settingName)
82 } 88 }
  89 + if settingCodeOk && settingNameOk {
  90 + list = append(list, defaultsysSettingList[i])
83 } 91 }
84 - } else {  
85 - list = make([]SystemSetting, len(defaultsysSettingList))  
86 - copy(list, defaultsysSettingList)  
87 } 92 }
88 return list 93 return list
89 } 94 }