ProjectDeptController.php
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace App\Http\Controllers\Aside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\User\DeptLogic;
use Illuminate\Support\Facades\DB;
/**
* @remark :b端用户组织架构
* @name :ProjectDeptController
* @author :lyh
* @time :2023/6/17 16:23
*/
class ProjectDeptController extends BaseController
{
/**
* @name :(组织部门)lists
* @author :lyh
* @method :post
* @time :2023/6/17 16:13
*/
public function lists(DeptLogic $deptLogic){
if(isset($this->param['pid'])){
$this->map['pid'] = $this->param['pid'];
}
if(isset($this->map['title']) && !empty($this->map['title'])){
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
}
$lists = $deptLogic->DeptLists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :(部门详情)read
* @author :lyh
* @method :post
* @time :2023/6/17 16:13
*/
public function read(DeptLogic $deptLogic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$info = $deptLogic->DeptRead();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :根据组织架构获取用户
* @name :getDeptUser
* @author :lyh
* @method :post
* @time :2023/6/26 10:21
*/
public function getDeptUser(){
$query = DB::table('gl_project_user')
->leftJoin('gl_project_dept_user', 'gl_project_user.id', '=', 'gl_project_dept_user.user_id')
->leftJoin('gl_project_dept', 'gl_project_dept_user.dept_id', '=', 'gl_project_dept.id')
->join('gl_project_role', 'gl_project_user.role_id', '=', 'gl_project_role.id')
->orderBy('gl_project_dept_user.id','desc');
$query = $this->searchParam($query);
$lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :(查询参数设置)selectParam
* @author :lyh
* @method :post
* @time :2023/6/14 15:00
*/
public function selectParam(){
$select = [
'gl_project_dept_user.dept_id AS dept_id',
'gl_project_user.name AS name',
'gl_project_user.project_id AS project_id',
'gl_project_user.mobile AS mobile',
'gl_project_user.email AS email',
'gl_project_user.status AS status',
'gl_project_user.role_id AS role_id',
'gl_project_user.operator_id AS operator_id',
'gl_project_dept_user.is_admin AS is_admin',
'gl_project_dept.title AS title',
'gl_project_dept.pid AS pid',
'gl_project_dept.remark AS remark',
'gl_project_user.id AS user_id',
'gl_project_dept_user.id AS id',
'gl_project_role.name AS role_name'
];
return $select;
}
/**
* @name :(搜索参数处理)searchParam
* @author :lyh
* @method :post
* @time :2023/6/14 14:58
*/
public function searchParam(&$query){
//搜索条件处理
if(isset($this->map['name'])){
$query = $query->where('gl_project_user.name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
}
if(isset($this->map['dept_id'])){
$query = $query->where('gl_project_dept_user.dept_id',$this->map['dept_id']);
}
if(isset($this->map['project_id'])){
$query = $query->where('gl_project_user.project_id',$this->map['project_id']);
}
return $query;
}
}