控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Attachments.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 会员附件类
  13. // +----------------------------------------------------------------------
  14. namespace app\member\controller;
  15. use app\common\model\Attachment;
  16. class Attachments extends MemberBase
  17. {
  18. //附件列表页
  19. public function select()
  20. {
  21. $this->request->filter('trim,strip_tags');
  22. if ($this->request->isAjax()) {
  23. $page = $this->request->param('page', 1);
  24. $limit = $this->request->param('limit', 15);
  25. $filters = $this->request->param('filter', '{}');
  26. $ops = $this->request->param('op', '{}');
  27. $filters = (array) json_decode($filters, true);
  28. $ops = (array) json_decode($ops, true);
  29. $where = [];
  30. foreach ($filters as $key => $val) {
  31. $op = isset($ops[$key]) && !empty($ops[$key]) ? $ops[$key] : '%*%';
  32. switch (strtolower($op)) {
  33. case '=':
  34. $where[] = [$key, '=', $val];
  35. break;
  36. case '%*%':
  37. $where[] = [$key, 'LIKE', "%{$val}%"];
  38. break;
  39. case '*%':
  40. $where[] = [$key, 'LIKE', "{$val}%"];
  41. break;
  42. case '%*':
  43. $where[] = [$key, 'LIKE', "%{$val}"];
  44. break;
  45. case 'range':
  46. list($beginTime, $endTime) = explode(' - ', $val);
  47. $where[] = [$key, '>=', strtotime($beginTime)];
  48. $where[] = [$key, '<=', strtotime($endTime)];
  49. break;
  50. default:
  51. $where[] = [$key, $op, "%{$val}"];
  52. };
  53. };
  54. $total = Attachment::where($where)
  55. ->where($where)
  56. ->where('user_id', $this->auth->id)
  57. ->order('id', 'desc')
  58. ->count();
  59. $_list = Attachment::where($where)
  60. ->where($where)
  61. ->where('user_id', $this->auth->id)
  62. ->page($page, $limit)
  63. ->order('id', 'desc')
  64. ->select();
  65. $result = ["code" => 0, "count" => $total, "data" => $_list];
  66. return json($result);
  67. }
  68. $mimetype = $this->request->param('mimetype', '');
  69. $mimetype = substr($mimetype, -1) === '/' ? $mimetype . '*' : $mimetype;
  70. $this->assign('mimetype', $mimetype);
  71. return $this->fetch('/attachment');
  72. }
  73. }