Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
newShopBack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
newshop
newShopBack
Commits
d13d08f3
Commit
d13d08f3
authored
Nov 07, 2019
by
郭勇志
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
授权相关
parent
8aee67c6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
259 additions
and
8 deletions
+259
-8
main.php
backend/config/main.php
+3
-2
BaseController.php
backend/controllers/v1/BaseController.php
+4
-4
RbacUserController.php
backend/controllers/v1/rbacuser/RbacUserController.php
+13
-2
ShopRbacNode.php
backend/models/v1/rbacuser/ShopRbacNode.php
+72
-0
ShopRbacRole.php
backend/models/v1/rbacuser/ShopRbacRole.php
+63
-0
ShopRbacRoleAccess.php
backend/models/v1/rbacuser/ShopRbacRoleAccess.php
+50
-0
ShopRbacRoleUser.php
backend/models/v1/rbacuser/ShopRbacRoleUser.php
+50
-0
ShopRbacUser.php
backend/models/v1/rbacuser/ShopRbacUser.php
+4
-0
No files found.
backend/config/main.php
View file @
d13d08f3
...
...
@@ -19,7 +19,7 @@ return [
]
],
'user'
=>
[
'identityClass'
=>
'app\models\v1\user\ShopRbacUser'
,
'identityClass'
=>
'app\models\v1\
rbac
user\ShopRbacUser'
,
'enableAutoLogin'
=>
true
,
// 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
'enableSession'
=>
false
,
...
...
@@ -54,15 +54,16 @@ return [
'v1/shop/branch/branch'
,
'v1/rbacuser/rbac-user'
,
'v1/shopuser/shop-user-membergrade'
,
'v1/user/user'
],
'extraPatterns'
=>
[
'GET,OPTIONS test'
=>
'test'
,
'GET swagger'
=>
'swagger'
,
'POST login'
=>
'login'
,
'GET get'
=>
'login'
,
],
],
'GET swaggers/swagger/<id>'
=>
'swagger/swagger'
,
'GET rbacuser/rbac-user/<id>'
=>
'rbacuser/rbac-user'
,
],
],
'redis'
=>
[
...
...
backend/controllers/v1/BaseController.php
View file @
d13d08f3
...
...
@@ -57,10 +57,10 @@ class BaseController extends ActiveController
'optional'
=>
[
'login'
],
];
// 授权
$behaviors
[
'authorizationFilter'
]
=
[
'class'
=>
authorizationFilter
::
className
(),
'optional'
=>
[
'login'
],
//过滤不需要验证的action
];
//
$behaviors['authorizationFilter']=[
//
'class' => authorizationFilter::className(),
//
'optional' => ['login'],//过滤不需要验证的action
//
];
return
$behaviors
;
}
}
backend/controllers/v1/rbacuser/RbacUserController.php
View file @
d13d08f3
...
...
@@ -7,7 +7,7 @@ use backend\controllers\v1\BaseController;
use
backend\models\v1\rbacuser\LoginForm
;
class
RbacUserController
extends
BaseController
{
public
$modelClass
=
'app\models\v1\user\ShopRbacUser'
;
public
$modelClass
=
'app\models\v1\
rbac
user\ShopRbacUser'
;
public
$serializer
=
[
'class'
=>
'yii\rest\Serializer'
,
'collectionEnvelope'
=>
'user'
,
...
...
@@ -43,5 +43,16 @@ class RbacUserController extends BaseController
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": {}}}
* )
*/
}
backend/models/v1/rbacuser/ShopRbacNode.php
0 → 100644
View file @
d13d08f3
<?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'
,
];
}
}
backend/models/v1/rbacuser/ShopRbacRole.php
0 → 100644
View file @
d13d08f3
<?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'
,
];
}
}
backend/models/v1/rbacuser/ShopRbacRoleAccess.php
0 → 100644
View file @
d13d08f3
<?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'
,
];
}
}
backend/models/v1/rbacuser/ShopRbacRoleUser.php
0 → 100644
View file @
d13d08f3
<?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'
,
];
}
}
backend/models/v1/rbacuser/ShopRbacUser.php
View file @
d13d08f3
...
...
@@ -183,4 +183,8 @@ class ShopRbacUser extends BaseModel implements IdentityInterface
{
return
Yii
::
$app
->
security
->
validatePassword
(
$password
,
$this
->
password_hash
);
}
public
function
getShopRbacRoleUser
()
{
return
$this
->
hasOne
(
ShopRbacRoleUser
::
className
(),
[
'USER_ID'
=>
'GUID'
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment