ArticleService.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\extra\service\blue;
  3. use app\extra\basic\Service;
  4. use app\model\blue\BlueArticle;
  5. use app\model\blue\BlueCategory;
  6. class ArticleService extends Service
  7. {
  8. /**
  9. * 列表
  10. * @param array $param
  11. */
  12. public function getList(array $param = [])
  13. {
  14. $this->mode = new BlueArticle();
  15. return $this->searchVal($param,$this->searchFilter($param))->with(['categoryJoin' => function($query){
  16. $query->field("id,name");
  17. }])->paginate([
  18. "list_rows" => $param['pageSize'],
  19. "page" => $param['page']
  20. ]);
  21. }
  22. /**
  23. *
  24. * @param array $param
  25. * @return array
  26. */
  27. public function searchFilter(array $param = []): array
  28. {
  29. $filter = [];
  30. !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
  31. !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
  32. !empty($param['name']) && $filter[] = ["name", 'like', "%{$param['name']}%"];
  33. return $filter;
  34. }
  35. }