Skip to content

Commit d50533a

Browse files
authored
Merge pull request #1344 from WeBankPartners/dev
Dev
2 parents 497ea09 + 8aad967 commit d50533a

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

cmdb-server/api/v1/ci/ci_data.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func SimpleCiDataImport(c *gin.Context) {
265265
}
266266
if attrObj, ok := attrIndexMap[k]; ok {
267267
if attrObj.InputType == "ref" {
268-
if tmpGuidList, tmpErr := db.GetGuidByKeyName(attrObj.RefCiType, []string{v}); tmpErr != nil {
268+
if tmpGuidList, tmpErr := db.GetGuidByKeyNameOrGuid(attrObj.RefCiType, []string{v}); tmpErr != nil {
269269
err = tmpErr
270270
break
271271
} else {
@@ -277,7 +277,7 @@ func SimpleCiDataImport(c *gin.Context) {
277277
}
278278
}
279279
} else if attrObj.InputType == "multiRef" {
280-
if tmpGuidList, tmpErr := db.GetGuidByKeyName(attrObj.RefCiType, strings.Split(v, ",")); tmpErr != nil {
280+
if tmpGuidList, tmpErr := db.GetGuidByKeyNameOrGuid(attrObj.RefCiType, strings.Split(v, ",")); tmpErr != nil {
281281
err = tmpErr
282282
break
283283
} else {

cmdb-server/services/db/ci_data.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,15 +2184,22 @@ func getMultiStringInputTypeValue(inputType, value string) []string {
21842184
return result
21852185
}
21862186

2187-
func GetGuidByKeyName(ciType string, keyNameList []string) (guidList []string, err error) {
2187+
func GetGuidByKeyNameOrGuid(ciType string, keyNameList []string) (guidList []string, err error) {
21882188
if len(keyNameList) == 0 {
21892189
return
21902190
}
21912191
dataRows, queryErr := x.QueryString(fmt.Sprintf("select guid,key_name from `%s` where key_name in ('%s')", ciType, strings.Join(keyNameList, "','")))
21922192
if queryErr != nil {
2193-
err = fmt.Errorf("query %s table fail,%s ", ciType, queryErr.Error())
2193+
err = fmt.Errorf("query %s table with key_name fail,%s ", ciType, queryErr.Error())
21942194
return
21952195
}
2196+
if len(dataRows) == 0 {
2197+
dataRows, queryErr = x.QueryString(fmt.Sprintf("select guid,key_name from `%s` where guid in ('%s')", ciType, strings.Join(keyNameList, "','")))
2198+
if queryErr != nil {
2199+
err = fmt.Errorf("query %s table with guid fail,%s ", ciType, queryErr.Error())
2200+
return
2201+
}
2202+
}
21962203
for _, v := range dataRows {
21972204
guidList = append(guidList, v["guid"])
21982205
}

cmdb-server/services/db/ci_data_rule.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ func buildAutofillValue(columnMap map[string]string, rule, attrInputType string)
5151
err = fmt.Errorf("buildCalcFillValue fail,%s ", calcErr.Error())
5252
return
5353
}
54-
if calcResult < 0 {
55-
err = fmt.Errorf("buildCalcFillValue fail,value:%3.f < 0", calcResult)
56-
return
57-
}
54+
// if calcResult < 0 {
55+
// err = fmt.Errorf("buildCalcFillValue fail,value:%3.f < 0", calcResult)
56+
// return
57+
// }
5858
newValueList = append(newValueList, transFloatValueToString(fmt.Sprintf("%.3f", calcResult)))
5959
log.Debug(nil, log.LOGGER_APP, "-----end buildAutofillValue with calcFillFlag", zap.Strings("result", newValueList))
6060
return

cmdb-ui/src/pages/designing/ci-data.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ export default {
854854
this.$refs[this.tableRef][0].resetModalLoading()
855855
if (statusCode === 'OK') {
856856
this.$Notice.success({
857-
title: this.$t('add_data_success'),
857+
title: this.$t('db_operation_successful'),
858858
desc: message
859859
})
860860
this.queryCiData()

0 commit comments

Comments
 (0)