SharedProsperityRecommendConfigRepository.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\common\repositories\shared;
  3. use app\common\dao\shared\SharedProsperityRecommendConfigDao;
  4. use app\common\repositories\BaseRepository;
  5. use app\entity\data\shared\SharedProsperityRecommendConfigEntity;
  6. class SharedProsperityRecommendConfigRepository extends BaseRepository
  7. {
  8. protected $dao;
  9. /**
  10. * SharedProsperityUserRepository constructor.
  11. * @param SharedProsperityRecommendConfigDao $dao
  12. */
  13. public function __construct(SharedProsperityRecommendConfigDao $dao)
  14. {
  15. $this->dao = $dao;
  16. }
  17. public function create($data)
  18. {
  19. return $this->dao->create($data);
  20. }
  21. /**
  22. * @param SharedProsperityRecommendConfigEntity $sharedProsperityRecommendConfigEntity
  23. * @return SharedProsperityRecommendConfigEntity
  24. */
  25. public function createByEntity(SharedProsperityRecommendConfigEntity $sharedProsperityRecommendConfigEntity): SharedProsperityRecommendConfigEntity
  26. {
  27. $result = $this->create($sharedProsperityRecommendConfigEntity->toUnderlineArray())->toArray();
  28. /** @var SharedProsperityRecommendConfigEntity $entity */
  29. $entity = SharedProsperityRecommendConfigEntity::newInstance($result);
  30. return $entity;
  31. }
  32. /**
  33. * @return array
  34. * @author 史晨
  35. * @date 2026/2/5 14:12
  36. */
  37. public function getList(): array
  38. {
  39. return $this->dao->getConfigList();
  40. }
  41. /**
  42. * @param $id
  43. * @return array
  44. * @author 史晨
  45. * @date 2026/2/5 14:12
  46. */
  47. public function getDetail($id)
  48. {
  49. return $this->dao->getDetailById($id);
  50. }
  51. /**
  52. * @param $params
  53. * @return bool
  54. * @author 史晨
  55. * @date 2026/2/5 14:12
  56. */
  57. public function update($params)
  58. {
  59. $id = $params['id'];
  60. unset($params['id']);
  61. if (!$this->dao->update($id, $params)){
  62. return false;
  63. }
  64. return true;
  65. }
  66. }