DeptUserController.php
4.5 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
namespace App\Http\Controllers\Bside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\User\DeptUserLogic;
use App\Models\User\ViewDeptUser;
use Illuminate\Support\Facades\DB;
class DeptUserController extends BaseController
{
/**
* @name :name
* @author :liyuhang
* @method
*/
public function lists(){
$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')
->leftJoin('gl_project_role', 'gl_project_user.role_id', '=', 'gl_project_role.id')
->orderBy('gl_project_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_user.id AS user_id',
'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_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']);
}
$query = $query->where('gl_project_user.project_id',$this->user['project_id']);
return $query;
}
/**
* @name :(详情)info
* @author :lyh
* @method :post
* @time :2023/5/18 9:32
*/
public function info(DeptUserLogic $deptUserLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'id不能为空'
]);
$info = $deptUserLogic->dept_user_info();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :(部门添加与更新用户)add
* @author :lyh
* @method :post
* @time :2023/5/17 17:36
*/
public function save(DeptUserLogic $deptUserLogic){
$this->request->validate([
'dept_id'=>['required'],
'user_id'=>['required']
],[
'dept_id.required' => '组织架构id不能为空',
'user_id.required' => '用户id不能为空',
]);
$deptUserLogic->dept_user_save();
$this->response('success');
}
/**
* @name :(设置管理员)set_admin
* @author :lyh
* @method :post
* @time :2023/5/18 10:32
*/
public function set_admin(DeptUserLogic $deptUserLogic){
$this->request->validate([
'id'=>['required'],
'is_admin'=>['required'],
],[
'id.required' => 'id不能为空',
'is_admin.required' => 'is_admin不能为空',
]);
$deptUserLogic->dept_user_edit();
$this->response('success');
}
/**
* @name :(设置用户角色)set_role
* @author :lyh
* @method :post
* @time :2023/5/19 9:32
*/
public function set_role(DeptUserLogic $deptUserLogic){
$this->request->validate([
'id'=>['required'],
'role_id'=>['required'],
],[
'id.required' => '用户id不能为空',
'role_id.required' => 'role_id不能为空',
]);
$deptUserLogic->user_edit_role();
$this->response('success');
}
}