|
@@ -4,7 +4,9 @@ namespace App\Http\Controllers\Bside; |
|
@@ -4,7 +4,9 @@ namespace App\Http\Controllers\Bside; |
|
4
|
|
4
|
|
|
5
|
use App\Enums\Common\Code;
|
5
|
use App\Enums\Common\Code;
|
|
6
|
use App\Http\Logic\Bside\ComLogic;
|
6
|
use App\Http\Logic\Bside\ComLogic;
|
|
7
|
-use Illuminate\Http\Request;
|
7
|
+use App\Models\ProjectMenu as ProjectMenuModel;
|
|
|
|
8
|
+use App\Models\ProjectRole as ProjectRoleModel;
|
|
|
|
9
|
+use Illuminate\Support\Facades\DB;
|
|
8
|
use Illuminate\Support\Facades\Validator;
|
10
|
use Illuminate\Support\Facades\Validator;
|
|
9
|
|
11
|
|
|
10
|
/***
|
12
|
/***
|
|
@@ -21,7 +23,7 @@ class ComController extends BaseController |
|
@@ -21,7 +23,7 @@ class ComController extends BaseController |
|
21
|
public function login(){
|
23
|
public function login(){
|
|
22
|
$rules = [
|
24
|
$rules = [
|
|
23
|
'mobile'=>'required|string|max:12',
|
25
|
'mobile'=>'required|string|max:12',
|
|
24
|
- 'password'=>'required|string|min:5',
|
26
|
+ 'password'=>'required|string',
|
|
25
|
];
|
27
|
];
|
|
26
|
//验证的提示信息
|
28
|
//验证的提示信息
|
|
27
|
$message = [
|
29
|
$message = [
|
|
@@ -30,16 +32,13 @@ class ComController extends BaseController |
|
@@ -30,16 +32,13 @@ class ComController extends BaseController |
|
30
|
'password.required'=>'内容必须填写',
|
32
|
'password.required'=>'内容必须填写',
|
|
31
|
'password.string'=>'内容中含有非法文字',
|
33
|
'password.string'=>'内容中含有非法文字',
|
|
32
|
'mobile.max' => 'account不大于12字符.',
|
34
|
'mobile.max' => 'account不大于12字符.',
|
|
33
|
- 'password.min' => 'password不小于5字符.',
|
|
|
|
34
|
];
|
35
|
];
|
|
35
|
$validate = Validator::make($this->param, $rules, $message);
|
36
|
$validate = Validator::make($this->param, $rules, $message);
|
|
36
|
if($validate->errors()->first()){
|
37
|
if($validate->errors()->first()){
|
|
37
|
return $this->response($validate->errors()->first(),Code::USER_ERROR,$this->param);
|
38
|
return $this->response($validate->errors()->first(),Code::USER_ERROR,$this->param);
|
|
38
|
}
|
39
|
}
|
|
39
|
- //TODO::参数验
|
|
|
|
40
|
$comLogic = new ComLogic();
|
40
|
$comLogic = new ComLogic();
|
|
41
|
$res = $comLogic->login($this->param);
|
41
|
$res = $comLogic->login($this->param);
|
|
42
|
- $this->token = $res['token'];
|
|
|
|
43
|
if($res === false){
|
42
|
if($res === false){
|
|
44
|
$this->response('请求失败',Code::USER_ERROR,[]);
|
43
|
$this->response('请求失败',Code::USER_ERROR,[]);
|
|
45
|
}
|
44
|
}
|
|
@@ -53,7 +52,49 @@ class ComController extends BaseController |
|
@@ -53,7 +52,49 @@ class ComController extends BaseController |
|
53
|
* @method
|
52
|
* @method
|
|
54
|
*/
|
53
|
*/
|
|
55
|
public function get_menu(){
|
54
|
public function get_menu(){
|
|
56
|
- $menu_lists = [];
|
|
|
|
57
|
- $this->response('当前用户菜单列表',Code::SUCCESS,$menu_lists);
|
55
|
+ //根据当前登录用户角色返回用户菜单列表
|
|
|
|
56
|
+ $projectRoleModel = new ProjectRoleModel();
|
|
|
|
57
|
+ $info = $projectRoleModel->read(['id'=>$this->user['role_id']]);
|
|
|
|
58
|
+ $projectMenuModel = new ProjectMenuModel();
|
|
|
|
59
|
+ $info['role_menu'] = trim($info['role_menu'],',');
|
|
|
|
60
|
+ $lists = DB::table($projectMenuModel->getTable())->where(['status'=>0])->whereIn('id',explode(',',$info['role_menu']))->get();
|
|
|
|
61
|
+ $lists = $lists->toArray();
|
|
|
|
62
|
+ $menu = array();
|
|
|
|
63
|
+ foreach ($lists as $k => $v){
|
|
|
|
64
|
+ $v = (array)$v;
|
|
|
|
65
|
+ if ($v['pid'] == 0) {
|
|
|
|
66
|
+ $v['sub'] = $this->_get_child($v['id'], $lists);
|
|
|
|
67
|
+ $menu[] = $v;
|
|
|
|
68
|
+ }
|
|
|
|
69
|
+ }
|
|
|
|
70
|
+ $this->response('当前用户菜单列表',Code::SUCCESS,$menu);
|
|
|
|
71
|
+ }
|
|
|
|
72
|
+
|
|
|
|
73
|
+ /**
|
|
|
|
74
|
+ * 菜单权限->得到子级数组
|
|
|
|
75
|
+ * @param int
|
|
|
|
76
|
+ * @return array
|
|
|
|
77
|
+ */
|
|
|
|
78
|
+ public function _get_child($my_id, $arr)
|
|
|
|
79
|
+ {
|
|
|
|
80
|
+ $new_arr = array();
|
|
|
|
81
|
+ foreach ($arr as $k => $v) {
|
|
|
|
82
|
+ $v = (array)$v;
|
|
|
|
83
|
+ if ($v['pid'] == $my_id) {
|
|
|
|
84
|
+ $new_arr[$k] = $v;
|
|
|
|
85
|
+ $new_arr[$k]['son'] = $this->_get_child($v['id'],$arr);
|
|
|
|
86
|
+ }
|
|
|
|
87
|
+
|
|
|
|
88
|
+ }
|
|
|
|
89
|
+ return $new_arr ? $new_arr : false;
|
|
|
|
90
|
+ }
|
|
|
|
91
|
+ /**
|
|
|
|
92
|
+ * @name :获取当前项目详情
|
|
|
|
93
|
+ * @return void
|
|
|
|
94
|
+ * @author :liyuhang
|
|
|
|
95
|
+ * @method
|
|
|
|
96
|
+ */
|
|
|
|
97
|
+ public function get_project(){
|
|
|
|
98
|
+
|
|
58
|
}
|
99
|
}
|
|
59
|
} |
100
|
} |