|
- <?php
-
- namespace common\models;
-
- use Yii;
- use yii\db\ActiveQuery;
-
- /**
- * This is the model class for table "base_user_auth".
- *
- * @property integer $id
- * @property integer $sys
- * @property string $auth_name
- * @property string $role_list
- * @property integer $main_corp
- */
- class BaseUserAuth extends \yii\db\ActiveRecord
- {
- const SYS_CS = 0; // 全权限
- const SYS_FO = 1; // 车系统
-
- const SYS_ADMIN = 1; //系统管理员
- const BUS_BD = 2; //巴士BD人员
- const BUS_OPERA_CUS = 3; //巴士运营客服人员
- const FINANCIAL_OFFICER = 4; //财务人员
- const HOTEL_OPERATOR = 5; //酒店运营人员
- const HOTEL_PURCHASE = 6; //酒店采购人员
- const HOTEL_CUSTOMER = 7; //酒店客服人员
- const BUS_OPERA_ADMIN = 8;//巴士运营管理人员
- const HOTEL_ADMIN = 9;//酒店管理人员
- const HOTEL_CUS_ADMIN = 10; //酒店客服管理人员
- const MAIN_CORP=16; // 运营主体管理账号
-
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'base_user_auth';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['sys', 'main_corp'], 'integer'],
- [['role_list'], 'string'],
- [['auth_name'], 'required'],
- [['auth_name'], 'string', 'max' => 50],
- ];
- }
-
- public function getMainCorp()
- {
- return $this->hasOne(BaseMainCorporation::className(), ['id' => 'main_corp']);
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'sys' => '系统,0:cs系统,1:车系统',
- 'auth_name' => '角色名称',
- 'role_list' => '权限列表',
- 'main_corp' => '运营主体'
- ];
- }
-
- /**
- * User: wangxj
- *
- * 函数作用
- *
- * @param $sys
- * @return ActiveQuery
- */
- public static function zFind($sys)
- {
- return parent::find()->where(['sys' => $sys]);
- }
-
- /**
- * 检查是否有权限
- * @param $route
- * @param $menu_permission
- * @return bool
- */
- public static function can($route)
- {
- $user = Yii::$app->user->identity;
- /* @var $user \common\models\User */
- $role = BaseRole::findOne(['ROLE_NAME' => $route]);
- if (!is_array($user->MENU_PERMISSION)) {
- $user->MENU_PERMISSION = explode(',', $user->MENU_PERMISSION);
- }
- if ($user->STATUS == 0 && $role != null && in_array($role->ID, $user->MENU_PERMISSION)) {
- return true;
- }
- return false;
- }
- }
|