获取阅读记录列表
()
| 20 | |
| 21 | //获取阅读记录列表 |
| 22 | func (this *RecordController) List() { |
| 23 | var ( |
| 24 | lists []map[string]interface{} |
| 25 | err error |
| 26 | rl []models.RecordList |
| 27 | rp models.ReadProgress |
| 28 | errCode int |
| 29 | message string = "数据查询成功" |
| 30 | count int64 |
| 31 | ) |
| 32 | bookId, _ := this.GetInt(":book_id") |
| 33 | if bookId > 0 { |
| 34 | m := new(models.ReadRecord) |
| 35 | if rl, count, err = m.List(this.Member.MemberId, bookId); err == nil && len(rl) > 0 { |
| 36 | rp, _ = m.Progress(this.Member.MemberId, bookId) |
| 37 | for _, item := range rl { |
| 38 | var list = make(map[string]interface{}) |
| 39 | list["title"] = item.Title |
| 40 | list["url"] = beego.URLFor("DocumentController.Read", ":key", rp.BookIdentify, ":id", item.Identify) |
| 41 | list["time"] = time.Unix(int64(item.CreateAt), 0).Format("01-02 15:04") |
| 42 | list["del"] = beego.URLFor("RecordController.Delete", ":doc_id", item.DocId) |
| 43 | lists = append(lists, list) |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | if len(lists) == 0 { |
| 48 | errCode = 1 |
| 49 | message = "您当前没有阅读记录" |
| 50 | } |
| 51 | this.JsonResult(errCode, message, map[string]interface{}{ |
| 52 | "lists": lists, |
| 53 | "count": count, |
| 54 | "progress": rp, |
| 55 | "clear": beego.URLFor("RecordController.Clear", ":book_id", bookId), |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | //重置阅读进度(清空阅读历史) |
| 60 | func (this *RecordController) Clear() { |
nothing calls this directly
no test coverage detected