CommentEnum.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 HAS_PICTURE_NO = 0; // 无图片
  15. const HAS_PICTURE_YES = 1; // 有图片
  16. /**
  17. * 获取评价状态文本
  18. * @param int $status
  19. * @return string
  20. */
  21. public static function getEvaluateStatusText($status)
  22. {
  23. $statusMap = [
  24. self::EVALUATE_STATUS_PENDING => '审核中',
  25. self::EVALUATE_STATUS_APPROVED => '审核通过',
  26. self::EVALUATE_STATUS_REJECTED => '审核失败'
  27. ];
  28. return isset($statusMap[$status]) ? $statusMap[$status] : '未知状态';
  29. }
  30. /**
  31. * 获取有图片状态文本
  32. * @param int $hasPicture
  33. * @return string
  34. */
  35. public static function getHasPictureText($hasPicture)
  36. {
  37. $statusMap = [
  38. self::HAS_PICTURE_NO => '无图片',
  39. self::HAS_PICTURE_YES => '有图片'
  40. ];
  41. return isset($statusMap[$hasPicture]) ? $statusMap[$hasPicture] : '未知状态';
  42. }
  43. /**
  44. * 获取所有评价状态
  45. * @return array
  46. */
  47. public static function getEvaluateStatusList()
  48. {
  49. return [
  50. self::EVALUATE_STATUS_PENDING => '审核中',
  51. self::EVALUATE_STATUS_APPROVED => '审核通过',
  52. self::EVALUATE_STATUS_REJECTED => '审核失败'
  53. ];
  54. }
  55. /**
  56. * 获取所有有图片状态
  57. * @return array
  58. */
  59. public static function getHasPictureList()
  60. {
  61. return [
  62. self::HAS_PICTURE_NO => '无图片',
  63. self::HAS_PICTURE_YES => '有图片'
  64. ];
  65. }
  66. /**
  67. * 验证评价状态
  68. * @param int $status
  69. * @return bool
  70. */
  71. public static function isValidEvaluateStatus($status)
  72. {
  73. return in_array($status, [
  74. self::EVALUATE_STATUS_PENDING,
  75. self::EVALUATE_STATUS_APPROVED,
  76. self::EVALUATE_STATUS_REJECTED
  77. ]);
  78. }
  79. /**
  80. * 验证有图片状态
  81. * @param int $hasPicture
  82. * @return bool
  83. */
  84. public static function isValidHasPicture($hasPicture)
  85. {
  86. return in_array($hasPicture, [
  87. self::HAS_PICTURE_NO,
  88. self::HAS_PICTURE_YES
  89. ]);
  90. }
  91. }