Commit d13d08f3 authored by 郭勇志's avatar 郭勇志

授权相关

parent 8aee67c6
...@@ -19,7 +19,7 @@ return [ ...@@ -19,7 +19,7 @@ return [
] ]
], ],
'user' => [ 'user' => [
'identityClass' => 'app\models\v1\user\ShopRbacUser', 'identityClass' => 'app\models\v1\rbacuser\ShopRbacUser',
'enableAutoLogin' => true, 'enableAutoLogin' => true,
// 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true], // 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
'enableSession' => false, 'enableSession' => false,
...@@ -54,15 +54,16 @@ return [ ...@@ -54,15 +54,16 @@ return [
'v1/shop/branch/branch', 'v1/shop/branch/branch',
'v1/rbacuser/rbac-user', 'v1/rbacuser/rbac-user',
'v1/shopuser/shop-user-membergrade', 'v1/shopuser/shop-user-membergrade',
'v1/user/user'
], ],
'extraPatterns'=>[ 'extraPatterns'=>[
'GET,OPTIONS test'=>'test', 'GET,OPTIONS test'=>'test',
'GET swagger'=>'swagger', 'GET swagger'=>'swagger',
'POST login'=>'login', 'POST login'=>'login',
'GET get'=>'login',
], ],
], ],
'GET swaggers/swagger/<id>'=>'swagger/swagger', 'GET swaggers/swagger/<id>'=>'swagger/swagger',
'GET rbacuser/rbac-user/<id>'=>'rbacuser/rbac-user',
], ],
], ],
'redis' => [ 'redis' => [
......
...@@ -57,10 +57,10 @@ class BaseController extends ActiveController ...@@ -57,10 +57,10 @@ class BaseController extends ActiveController
'optional' => ['login'], 'optional' => ['login'],
]; ];
// 授权 // 授权
$behaviors['authorizationFilter']=[ // $behaviors['authorizationFilter']=[
'class' => authorizationFilter::className(), // 'class' => authorizationFilter::className(),
'optional' => ['login'],//过滤不需要验证的action // 'optional' => ['login'],//过滤不需要验证的action
]; // ];
return $behaviors; return $behaviors;
} }
} }
...@@ -7,7 +7,7 @@ use backend\controllers\v1\BaseController; ...@@ -7,7 +7,7 @@ use backend\controllers\v1\BaseController;
use backend\models\v1\rbacuser\LoginForm; use backend\models\v1\rbacuser\LoginForm;
class RbacUserController extends BaseController class RbacUserController extends BaseController
{ {
public $modelClass='app\models\v1\user\ShopRbacUser'; public $modelClass='app\models\v1\rbacuser\ShopRbacUser';
public $serializer = [ public $serializer = [
'class' => 'yii\rest\Serializer', 'class' => 'yii\rest\Serializer',
'collectionEnvelope' => 'user', 'collectionEnvelope' => 'user',
...@@ -43,5 +43,16 @@ class RbacUserController extends BaseController ...@@ -43,5 +43,16 @@ class RbacUserController extends BaseController
return $model; return $model;
} }
} }
/**
* @OA\Get(
* path="/backend/web/v1/rbacuser/rbac-users/{id}",
* tags={"用户&员工接口"},
* description="根据id取得用户",
* summary="根据id取得用户",
* operationId="returnuser",
* @OA\Parameter(name="id",in="path",required=true,@OA\Schema(type="string")),
* @OA\Response(response="200",description="OK。一切正常"),
* security={{"Authorization": {}}}
* )
*/
} }
<?php
namespace app\models\v1\rbacuser;
use Yii;
use yii\web\IdentityInterface;
use app\models\v1\BaseModel;
use yii\web\HttpException;
/**
* This is the model class for table "shop_rbac_node".
*
* @property int $ID 主键自增ID
* @property string $ORG_GUID 组织机构号
* @property string $NAME 菜单地址
* @property string $TITLE 菜单名称
* @property string $LOGO 菜单前面的图标url
* @property int $STATUS 菜单状态 0禁用 1启用
* @property int $IS_MENU 是否为菜单(1:是,0:不是)
* @property int $IS_TOP_MENU 是否顶部菜单 1是 0否
* @property int $IS_DEFAULT_SHOW 是否进入默认显示页面 1是0否
* @property string $REMARK 备注名称
* @property int $SORT 菜单排序序号
* @property string $PID 父级菜单ID
* @property int $LEVEL 菜单层级等级
*/
class ShopRbacNode extends BaseModel implements IdentityInterface
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'shop_rbac_node';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['STATUS', 'IS_MENU', 'IS_TOP_MENU', 'IS_DEFAULT_SHOW', 'SORT', 'LEVEL'], 'integer'],
[['ORG_GUID', 'TITLE'], 'string', 'max' => 50],
[['NAME'], 'string', 'max' => 100],
[['LOGO', 'REMARK'], 'string', 'max' => 200],
[['PID'], 'string', 'max' => 11],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'ID' => 'ID',
'ORG_GUID' => 'Org Guid',
'NAME' => 'Name',
'TITLE' => 'Title',
'LOGO' => 'Logo',
'STATUS' => 'Status',
'IS_MENU' => 'Is Menu',
'IS_TOP_MENU' => 'Is Top Menu',
'IS_DEFAULT_SHOW' => 'Is Default Show',
'REMARK' => 'Remark',
'SORT' => 'Sort',
'PID' => 'Pid',
'LEVEL' => 'Level',
];
}
}
<?php
namespace app\models\v1\rbacuser;
use Yii;
use yii\web\IdentityInterface;
use app\models\v1\BaseModel;
use yii\web\HttpException;
/**
* This is the model class for table "shop_rbac_role".
*
* @property int $ID 主键自增ID
* @property string $ORG_GUID 组织机构号
* @property string $CODE 角色CODE
* @property string $NAME 角色名称
* @property string $PID 上级管理组GUID
* @property int $STATUS 状态,1:启用
* @property string $REMARK 备注
* @property int $SORT 排序
*/
class ShopRbacRole extends BaseModel implements IdentityInterface
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'shop_rbac_role';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['STATUS', 'SORT'], 'integer'],
[['ORG_GUID'], 'string', 'max' => 50],
[['CODE'], 'string', 'max' => 15],
[['NAME'], 'string', 'max' => 30],
[['PID'], 'string', 'max' => 6],
[['REMARK'], 'string', 'max' => 255],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'ID' => 'ID',
'ORG_GUID' => 'Org Guid',
'CODE' => 'Code',
'NAME' => 'Name',
'PID' => 'Pid',
'STATUS' => 'Status',
'REMARK' => 'Remark',
'SORT' => 'Sort',
];
}
}
<?php
namespace app\models\v1\rbacuser;
use Yii;
use yii\web\IdentityInterface;
use app\models\v1\BaseModel;
use yii\web\HttpException;
/**
* This is the model class for table "shop_rbac_role_access".
*
* @property string $ROLE_ID 对应权限角色表ID
* @property string $NODE_ID 角色所对应的权限菜单ID集合
* @property string $ORG_GUID 组织机构号
*/
class ShopRbacRoleAccess extends BaseModel implements IdentityInterface
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'shop_rbac_role_access';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['NODE_ID'], 'required'],
[['ROLE_ID', 'NODE_ID'], 'string', 'max' => 20],
[['ORG_GUID'], 'string', 'max' => 50],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'ROLE_ID' => 'Role ID',
'NODE_ID' => 'Node ID',
'ORG_GUID' => 'Org Guid',
];
}
}
<?php
namespace app\models\v1\rbacuser;
use Yii;
use yii\web\IdentityInterface;
use app\models\v1\BaseModel;
use yii\web\HttpException;
/**
* This is the model class for table "shop_rbac_role_user".
*
* @property string $USER_ID 权限用户表对应用户GUID
* @property string $ROLE_ID 用户对应的权限角色表ID
* @property string $ORG_GUID 组织机构号
*/
class ShopRbacRoleUser extends BaseModel implements IdentityInterface
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'shop_rbac_role_user';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['ROLE_ID'], 'required'],
[['USER_ID', 'ORG_GUID'], 'string', 'max' => 50],
[['ROLE_ID'], 'string', 'max' => 20],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'USER_ID' => 'User ID',
'ROLE_ID' => 'Role ID',
'ORG_GUID' => 'Org Guid',
];
}
}
...@@ -183,4 +183,8 @@ class ShopRbacUser extends BaseModel implements IdentityInterface ...@@ -183,4 +183,8 @@ class ShopRbacUser extends BaseModel implements IdentityInterface
{ {
return Yii::$app->security->validatePassword($password, $this->password_hash); return Yii::$app->security->validatePassword($password, $this->password_hash);
} }
public function getShopRbacRoleUser()
{
return $this->hasOne(ShopRbacRoleUser::className(), ['USER_ID' => 'GUID']);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment