MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Delete

Method Delete

models/read_record.go:304–320  ·  view source on GitHub ↗

删除单条阅读记录

(uid, docId int)

Source from the content-addressed store, hash-verified

302
303//删除单条阅读记录
304func (this *ReadRecord) Delete(uid, docId int) (err error) {
305 if uid*docId == 0 {
306 err = errors.New("用户id和文档id不能为空")
307 return
308 }
309
310 var record ReadRecord
311
312 o := orm.NewOrm()
313 o.QueryTable(tableReadRecord).Filter("uid", uid).Filter("doc_id", docId).One(&record, "book_id", "id")
314 if record.BookId > 0 { //存在,则删除该阅读记录
315 if _, err = o.QueryTable(tableReadRecord).Filter("id", record.Id).Delete(); err == nil {
316 err = SetIncreAndDecre(tableReadCount, "cnt", "book_id="+strconv.Itoa(record.BookId)+" and uid="+strconv.Itoa(uid), false, 1)
317 }
318 }
319 return
320}
321
322// 更新签到奖励规则
323func (*ReadRecord) UpdateReadingRule() {

Callers 2

AddMethod · 0.45
ClearMethod · 0.45

Calls 1

SetIncreAndDecreFunction · 0.85

Tested by

no test coverage detected