|
@@ -14,7 +14,6 @@ class UserLogic extends BaseLogic |
|
@@ -14,7 +14,6 @@ class UserLogic extends BaseLogic |
|
14
|
public function __construct()
|
14
|
public function __construct()
|
|
15
|
{
|
15
|
{
|
|
16
|
parent::__construct();
|
16
|
parent::__construct();
|
|
17
|
-
|
|
|
|
18
|
$this->model = new User();
|
17
|
$this->model = new User();
|
|
19
|
$this->param = $this->requestAll;
|
18
|
$this->param = $this->requestAll;
|
|
20
|
}
|
19
|
}
|
|
@@ -25,36 +24,48 @@ class UserLogic extends BaseLogic |
|
@@ -25,36 +24,48 @@ class UserLogic extends BaseLogic |
|
25
|
* @author :liyuhang
|
24
|
* @author :liyuhang
|
|
26
|
* @method
|
25
|
* @method
|
|
27
|
*/
|
26
|
*/
|
|
28
|
- public function user_info(){
|
|
|
|
29
|
- $info = Common::get_user_cache($this->model,$this->param['id'],'A');
|
|
|
|
30
|
- if(empty($info)){
|
|
|
|
31
|
- $info = $this->model->read($this->param,['id','project_id','name','status','mobile','operator_id']);
|
|
|
|
32
|
- if($info === false){
|
27
|
+ public function user_info()
|
|
|
|
28
|
+ {
|
|
|
|
29
|
+ $info = Common::get_user_cache($this->model, $this->param['id'], 'A');
|
|
|
|
30
|
+ if (empty($info)) {
|
|
|
|
31
|
+ $info = $this->model->read($this->param, ['id', 'project_id', 'name', 'status', 'mobile', 'operator_id']);
|
|
|
|
32
|
+ if ($info === false) {
|
|
33
|
$this->fail('当前数据不存在');
|
33
|
$this->fail('当前数据不存在');
|
|
34
|
}
|
34
|
}
|
|
35
|
- $userModel = new UserModel();
|
|
|
|
36
|
- $info['operator_name'] = $userModel->read(['id'=>$info['operator_id']],['name'])['name'];
|
|
|
|
37
|
- $info['project_name'] = (new Project())->read(['id'=>$info['project_id']],['title'])['title'];
|
|
|
|
38
|
- Common::set_user_cache($info,$this->model,$this->param['id'],'A');
|
35
|
+ $info['project_name'] = (new Project())->read(['id' => $info['project_id']], ['title'])['title'];
|
|
|
|
36
|
+ Common::set_user_cache($info, $this->model, $this->param['id'], 'A');
|
|
39
|
}
|
37
|
}
|
|
40
|
return $this->success($info);
|
38
|
return $this->success($info);
|
|
41
|
}
|
39
|
}
|
|
|
|
40
|
+
|
|
42
|
/**
|
41
|
/**
|
|
43
|
* @name :添加会员
|
42
|
* @name :添加会员
|
|
44
|
* @return void
|
43
|
* @return void
|
|
45
|
* @author :liyuhang
|
44
|
* @author :liyuhang
|
|
46
|
* @method
|
45
|
* @method
|
|
47
|
*/
|
46
|
*/
|
|
48
|
- public function user_add(){
|
|
|
|
49
|
- //验证当前项目是否已存在超级管理员
|
|
|
|
50
|
- $info = $this->model->read(['project_id'=>$this->param['project_id'],'role_id'=>0]);
|
|
|
|
51
|
- if($info !== false){
|
|
|
|
52
|
- $this->fail('一个项目只允许一个超级管理员');
|
47
|
+ public function projectUserSave()
|
|
|
|
48
|
+ {
|
|
|
|
49
|
+ if (isset($this->param['id']) && !empty($this->param['id'])) {
|
|
|
|
50
|
+ $info = $this->model->read(['mobile' => $this->param['mobile'], 'id' => ['!=', $this->param['id']]]);
|
|
|
|
51
|
+ if ($info !== false) {
|
|
|
|
52
|
+ $this->fail('当前手机号码已存在');
|
|
|
|
53
|
+ }
|
|
|
|
54
|
+ $this->param = $this->editPassword($this->param);
|
|
|
|
55
|
+ $rs = $this->model->edit($this->param, ['id' => $this->param['id']]);
|
|
|
|
56
|
+ } else {
|
|
|
|
57
|
+ $info = $this->model->read(['mobile'=>$this->param['mobile']]);
|
|
|
|
58
|
+ if($info !== false){
|
|
|
|
59
|
+ $this->fail('当前手机号码已存在');
|
|
|
|
60
|
+ }
|
|
|
|
61
|
+ $info = $this->model->read(['project_id'=>$this->param['id'],'role_id'=>0]);
|
|
|
|
62
|
+ if($info !== false){
|
|
|
|
63
|
+ $this->fail('当前项目已存在超级管理员,请选择其他项目');
|
|
|
|
64
|
+ }
|
|
|
|
65
|
+ $this->param['password'] = base64_encode(md5($this->param['password']));
|
|
|
|
66
|
+ $rs = $this->model->add($this->param);
|
|
53
|
}
|
67
|
}
|
|
54
|
- $this->verifyMobile();//验证手机号
|
|
|
|
55
|
- $this->param['password'] = base64_encode(md5($this->param['password']));
|
|
|
|
56
|
- $rs = $this->model->add($this->param);
|
|
|
|
57
|
- if($rs === false){
|
68
|
+ if ($rs === false) {
|
|
58
|
$this->fail('添加失败');
|
69
|
$this->fail('添加失败');
|
|
59
|
}
|
70
|
}
|
|
60
|
return $this->success();
|
71
|
return $this->success();
|
|
@@ -66,21 +77,16 @@ class UserLogic extends BaseLogic |
|
@@ -66,21 +77,16 @@ class UserLogic extends BaseLogic |
|
66
|
* @author :liyuhang
|
77
|
* @author :liyuhang
|
|
67
|
* @method
|
78
|
* @method
|
|
68
|
*/
|
79
|
*/
|
|
69
|
- public function user_edit(){
|
|
|
|
70
|
- $this->verifyMobile();//验证手机号
|
80
|
+ public function editPassword($param)
|
|
|
|
81
|
+ {
|
|
71
|
//验证密码是否更改
|
82
|
//验证密码是否更改
|
|
72
|
- if(isset($this->param['password']) && !empty($this->param['password'])){
|
|
|
|
73
|
- $info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
74
|
- if($info['password'] != $this->param['password']){
|
|
|
|
75
|
- $this->param['password'] = base64_encode(md5($this->param['password']));
|
83
|
+ if (isset($param['password']) && !empty($param['password'])) {
|
|
|
|
84
|
+ $info = $this->model->read(['id' => $param['id']]);
|
|
|
|
85
|
+ if ($info['password'] != $param['password']) {
|
|
|
|
86
|
+ $param['password'] = base64_encode(md5($param['password']));
|
|
76
|
}
|
87
|
}
|
|
77
|
}
|
88
|
}
|
|
78
|
- $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
79
|
- if($rs === false){
|
|
|
|
80
|
- $this->fail('编辑失败');
|
|
|
|
81
|
- }
|
|
|
|
82
|
- Common::del_user_cache($this->model,$this->param['id'],'A');
|
|
|
|
83
|
- return $this->success();
|
89
|
+ return $this->success($param);
|
|
84
|
}
|
90
|
}
|
|
85
|
|
91
|
|
|
86
|
/**
|
92
|
/**
|
|
@@ -89,36 +95,15 @@ class UserLogic extends BaseLogic |
|
@@ -89,36 +95,15 @@ class UserLogic extends BaseLogic |
|
89
|
* @author :liyuhang
|
95
|
* @author :liyuhang
|
|
90
|
* @method
|
96
|
* @method
|
|
91
|
*/
|
97
|
*/
|
|
92
|
- public function user_del(){
|
98
|
+ public function user_del()
|
|
|
|
99
|
+ {
|
|
93
|
$ids = $this->param['id'];
|
100
|
$ids = $this->param['id'];
|
|
94
|
- $this->param['id'] = ['in',$this->param['id']];
|
101
|
+ $this->param['id'] = ['in', $this->param['id']];
|
|
95
|
$rs = $this->model->del($this->param);
|
102
|
$rs = $this->model->del($this->param);
|
|
96
|
- if($rs === false){
|
103
|
+ if ($rs === false) {
|
|
97
|
$this->fail('删除失败');
|
104
|
$this->fail('删除失败');
|
|
98
|
}
|
105
|
}
|
|
99
|
- Common::del_user_cache($this->model,$ids,'A');
|
106
|
+ Common::del_user_cache($this->model, $ids, 'A');
|
|
100
|
return $this->success();
|
107
|
return $this->success();
|
|
101
|
}
|
108
|
}
|
|
102
|
-
|
|
|
|
103
|
- /**
|
|
|
|
104
|
- * @remark :验证手机号
|
|
|
|
105
|
- * @name :verifyMobile
|
|
|
|
106
|
- * @author :lyh
|
|
|
|
107
|
- * @method :post
|
|
|
|
108
|
- * @time :2023/6/25 9:47
|
|
|
|
109
|
- */
|
|
|
|
110
|
- public function verifyMobile(){
|
|
|
|
111
|
- if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
112
|
- $info = $this->model->read(['mobile'=>$this->param['mobile'],'id'=>['!=',$this->param['id']]]);
|
|
|
|
113
|
- if($info !== false){
|
|
|
|
114
|
- $this->fail('当前手机号码已存在');
|
|
|
|
115
|
- }
|
|
|
|
116
|
- }else{
|
|
|
|
117
|
- $info = $this->model->read(['mobile'=>$this->param['mobile']]);
|
|
|
|
118
|
- if($info !== false){
|
|
|
|
119
|
- $this->fail('当前手机号码已存在');
|
|
|
|
120
|
- }
|
|
|
|
121
|
- }
|
|
|
|
122
|
- return true;
|
|
|
|
123
|
- }
|
|
|
|
124
|
} |
109
|
} |