ManageLogic.php
2.9 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\Logic\Aside\Manage;
use App\Helper\Common;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\Manage;
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'])){
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']]);
Common::del_user_cache('manager',$this->param['id'],'A');
}else{
$this->param['password'] = Hash::make($this->param['password']);
$this->model->add($this->param);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @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 = Common::get_user_cache('manager',$this->param['id'],'A');
if(empty($info)){
$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');
}
Common::set_user_cache('manager',$this->param['id'],'A');
}
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();
}
}