FortuneBase.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. declare(strict_types=1);
  3. namespace ImiApp\Model\Base;
  4. use Imi\Config\Annotation\ConfigValue;
  5. use Imi\Model\Annotation\Column;
  6. use Imi\Model\Annotation\DDL;
  7. use Imi\Model\Annotation\Entity;
  8. use Imi\Model\Annotation\Table;
  9. use Imi\Model\Model as Model;
  10. /**
  11. * fortune 基类.
  12. *
  13. * @Entity(camel=true, bean=false, incrUpdate=false)
  14. * @Table(name=@ConfigValue(name="@app.models.ImiApp\Model\Fortune.name", default="fortune"), usePrefix=false, id={"id"}, dbPoolName=@ConfigValue(name="@app.models.ImiApp\Model\Fortune.poolName"))
  15. * @DDL(sql="CREATE TABLE `fortune` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `message` varchar(2048) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", decode="")
  16. *
  17. * @property int|null $id
  18. * @property string|null $message
  19. */
  20. abstract class FortuneBase extends Model
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public const PRIMARY_KEY = 'id';
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public const PRIMARY_KEYS = ["id"];
  30. /**
  31. * id.
  32. * @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true, unsigned=true, virtual=false)
  33. * @var int|null
  34. */
  35. protected ?int $id = NULL;
  36. /**
  37. * 获取 id.
  38. *
  39. * @return int|null
  40. */
  41. public function getId(): ?int
  42. {
  43. return $this->id;
  44. }
  45. /**
  46. * 赋值 id.
  47. * @param int|null $id id
  48. * @return static
  49. */
  50. public function setId($id)
  51. {
  52. $this->id = null === $id ? null : (int)$id;
  53. return $this;
  54. }
  55. /**
  56. * message.
  57. * @Column(name="message", type="varchar", length=2048, accuracy=0, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false, unsigned=false, virtual=false)
  58. * @var string|null
  59. */
  60. protected ?string $message = NULL;
  61. /**
  62. * 获取 message.
  63. *
  64. * @return string|null
  65. */
  66. public function getMessage(): ?string
  67. {
  68. return $this->message;
  69. }
  70. /**
  71. * 赋值 message.
  72. * @param string|null $message message
  73. * @return static
  74. */
  75. public function setMessage($message)
  76. {
  77. $this->message = null === $message ? null : (string)$message;
  78. return $this;
  79. }
  80. }