作者 liyuhang

gx

  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside;
  4 +
  5 +class ProjectMenuController
  6 +{
  7 +
  8 +}
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Bside;  
4 -  
5 -use App\Models\Project as ProjectModel;  
6 -use Illuminate\Support\Facades\DB;  
7 -  
8 -/**  
9 - * @name:user用户获取相关项目  
10 - */  
11 -class ProjectController extends BaseController  
12 -{  
13 - /**  
14 - * @name :根据登录用户获取所有项目  
15 - * @return void  
16 - * @author :liyuhang  
17 - * @method  
18 - */  
19 - public function page_lists(){  
20 -  
21 - $projectModel = new ProjectModel();  
22 - $lists = DB::table($projectModel->table)->select(['*'])->where($this->map)->forPage($this->p,$this->row)->orderBy($this->order)->get();  
23 -  
24 - }  
25 -}  
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Bside;  
4 -  
5 -use App\Enums\Common\Code;  
6 -use App\Models\ProjectMenu as ProjectMenuModel;  
7 -use App\Models\ProjectRole as ProjectRoleModel;  
8 -use Illuminate\Support\Facades\Validator;  
9 -  
10 -class ProjectMenuController extends BaseController  
11 -{  
12 - /**  
13 - * @name :用户组菜单列表(带分页)  
14 - * @return void  
15 - * @author :liyuhang  
16 - * @method  
17 - */  
18 - public function lists(){  
19 - //根据角色获取菜单列表  
20 - $projectMenuModel = new ProjectMenuModel();  
21 - $lists = $projectMenuModel->lists($this->param,$this->p,$this->row,$this->order);  
22 - $this->allCount = $projectMenuModel->allCount;  
23 - $this->result($lists);  
24 - }  
25 -  
26 - /**  
27 - * @name :添加用户组菜单  
28 - * @return void  
29 - * @author :liyuhang  
30 - * @method  
31 - */  
32 - public function add(){  
33 - //参数验证  
34 - $rules = [  
35 - 'name'=>'required|max:11',  
36 - 'rules'=>'required',  
37 - ];  
38 - //验证的提示信息  
39 - $message = [  
40 - 'name.required'=>'名称必须填写',  
41 - 'name.max' => '名称不大于16字符.',  
42 - 'rules.required'=>'路由必须填写',  
43 - ];  
44 - $validate = Validator::make($this->param, $rules, $message);  
45 - if($validate->fails()){  
46 - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);  
47 - }  
48 - $projectMenuModel = new ProjectMenuModel();  
49 - $rs = $projectMenuModel->add($this->param);  
50 - if($rs === false){  
51 - $this->response('请求失败',Code::USER_ERROR,[]);  
52 - }  
53 - $this->response('success',Code::SUCCESS);  
54 - }  
55 -  
56 - /**  
57 - * @name :编辑用户组菜单  
58 - * @return void  
59 - * @author :liyuhang  
60 - * @method  
61 - */  
62 - public function edit(){  
63 - //参数验证  
64 - $rules = [  
65 - 'id'=>'required',  
66 - 'name'=>'required|max:11',  
67 - 'rules'=>'required',  
68 - ];  
69 - //验证的提示信息  
70 - $message = [  
71 - 'id.required'=>'服务器id错误',  
72 - 'name.required'=>'名称必须填写',  
73 - 'name.max' => '名称不大于16字符.',  
74 - 'rules.required'=>'路由必须填写',  
75 - ];  
76 - $validate = Validator::make($this->param, $rules, $message);  
77 - if($validate->fails()){  
78 - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);  
79 - }  
80 - $projectMenuModel = new ProjectMenuModel();  
81 - $rs = $projectMenuModel->edit($this->param,['id'=>$this->param['id']]);  
82 - if($rs === false){  
83 - $this->response('请求失败',Code::USER_ERROR);  
84 - }  
85 - $this->response('success',Code::SUCCESS);  
86 - }  
87 -  
88 - /**  
89 - * @name :编辑状态  
90 - * @return void  
91 - * @author :liyuhang  
92 - * @method  
93 - */  
94 - public function status(){  
95 - //参数验证  
96 - $rules = [  
97 - 'id'=>'required',  
98 - 'status'=>'required',  
99 - ];  
100 - //验证的提示信息  
101 - $message = [  
102 - 'id.required'=>'主键必须填写',  
103 - 'status.required'=>'状态必须填写',  
104 - ];  
105 - $validate = Validator::make($this->param, $rules, $message);  
106 - if($validate->fails()){  
107 - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);  
108 - }  
109 - $projectMenuModel = new ProjectMenuModel();  
110 - $rs = $projectMenuModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);  
111 - if($rs === false){  
112 - $this->response('编辑失败',Code::USER_PARAMS_ERROE);  
113 - }  
114 - $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功',Code::SUCCESS);  
115 - }  
116 -}