123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- namespace app\common\Enum;
- class CommentEnum
- {
- /**
- * 评价状态
- */
- const EVALUATE_STATUS_PENDING = 1; // 审核中
- const EVALUATE_STATUS_APPROVED = 2; // 审核通过
- const EVALUATE_STATUS_REJECTED = 3; // 审核失败
- /**
- * 显示状态
- */
- const STATUS_NORMAL = 'normal'; // 正常显示
- const STATUS_HIDDEN = 'hidden'; // 隐藏
- /**
- * 是否有图片
- */
- 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 string $status
- * @return string
- */
- public static function getStatusText($status)
- {
- $statusMap = [
- self::STATUS_NORMAL => '正常显示',
- self::STATUS_HIDDEN => '隐藏'
- ];
- 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 getStatusList()
- {
- return [
- self::STATUS_NORMAL => '正常显示',
- self::STATUS_HIDDEN => '隐藏'
- ];
- }
- /**
- * 获取所有有图片状态
- * @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 string $status
- * @return bool
- */
- public static function isValidStatus($status)
- {
- return in_array($status, [
- self::STATUS_NORMAL,
- self::STATUS_HIDDEN
- ]);
- }
- /**
- * 验证有图片状态
- * @param int $hasPicture
- * @return bool
- */
- public static function isValidHasPicture($hasPicture)
- {
- return in_array($hasPicture, [
- self::HAS_PICTURE_NO,
- self::HAS_PICTURE_YES
- ]);
- }
- }
|