ManageLogic.php
4.3 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
142
143
144
145
<?php
namespace App\Http\Logic\Aside\Manage;
use App\Helper\Common;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Manage\Menu;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
/**
* Class ManageLogic
* @package App\Http\Logic\Aside\Manage
* @author zbj
* @date 2023/4/20
*/
class ManageLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new Manage();
}
/**
* @remark :保存管理员
* @name :managerSave
* @author :lyh
* @method :post
* @time :2023/9/11 9:34
*/
public function managerSave(){
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->editManager();
Common::del_user_cache('manager',$this->param['id'],'A');
}else{
$this->addManager();
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :添加管理员
* @name :addManager
* @author :lyh
* @method :post
* @time :2023/9/20 15:49
*/
public function addManager(){
$managerInfo = $this->model->read(['mobile'=>$this->param['mobile']]);
if($managerInfo !== false){
$this->fail('当前手机号码已存在');
}
$this->param['password'] = Hash::make($this->param['password']);
$this->model->add($this->param);
$this->success();
}
/**
* @remark :编辑管理员
* @name :editManager
* @author :lyh
* @method :post
* @time :2023/9/20 15:51
*/
public function editManager(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['mobile'] != $this->param['mobile']){
$mobileInfo = $this->model->read(['mobile'=>$this->param['mobile']]);
if($mobileInfo !== false){
$this->fail('当前手机号码在管理员信息中已存在');
}
//查看人事信息中是否关联当前管理员账号
$hrManagerModel = new ManageHr();
$hrInfo = $hrManagerModel->read(['manage_id'=>$this->param['id']]);
if($hrInfo !== false){
//查看是否号码在存在人事表中
$hrMobileInfo = $hrManagerModel->read(['mobile'=>$this->param['mobile']]);
if($hrMobileInfo !== false){
$this->fail('当前号码已存在人事信息中');
}
$hrManagerModel->edit(['mobile'=>$this->param['mobile']],['manage_id'=>$this->param['id']]);
}
}
if(isset($this->param['password']) && !empty($this->param['password'])){
$this->param['password'] = Hash::make($this->param['password']);
}
$this->model->edit($this->param,['id'=>$this->param['id']]);
}
/**
* @remark :设置排序
* @name :setSort
* @author :lyh
* @method :post
* @time :2023/8/10 16:42
*/
public function setParamStatus(){
$rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('修改失败');
}
return $this->success();
}
/**
* @remark :获取数据详情
* @name :getManagerInfo
* @author :lyh
* @method :post
* @time :2023/8/28 16:10
*/
public function getManagerInfo(){
$info = $this->model->read(['id'=>$this->param['id']],
['id','name','email','mobile','status','gid','sort','dept_id','is_dept_manager','created_at','role','updated_at']);
if($info === false){
$this->fail('error');
}
return $this->success($info);
}
/**
* @remark :删除
* @name :managerDelete
* @author :lyh
* @method :post
* @time :2023/9/15 10:45
*/
public function managerDelete(){
$rs = $this->model->del(['id'=>['in',$this->param['ids']]]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
Common::del_user_cache('manager',$this->param['ids'],'A');
return $this->success();
}
}