Queue.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\other\queue;
  12. use crmeb\traits\ModelTrait;
  13. use crmeb\basic\BaseModel;
  14. use think\Model;
  15. /**
  16. * 队列model
  17. * Class Queue
  18. * @package app\model\other\queue
  19. */
  20. class Queue extends BaseModel
  21. {
  22. use ModelTrait;
  23. const EXPIRE = 0;
  24. /**
  25. * 主键
  26. * @var string
  27. */
  28. protected $pk = 'id';
  29. /**
  30. * 模型名称
  31. * @var string
  32. */
  33. protected $name = 'queue_list';
  34. /**
  35. * 缓存KEY搜索器
  36. * @param Model $query
  37. * @param $value
  38. * @param $data
  39. */
  40. public function searchExecuteKeyAttr($query, $value, $data)
  41. {
  42. if ($value) $query->where('execute_key', $value);
  43. }
  44. /**
  45. * 队列类型搜索器
  46. * @param $query
  47. * @param $value
  48. */
  49. public function searchTypeAttr($query, $value)
  50. {
  51. if ($value) {
  52. if (is_array($value)) {
  53. if ($value) $query->whereIn('type', $value);
  54. } else {
  55. if ($value) $query->where('type', $value);
  56. }
  57. }
  58. }
  59. /**
  60. * 队列主键搜索器
  61. * @param $query
  62. * @param $value
  63. */
  64. public function searchIdAttr($query, $value)
  65. {
  66. if ($value) $query->where('id', $value);
  67. }
  68. /**
  69. * 队列状态搜索器
  70. * @param $query
  71. * @param $value
  72. */
  73. public function searchStatusAttr($query, $value)
  74. {
  75. if ($value) {
  76. if (is_array($value)) {
  77. $query->whereIn('status', $value);
  78. } else {
  79. $query->where('status', $value);
  80. }
  81. }
  82. }
  83. }