System_column_root.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Models;
  3. class System_column_root extends BaseModel {
  4. protected $table = "system_column_root";
  5. public $timestamps = false;
  6. //获取管理员权限菜单列表
  7. function getRootmenulist($value='',$type=1,$sort=1,$ads='asc') {
  8. $pre = $this->table . '.';
  9. $key = $this->getFeild($type);
  10. $sort = $this->getFeild($sort);
  11. $sort = $pre .$sort;
  12. if(empty($value)){
  13. $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();
  14. }else if(is_array($value)){
  15. foreach($value as $k=>$v){
  16. $value[$k][0] = $pre . $v[0];
  17. }
  18. $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();
  19. }else{
  20. $key = $pre . $key;
  21. $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();
  22. }
  23. if (!$data) {
  24. return -7010100102; //没有列表数据
  25. }
  26. return $data->toArray();
  27. }
  28. //获取权限信息
  29. function getRootDetails($value,$type=1,$jointable='',$columnn='',$columnw='') {
  30. $key = $this->getFeild($type);
  31. if(empty($jointable)){
  32. $data = $this->where($key, $value)->first();
  33. }else{
  34. $data = $this->where($key, $value)->join($jointable,$this->table.'.'.$columnn,$jointable.'.'.$columnw)->first();
  35. }
  36. ;
  37. if (!$data) {
  38. return -7010100202; //没有权限信息
  39. }
  40. return $data->toArray();
  41. }
  42. //字段对应值
  43. private function getFeild($num){
  44. $data = array(
  45. '1' => 'id',
  46. '2' => 'root_id',
  47. '3' => 'menu_id',
  48. );
  49. return $data[$num];
  50. }
  51. }