UserCertificationDao.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020-04-28
  7. *
  8. *
  9. */
  10. namespace app\common\dao\user;
  11. use app\common\dao\BaseDao;
  12. use app\common\model\BaseModel;
  13. use app\common\model\user\UserCertification;
  14. use app\entity\data\user\UserCertificationEntity;
  15. use think\db\exception\DataNotFoundException;
  16. use think\db\exception\DbException;
  17. use think\db\exception\ModelNotFoundException;
  18. /**
  19. * Class UserDao
  20. * @package app\common\dao\user
  21. * @author xaboy
  22. * @day 2020-04-28
  23. */
  24. class UserCertificationDao extends BaseDao
  25. {
  26. /**
  27. * @return BaseModel
  28. * @author xaboy
  29. * @day 2020-03-30
  30. */
  31. protected function getModel(): string
  32. {
  33. return UserCertification::class;
  34. }
  35. /**
  36. * @param array $idList
  37. * @return UserCertificationEntity[]
  38. */
  39. public function getUserCertificationEntityListByIdList(array $idList): array
  40. {
  41. $entityList = [];
  42. try {
  43. $dataList = UserCertification::getDB()
  44. ->whereIn('id', $idList)
  45. ->select()
  46. ->toArray();
  47. if (!empty($dataList)) {
  48. $entityList = array_map(function ($data) {
  49. return UserCertificationEntity::newInstance($data);
  50. }, $dataList);
  51. }
  52. } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
  53. }
  54. return $entityList;
  55. }
  56. /**
  57. * @param array $uidList
  58. * @return UserCertificationEntity[]
  59. */
  60. public function getUserCertificationEntityListByUidList(array $uidList): array
  61. {
  62. $entityList = [];
  63. try {
  64. $dataList = UserCertification::getDB()
  65. ->whereIn('uid', $uidList)
  66. ->select()
  67. ->toArray();
  68. if (!empty($dataList)) {
  69. $entityList = array_map(function ($data) {
  70. return UserCertificationEntity::newInstance($data);
  71. }, $dataList);
  72. }
  73. } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
  74. }
  75. return $entityList;
  76. }
  77. }