UserController.php
3.0 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
<?php
namespace App\Http\Controllers\Bside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Controllers\Bside\json;
use App\Http\Logic\Bside\User\UserLogic;
use App\Http\Requests\Bside\User\UserRequest;
use App\Models\User\ProjectRole;
use App\Models\User\User as UserModel;
use App\Models\User\ViewDeptUser;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class UserController extends BaseController
{
/**
* @name :name
* @author :liyuhang
* @method
*/
public function lists(UserModel $userModel){
//TODO::搜索参数统一处理
$this->map['project_id'] = $this->user['project_id'];
$this->map['role_id'] = ['!=',0];
$lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :(添加管理员获取角色菜单)role_list
* @author :lyh
* @method :post
* @time :2023/5/18 17:04
*/
public function role_list(ProjectRole $projectRole){
$list = $projectRole->list(['status'=>0,'project_id'=>$this->user['project_id']],'id');
$this->response('success',Code::SUCCESS,$list);
}
/**
* @name :添加管理员
* @author :liyuhang
* @method
*/
public function add(UserRequest $request,UserLogic $userLogic){
$request->validated();
$userLogic->user_add();
$this->response('success');
}
/**
* @name : 编辑管理员
* @author :liyuhang
* @method
*/
public function edit(Request $request,UserLogic $userLogic){
$request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$userLogic->user_edit();
$this->response('success');
}
/**
* @name :修改当前用户状态
* @author :liyuhang
* @method
*/
public function status(UserLogic $userLogic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$userLogic->user_status();
$this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功');
}
/**
* @name :详情
* @author :liyuhang
* @method
*/
public function info(UserLogic $userLogic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$info = $userLogic->user_info();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :删除管理员
* @author :liyuhang
* @method
*/
public function del(UserLogic $userLogic){
$this->request->validate([
'id'=>['required','array'],
],[
'id.required' => 'ID不能为空',
'id.array' => 'ID为数组',
]);
$userLogic->user_del();
$this->response('success');
}
}