参数配置插入结果返回记录ID
This commit is contained in:
@@ -260,13 +260,18 @@ func (r *RepoSysConfig) InsertConfig(sysConfig model.SysConfig) string {
|
||||
sql := "insert into sys_config (" + strings.Join(keys, ",") + ")values(" + placeholder + ")"
|
||||
|
||||
// 执行插入
|
||||
rows, err := datasource.ExecDB("", sql, values)
|
||||
results, err := datasource.ExecDB("", sql, values)
|
||||
if err != nil {
|
||||
log.Errorf("insert row : %v", err.Error())
|
||||
return ""
|
||||
}
|
||||
|
||||
return fmt.Sprint(rows)
|
||||
insertId, err := results.LastInsertId()
|
||||
if err != nil {
|
||||
log.Errorf("insert row : %v", err.Error())
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprint(insertId)
|
||||
}
|
||||
|
||||
// UpdateConfig 修改参数配置
|
||||
@@ -299,12 +304,17 @@ func (r *RepoSysConfig) UpdateConfig(sysConfig model.SysConfig) int64 {
|
||||
|
||||
// 执行更新
|
||||
values = append(values, sysConfig.ConfigID)
|
||||
rows, err := datasource.ExecDB("", sql, values)
|
||||
results, err := datasource.ExecDB("", sql, values)
|
||||
if err != nil {
|
||||
log.Errorf("update row : %v", err.Error())
|
||||
return 0
|
||||
}
|
||||
return rows
|
||||
affected, err := results.RowsAffected()
|
||||
if err != nil {
|
||||
log.Errorf("update err => %v", err)
|
||||
return 0
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// DeleteConfigByIds 批量删除参数配置信息
|
||||
@@ -317,5 +327,10 @@ func (r *RepoSysConfig) DeleteConfigByIds(configIds []string) int64 {
|
||||
log.Errorf("delete err => %v", err)
|
||||
return 0
|
||||
}
|
||||
return results
|
||||
affected, err := results.RowsAffected()
|
||||
if err != nil {
|
||||
log.Errorf("delete err => %v", err)
|
||||
return 0
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user