(bookId int, isPV bool)
| 51 | } |
| 52 | |
| 53 | func (*BookCounter) Increase(bookId int, isPV bool) { |
| 54 | sc := NewBookCounter() |
| 55 | today, _ := strconv.Atoi(time.Now().Format(dateFormat)) |
| 56 | o := orm.NewOrm() |
| 57 | o.QueryTable(sc).Filter("bid", bookId).Filter("day", today).One(sc) |
| 58 | if sc.Id == 0 { |
| 59 | sc = &BookCounter{ |
| 60 | Bid: bookId, |
| 61 | Day: today, |
| 62 | } |
| 63 | if isPV { |
| 64 | sc.ViewCnt = 1 |
| 65 | } else { |
| 66 | sc.StarCnt = 1 |
| 67 | } |
| 68 | o.Insert(sc) |
| 69 | } else { |
| 70 | if isPV { |
| 71 | sc.ViewCnt += 1 |
| 72 | } else { |
| 73 | sc.StarCnt += 1 |
| 74 | } |
| 75 | o.Update(sc) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | func (*BookCounter) Decrease(bookId int, isPV bool) { |
| 80 | sc := NewBookCounter() |
no test coverage detected