作者 tangxuhui

数据结构调整

@@ -52,6 +52,8 @@ func (systemSettingService *SystemSettingService) GetSystemSetting(getSystemSett @@ -52,6 +52,8 @@ func (systemSettingService *SystemSettingService) GetSystemSetting(getSystemSett
52 } 52 }
53 defaultSet[0].CompanyId = getSystemSettingQuery.CompanyId 53 defaultSet[0].CompanyId = getSystemSettingQuery.CompanyId
54 systemSetting = defaultSet[0] 54 systemSetting = defaultSet[0]
  55 + } else {
  56 + systemSetting = *systemSettings[0]
55 } 57 }
56 if err := transactionContext.CommitTransaction(); err != nil { 58 if err := transactionContext.CommitTransaction(); err != nil {
57 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 59 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -147,21 +149,20 @@ func (systemSettingService *SystemSettingService) UpdateSystemSetting(updateSyst @@ -147,21 +149,20 @@ func (systemSettingService *SystemSettingService) UpdateSystemSetting(updateSyst
147 //未找到历史数据,使用默认配置 149 //未找到历史数据,使用默认配置
148 defaultSet := new(domain.SystemSetting).GetDefaultSetting(updateSystemSettingCommand.SettingCode) 150 defaultSet := new(domain.SystemSetting).GetDefaultSetting(updateSystemSettingCommand.SettingCode)
149 if len(defaultSet) > 0 { 151 if len(defaultSet) > 0 {
150 - systemSetting = &defaultSet[0] 152 + *systemSetting = defaultSet[0]
151 systemSetting.CompanyId = updateSystemSettingCommand.CompanyId 153 systemSetting.CompanyId = updateSystemSettingCommand.CompanyId
152 } 154 }
153 } else { 155 } else {
154 systemSetting = systemSettings[0] 156 systemSetting = systemSettings[0]
  157 + }
  158 + if systemSetting == nil {
  159 + return nil, application.ThrowError(application.BUSINESS_ERROR, "settingCode错误,settingCode="+updateSystemSettingCommand.SettingCode)
  160 + }
155 if err := systemSetting.Update(map[string]interface{}{ 161 if err := systemSetting.Update(map[string]interface{}{
156 "value": updateSystemSettingCommand.Value, 162 "value": updateSystemSettingCommand.Value,
157 }); err != nil { 163 }); err != nil {
158 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 164 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
159 } 165 }
160 - }  
161 - if systemSetting == nil {  
162 - return nil, application.ThrowError(application.BUSINESS_ERROR, "settingCode错误,settingCode="+updateSystemSettingCommand.SettingCode)  
163 - }  
164 -  
165 if systemSetting, err := systemSettingRepository.Save(systemSetting); err != nil { 166 if systemSetting, err := systemSettingRepository.Save(systemSetting); err != nil {
166 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 167 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
167 } else { 168 } else {
@@ -3,7 +3,7 @@ package domain @@ -3,7 +3,7 @@ package domain
3 // 系统参数设置 3 // 系统参数设置
4 type SystemSetting struct { 4 type SystemSetting struct {
5 // 公司id 5 // 公司id
6 - CompanyId int64 `json:"companyId"` 6 + CompanyId int64 `json:"companyId,string"`
7 // 管控层级 7 // 管控层级
8 ControlLevel string `json:"controlLevel"` 8 ControlLevel string `json:"controlLevel"`
9 // 描述 9 // 描述
@@ -13,7 +13,7 @@ type SystemSetting struct { @@ -13,7 +13,7 @@ type SystemSetting struct {
13 // 设置对应的名称 13 // 设置对应的名称
14 SettingName string `json:"settingName"` 14 SettingName string `json:"settingName"`
15 // 数据id 15 // 数据id
16 - SystemSettingId int64 `json:"systemSettingId"` 16 + SystemSettingId int64 `json:"systemSettingId,string"`
17 // 设定的值 17 // 设定的值
18 Value string `json:"value"` 18 Value string `json:"value"`
19 // 值类型 19 // 值类型