设置增减 @param table 需要处理的数据表 @param field 字段 @param condition 条件 @param incre 是否是增长值,true则增加,false则减少 @param step 增或减的步长
(table string, field string, condition string, incre bool, step ...int)
| 60 | //@param incre 是否是增长值,true则增加,false则减少 |
| 61 | //@param step 增或减的步长 |
| 62 | func SetIncreAndDecre(table string, field string, condition string, incre bool, step ...int) (err error) { |
| 63 | mark := "-" |
| 64 | if incre { |
| 65 | mark = "+" |
| 66 | } |
| 67 | s := 1 |
| 68 | if len(step) > 0 { |
| 69 | s = step[0] |
| 70 | } |
| 71 | sql := fmt.Sprintf("update %v set %v=%v%v%v where %v", table, field, field, mark, s, condition) |
| 72 | _, err = orm.NewOrm().Raw(sql).Exec() |
| 73 | return |
| 74 | } |
| 75 | |
| 76 | type SitemapDocs struct { |
| 77 | DocumentId int |
no outgoing calls
no test coverage detected