作者 yangfu

计数

@@ -198,7 +198,11 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq @@ -198,7 +198,11 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq
198 var sql *bytes.Buffer 198 var sql *bytes.Buffer
199 sql = bytes.NewBuffer(nil) 199 sql = bytes.NewBuffer(nil)
200 sql.WriteString(fmt.Sprintf("update %s set %s=%s+%d ", table, column, column, incre)) 200 sql.WriteString(fmt.Sprintf("update %s set %s=%s+%d ", table, column, column, incre))
201 - sql.WriteString(fmt.Sprintf(" where id=%d", id)) 201 + if incre > 0 {
  202 + sql.WriteString(fmt.Sprintf(" where id=%d", id))
  203 + } else {
  204 + sql.WriteString(fmt.Sprintf(" where id=%d and %v>0", id, column))
  205 + }
202 return &utils.SqlData{ 206 return &utils.SqlData{
203 Sql: sql.String(), 207 Sql: sql.String(),
204 } 208 }