123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace app\common\Enum;
- class CommentEnum
- {
- /**
- * 评价状态
- */
- const EVALUATE_STATUS_PENDING = 1; // 审核中
- const EVALUATE_STATUS_APPROVED = 2; // 审核通过
- const EVALUATE_STATUS_REJECTED = 3; // 审核失败
- /**
- * 是否有图片
- */
- const HAS_PICTURE_NO = 0; // 无图片
- const HAS_PICTURE_YES = 1; // 有图片
- /**
- * 获取评价状态文本
- * @param int $status
- * @return string
- */
- public static function getEvaluateStatusText($status)
- {
- $statusMap = [
- self::EVALUATE_STATUS_PENDING => '审核中',
- self::EVALUATE_STATUS_APPROVED => '审核通过',
- self::EVALUATE_STATUS_REJECTED => '审核失败'
- ];
- return isset($statusMap[$status]) ? $statusMap[$status] : '未知状态';
- }
-
- /**
- * 获取有图片状态文本
- * @param int $hasPicture
- * @return string
- */
- public static function getHasPictureText($hasPicture)
- {
- $statusMap = [
- self::HAS_PICTURE_NO => '无图片',
- self::HAS_PICTURE_YES => '有图片'
- ];
- return isset($statusMap[$hasPicture]) ? $statusMap[$hasPicture] : '未知状态';
- }
- /**
- * 获取所有评价状态
- * @return array
- */
- public static function getEvaluateStatusList()
- {
- return [
- self::EVALUATE_STATUS_PENDING => '审核中',
- self::EVALUATE_STATUS_APPROVED => '审核通过',
- self::EVALUATE_STATUS_REJECTED => '审核失败'
- ];
- }
- /**
- * 获取所有有图片状态
- * @return array
- */
- public static function getHasPictureList()
- {
- return [
- self::HAS_PICTURE_NO => '无图片',
- self::HAS_PICTURE_YES => '有图片'
- ];
- }
- /**
- * 验证评价状态
- * @param int $status
- * @return bool
- */
- public static function isValidEvaluateStatus($status)
- {
- return in_array($status, [
- self::EVALUATE_STATUS_PENDING,
- self::EVALUATE_STATUS_APPROVED,
- self::EVALUATE_STATUS_REJECTED
- ]);
- }
- /**
- * 验证有图片状态
- * @param int $hasPicture
- * @return bool
- */
- public static function isValidHasPicture($hasPicture)
- {
- return in_array($hasPicture, [
- self::HAS_PICTURE_NO,
- self::HAS_PICTURE_YES
- ]);
- }
- }
|