Demo.php 745 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 97
  5. */
  6. namespace app\common\business;
  7. use app\common\model\mysql\Demo as mysqlDemo;
  8. class Demo{
  9. /**
  10. * business 层通过 getDemoDataByCategoryId 来获取数据
  11. * @param $categoryId
  12. * @param int $limit
  13. * @return array
  14. */
  15. public function getDemoDataByCategoryId($categoryId,$limit = 10){
  16. $model = new mysqlDemo;
  17. $results = $model->getDemoDataByCategoryId($categoryId);
  18. if(empty($results)){
  19. return [];
  20. }
  21. $cagegorys = config("category");
  22. foreach ($results as $key=>$result){
  23. $results[$key]['categoryName'] = $cagegorys[$result['category_id']] ?? '--';
  24. }
  25. return $results;
  26. }
  27. }