| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace App\Models;
- class System_column_root extends BaseModel {
- protected $table = "system_column_root";
- public $timestamps = false;
-
- //获取管理员权限菜单列表
- function getRootmenulist($value='',$type=1,$sort=1,$ads='asc') {
- $pre = $this->table . '.';
- $key = $this->getFeild($type);
- $sort = $this->getFeild($sort);
- $sort = $pre .$sort;
- if(empty($value)){
- $data = $this->select('root_id','level','a.name as root_name','settingmoney','menu_id','b.name as menu_name')->join('system_root as a','a.id','root_id')->join('system_menu as b','b.id','menu_id')->orderby($sort,$ads)->get();
- }else if(is_array($value)){
- foreach($value as $k=>$v){
- $value[$k][0] = $pre . $v[0];
- }
- $data = $this->select('root_id','level','a.name as root_name','settingmoney','menu_id','b.name as menu_name')->join('system_root as a','a.id','root_id')->join('system_menu as b','b.id','menu_id')->where($value)->orderby($sort,$ads)->get();
- }else{
- $key = $pre . $key;
- $data = $this->select('root_id','level','a.name as root_name','settingmoney','menu_id','b.name as menu_name')->join('system_root as a','a.id','root_id')->join('system_menu as b','b.id','menu_id')->where($key,$value)->orderby($sort,$ads)->first();
- }
-
- if (!$data) {
- return -7010100102; //没有列表数据
- }
- return $data->toArray();
- }
-
- //获取权限信息
- function getRootDetails($value,$type=1,$jointable='',$columnn='',$columnw='') {
- $key = $this->getFeild($type);
- if(empty($jointable)){
- $data = $this->where($key, $value)->first();
- }else{
- $data = $this->where($key, $value)->join($jointable,$this->table.'.'.$columnn,$jointable.'.'.$columnw)->first();
- }
- ;
- if (!$data) {
- return -7010100202; //没有权限信息
- }
- return $data->toArray();
- }
-
- //字段对应值
- private function getFeild($num){
- $data = array(
- '1' => 'id',
- '2' => 'root_id',
- '3' => 'menu_id',
- );
- return $data[$num];
- }
-
- }
|