Commit 5beca137 authored by 孙磊's avatar 孙磊

auth

Signed-off-by: 孙磊's avatarsunlei <sunlei@romens.cn>
parent d59e1901
...@@ -69,4 +69,12 @@ class ShopRbacNode extends BaseModel ...@@ -69,4 +69,12 @@ class ShopRbacNode extends BaseModel
'LEVEL' => 'Level', 'LEVEL' => 'Level',
]; ];
} }
//获取全部的权限节点
public function getAuthorityNodes()
{
return $query = static::find()
->select('ID,NAME,TITLE,STATUS,PID')
->where(['ifnull(STATUS,0)' => 1])
->all();
}
} }
...@@ -29,7 +29,7 @@ class ShopRbacRoleAccess extends BaseModel ...@@ -29,7 +29,7 @@ class ShopRbacRoleAccess extends BaseModel
public function rules() public function rules()
{ {
return [ return [
[['NODE_ID'], 'required'], [['NODE_ID'], 'required','on'=>['create']],
[['ROLE_ID', 'NODE_ID'], 'string', 'max' => 20], [['ROLE_ID', 'NODE_ID'], 'string', 'max' => 20],
[['ORG_GUID'], 'string', 'max' => 50], [['ORG_GUID'], 'string', 'max' => 50],
]; ];
...@@ -46,4 +46,20 @@ class ShopRbacRoleAccess extends BaseModel ...@@ -46,4 +46,20 @@ class ShopRbacRoleAccess extends BaseModel
'ORG_GUID' => 'Org Guid', 'ORG_GUID' => 'Org Guid',
]; ];
} }
//获取角色的权限
public function getRoleAuthorities($id)
{
return $query = static::find()
->select('ROLE_ID,NODE_ID')
->where(['ROLE_ID' => $id])
->asArray()
->all();
}
//删除角色原有权限
public function delRoleAuthorities($ROLE_ID)
{
$roleAuth = static::find()->where(['ROLE_ID'=>$ROLE_ID])->one();
$res = $roleAuth->delete();
return $res;
}
} }
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