PointDto.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Module\Point\Dto;
  3. /**
  4. * 积分DTO类
  5. *
  6. * 用于传输积分相关数据
  7. */
  8. class PointDto
  9. {
  10. public int $id;
  11. public int $user_id;
  12. public int $point_id;
  13. public int $balance;
  14. public int $create_time;
  15. public int $update_time;
  16. public function __construct(array $data = [])
  17. {
  18. $this->id = $data['id'] ?? 0;
  19. $this->user_id = $data['user_id'] ?? 0;
  20. $this->point_id = $data['point_id'] ?? 0;
  21. $this->balance = $data['balance'] ?? 0;
  22. $this->create_time = $data['create_time'] ?? 0;
  23. $this->update_time = $data['update_time'] ?? 0;
  24. }
  25. /**
  26. * 转换为数组
  27. *
  28. * @return array
  29. */
  30. public function toArray(): array
  31. {
  32. return [
  33. 'id' => $this->id,
  34. 'user_id' => $this->user_id,
  35. 'point_id' => $this->point_id,
  36. 'balance' => $this->balance,
  37. 'create_time' => $this->create_time,
  38. 'update_time' => $this->update_time,
  39. ];
  40. }
  41. }