ConditionItemDto.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace App\Module\Game\Dtos;
  3. /**
  4. * 条件项DTO
  5. */
  6. class ConditionItemDto
  7. {
  8. /**
  9. * 条件项ID
  10. *
  11. * @var int
  12. */
  13. public int $id;
  14. /**
  15. * 条件组ID
  16. *
  17. * @var int
  18. */
  19. public int $groupId;
  20. /**
  21. * 条件类型
  22. *
  23. * @var int
  24. */
  25. public int $conditionType;
  26. /**
  27. * 目标ID
  28. *
  29. * @var int
  30. */
  31. public int $targetId;
  32. /**
  33. * 比较运算符
  34. *
  35. * @var int
  36. */
  37. public int $operator;
  38. /**
  39. * 比较值
  40. *
  41. * @var int
  42. */
  43. public int $value;
  44. /**
  45. * 参数1
  46. *
  47. * @var int
  48. */
  49. public int $param1;
  50. /**
  51. * 参数2
  52. *
  53. * @var int
  54. */
  55. public int $param2;
  56. /**
  57. * 额外数据
  58. *
  59. * @var array|null
  60. */
  61. public ?array $extraData;
  62. /**
  63. * 从模型创建DTO
  64. *
  65. * @param \App\Module\Game\Models\GameConditionItem $model
  66. * @return self
  67. */
  68. public static function fromModel($model): self
  69. {
  70. $dto = new self();
  71. $dto->id = $model->id;
  72. $dto->groupId = $model->group_id;
  73. $dto->conditionType = $model->condition_type;
  74. $dto->targetId = $model->target_id;
  75. $dto->operator = $model->operator;
  76. $dto->value = $model->value;
  77. $dto->param1 = $model->param1;
  78. $dto->param2 = $model->param2;
  79. $dto->extraData = $model->extra_data;
  80. return $dto;
  81. }
  82. }