UserController.php
2.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
<?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\User as UserModel;
use Illuminate\Http\Request;
class UserController extends BaseController
{
/**
* @name :name
* @return void
* @author :liyuhang
* @method
*/
public function lists(UserModel $userModel){
//TODO::搜索参数处理
$this->map['project_id'] = $this->user['project_id'];
$lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at']);
if(empty($lists)){
$this->response('error',Code::USER_ERROR,[]);
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :添加管理员
* @return void
* @author :liyuhang
* @method
*/
public function add(UserRequest $request,UserLogic $userLogic){
$request->validated();
$userLogic->user_add();
$this->response('success');
}
/**
* @name : 编辑管理员
* @return void
* @author :liyuhang
* @method
*/
public function edit(UserRequest $request,UserLogic $userLogic){
$request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$userLogic->user_edit();
$this->response('success');
}
/**
* @name :修改当前用户状态
* @return void
* @author :liyuhang
* @method
*/
public function status(Request $request,UserLogic $userLogic){
$request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$userLogic->user_status();
$this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功');
}
/**
* @name :详情
* @return json
* @author :liyuhang
* @method
*/
public function info(Request $request,UserLogic $userLogic){
$request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$userLogic->user_info();
$this->response('success');
}
/**
* @name :删除管理员
* @return json
* @author :liyuhang
* @method
*/
public function del(Request $request,UserLogic $userLogic){
$request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$userLogic->user_del();
$this->response('success');
}
}