SharedProsperityRecommendConfigDao.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\common\dao\shared;
  3. use app\common\dao\BaseDao;
  4. use app\common\model\shared\SharedProsperityRecommendConfig;
  5. use app\entity\data\shared\SharedProsperityRecommendConfigEntity;
  6. class SharedProsperityRecommendConfigDao extends BaseDao
  7. {
  8. protected function getModel(): string
  9. {
  10. return SharedProsperityRecommendConfig::class;
  11. }
  12. /**
  13. * @return array
  14. * @author 史晨
  15. * @date 2026/2/5 14:43
  16. * 获取推荐配置
  17. */
  18. public function getConfigList(): array
  19. {
  20. $entityList = [];
  21. try {
  22. /** @var SharedProsperityRecommendConfig $model */
  23. $model = $this->getModel();
  24. $dataRes = $model::getDB()
  25. ->select()
  26. ->toArray();
  27. if (!empty($dataRes)) {
  28. $entityList = array_map(function ($data) {
  29. return SharedProsperityRecommendConfigEntity::newInstance($data);
  30. }, $dataRes);
  31. }
  32. } catch (\Exception $e) {
  33. }
  34. return $entityList;
  35. }
  36. /**
  37. * @param $id
  38. * @return mixed
  39. * @author 史晨
  40. * @date 2026/2/5 14:43
  41. * 获取推荐配置详情
  42. */
  43. public function getDetailById($id)
  44. {
  45. /** @var SharedProsperityRecommendConfig $model */
  46. $model = $this->getModel();
  47. return $model::getDB()
  48. ->where(['id'=>$id])
  49. ->find();
  50. }
  51. }