CommentEnum.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace app\common\Enum;
  3. class CommentEnum
  4. {
  5. /**
  6. * 评价状态
  7. */
  8. const EVALUATE_STATUS_PENDING = 1; // 审核中
  9. const EVALUATE_STATUS_APPROVED = 2; // 审核通过
  10. const EVALUATE_STATUS_REJECTED = 3; // 审核失败
  11. /**
  12. * 显示状态
  13. */
  14. const STATUS_NORMAL = 'normal'; // 正常显示
  15. const STATUS_HIDDEN = 'hidden'; // 隐藏
  16. /**
  17. * 是否有图片
  18. */
  19. const HAS_PICTURE_NO = 0; // 无图片
  20. const HAS_PICTURE_YES = 1; // 有图片
  21. /**
  22. * 获取评价状态文本
  23. * @param int $status
  24. * @return string
  25. */
  26. public static function getEvaluateStatusText($status)
  27. {
  28. $statusMap = [
  29. self::EVALUATE_STATUS_PENDING => '审核中',
  30. self::EVALUATE_STATUS_APPROVED => '审核通过',
  31. self::EVALUATE_STATUS_REJECTED => '审核失败'
  32. ];
  33. return isset($statusMap[$status]) ? $statusMap[$status] : '未知状态';
  34. }
  35. /**
  36. * 获取显示状态文本
  37. * @param string $status
  38. * @return string
  39. */
  40. public static function getStatusText($status)
  41. {
  42. $statusMap = [
  43. self::STATUS_NORMAL => '正常显示',
  44. self::STATUS_HIDDEN => '隐藏'
  45. ];
  46. return isset($statusMap[$status]) ? $statusMap[$status] : '未知状态';
  47. }
  48. /**
  49. * 获取有图片状态文本
  50. * @param int $hasPicture
  51. * @return string
  52. */
  53. public static function getHasPictureText($hasPicture)
  54. {
  55. $statusMap = [
  56. self::HAS_PICTURE_NO => '无图片',
  57. self::HAS_PICTURE_YES => '有图片'
  58. ];
  59. return isset($statusMap[$hasPicture]) ? $statusMap[$hasPicture] : '未知状态';
  60. }
  61. /**
  62. * 获取所有评价状态
  63. * @return array
  64. */
  65. public static function getEvaluateStatusList()
  66. {
  67. return [
  68. self::EVALUATE_STATUS_PENDING => '审核中',
  69. self::EVALUATE_STATUS_APPROVED => '审核通过',
  70. self::EVALUATE_STATUS_REJECTED => '审核失败'
  71. ];
  72. }
  73. /**
  74. * 获取所有显示状态
  75. * @return array
  76. */
  77. public static function getStatusList()
  78. {
  79. return [
  80. self::STATUS_NORMAL => '正常显示',
  81. self::STATUS_HIDDEN => '隐藏'
  82. ];
  83. }
  84. /**
  85. * 获取所有有图片状态
  86. * @return array
  87. */
  88. public static function getHasPictureList()
  89. {
  90. return [
  91. self::HAS_PICTURE_NO => '无图片',
  92. self::HAS_PICTURE_YES => '有图片'
  93. ];
  94. }
  95. /**
  96. * 验证评价状态
  97. * @param int $status
  98. * @return bool
  99. */
  100. public static function isValidEvaluateStatus($status)
  101. {
  102. return in_array($status, [
  103. self::EVALUATE_STATUS_PENDING,
  104. self::EVALUATE_STATUS_APPROVED,
  105. self::EVALUATE_STATUS_REJECTED
  106. ]);
  107. }
  108. /**
  109. * 验证显示状态
  110. * @param string $status
  111. * @return bool
  112. */
  113. public static function isValidStatus($status)
  114. {
  115. return in_array($status, [
  116. self::STATUS_NORMAL,
  117. self::STATUS_HIDDEN
  118. ]);
  119. }
  120. /**
  121. * 验证有图片状态
  122. * @param int $hasPicture
  123. * @return bool
  124. */
  125. public static function isValidHasPicture($hasPicture)
  126. {
  127. return in_array($hasPicture, [
  128. self::HAS_PICTURE_NO,
  129. self::HAS_PICTURE_YES
  130. ]);
  131. }
  132. }