Userdelrecentreadcount.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\admin\controller\auth;
  3. class Userdelrecentreadcount extends UserDetailBase
  4. {
  5. public function _initialize()
  6. {
  7. parent::_initialize();
  8. }
  9. public function index()
  10. {
  11. if ($this->request->isAjax()) {
  12. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  13. $data = $this->userRecentlyReadModel->setConnect($this->ids)
  14. ->where(['user_id' => $this->ids, 'flag' => 0])
  15. ->where($where)
  16. ->limit($offset, $limit)
  17. ->order('updatetime desc')
  18. ->select();
  19. $total = $this->userRecentlyReadModel->setConnect($this->ids)
  20. ->where(['user_id' => $this->ids, 'flag' => 0])
  21. ->where($where)
  22. ->count();
  23. if($data){
  24. foreach ($data as $key => $item)
  25. {
  26. $bookName = model('Book')->where(['id'=>$item['book_id']])->find();
  27. if($bookName){
  28. $data[$key]['bookname'] = $bookName->name;
  29. }else{
  30. $data[$key]['bookname'] = '未知';
  31. }
  32. $data[$key]['updatetime'] = date('Y-m-d H:i:s', $item['updatetime']);
  33. }
  34. }
  35. $result = array("total" => $total, "rows" => $data);
  36. return json($result);
  37. }
  38. $this->view->assign('title', '已删除阅读记录');
  39. $this->view->assign('type', 'userdelrecentreadcount');
  40. return $this->view->fetch();
  41. }
  42. }