|
@@ -200,6 +200,7 @@ func updateInsertConfigValueByMysql(to *gorm.DB, edbInfo *EdbInfo, oldConfigDate
|
|
|
if !oldConfigDate.IsZero() {
|
|
|
sql := `SELECT edb_data_id,edb_info_id,data_time,value,data_timestamp FROM %s WHERE edb_info_id=? AND data_time = ?`
|
|
|
sql = fmt.Sprintf(sql, tableName)
|
|
|
+ sql = utils.ReplaceDriverKeywords("", sql)
|
|
|
err = to.Raw(sql, tableName, edbInfo.EdbInfoId, oldConfigDate.Format(utils.FormatDate)).First(&edbDateData).Error
|
|
|
//err = to.Raw(sql, edbInfo.EdbInfoId, oldConfigDate.Format(utils.FormatDate)).QueryRow(&edbDateData)
|
|
|
if err != nil && !utils.IsErrNoRow(err) {
|
|
@@ -212,6 +213,7 @@ func updateInsertConfigValueByMysql(to *gorm.DB, edbInfo *EdbInfo, oldConfigDate
|
|
|
if edbDateData == nil {
|
|
|
addSql := ` INSERT INTO %s (edb_info_id,edb_code,data_time,value,create_time,modify_time,data_timestamp) VALUES ( %d, "%s", "%s", "%s", now(), now(), %s) `
|
|
|
addSql = fmt.Sprintf(addSql, tableName, edbInfo.EdbInfoId, edbInfo.EdbCode, dateStr, saveValue, timeStr)
|
|
|
+ addSql = utils.ReplaceDriverKeywords("", addSql)
|
|
|
err = to.Exec(addSql).Error
|
|
|
//_, err = to.Raw(addSql).Exec()
|
|
|
} else if value == "" {
|
|
@@ -232,6 +234,7 @@ func updateInsertConfigValueByMysql(to *gorm.DB, edbInfo *EdbInfo, oldConfigDate
|
|
|
err = to.Exec(deleteSql).Error
|
|
|
} else {
|
|
|
updateSql := `UPDATE %s SET data_time = "%s", value = "%s", modify_time= now(), data_timestamp= %s WHERE edb_data_id = %d;`
|
|
|
+ updateSql = utils.ReplaceDriverKeywords("", updateSql)
|
|
|
updateSql = fmt.Sprintf(updateSql, tableName, dateStr, saveValue, timeStr, edbDateData.EdbDataId)
|
|
|
//_, err = to.Raw(updateSql).Exec()
|
|
|
err = to.Exec(updateSql).Error
|