1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\cxinv\model;
- class RoleAction extends Base
- {
- //设置字段信息
- protected $schema = [
- 'id' =>'bigint',//
- 'role_id' =>'bigint',//
- 'action_data' =>'text',//
- 'action_conllect' =>'text',//
- 'private_data' =>'text',//
- 'status' =>'int',//
- 'addtime' =>'datetime',//
- 'updatetime' =>'datetime',//
- ];
- protected $updateTime='updatetime';
- protected $createTime='addtime';
- public function GetActionConllectAttr($v){
- return json_decode($v,true);
- }
-
- public function SetActionConllectAttr($v){
- return json_encode($v,JSON_UNESCAPED_UNICODE);
- }
-
- public function GetActionDataAttr($v){
- return json_decode($v,true);
- }
-
- public function SetActionDataAttr($v){
- return json_encode($v,JSON_UNESCAPED_UNICODE);
- }
-
- public function GetPrivateDataAttr($v){
- return json_decode($v,true);
- }
-
- public function SetPrivateDataAttr($v){
- return json_encode($v,JSON_UNESCAPED_UNICODE);
- }
- public static function checkRole($roleid,$actionid){
- $info = self::where([['role_id',"in",$roleid],["status","=",1]])->findOrEmpty();
- if ($info->isEmpty()) return false;
- $provate_data = $info->private_data;
- if(is_array($actionid))return empty(array_intersect($actionid,$provate_data))==false;
- if(is_string($actionid)||is_int($actionid)) return in_array($actionid,$provate_data);
- }
- }
|