MenuSpecialLogic.php
3.5 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
<?php
/**
* @remark :
* @name :MenuSpecialLogic.php
* @author :lyh
* @method :post
* @time :2023/8/7 11:56
*/
namespace App\Http\Logic\Aside\Manage;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Manage\MenuSpecial;
class MenuSpecialLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new MenuSpecial();
}
/**
* @remark :添加时获取用户列表
* @name :managerList
* @author :lyh
* @method :post
* @time :2023/8/7 14:33
*/
public function managerList($map){
$managerModel = new Manage();
$query = $managerModel->leftJoin('gl_manage_hr', 'gl_manage.id', '=', 'gl_manage_hr.manage_id');
$query = $this->searchParam($query,$map);
$lists = $query->select($this->selectParam())->get()->toArray();
return $this->success($lists);
}
/**
* @remark :搜索
* @name :searchParam
* @author :lyh
* @method :post
* @time :2024/10/24 11:50
*/
public function searchParam(&$query,$map){
$query = $query->where('gl_manage_hr.status', null)->orWhere('gl_manage_hr.status', $map['status'] ?? 1);
return $query;
}
/**
* 需要查询的字段
* @return array
*/
public function selectParam(){
$select = [
'gl_manage.id AS id',
'gl_manage.name AS name',
'gl_manage_hr.status as status'
];
return $select;
}
/**
* @remark :获取详情
* @name :specialInfo
* @author :lyh
* @method :post
* @time :2023/8/7 14:15
*/
public function specialInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或者被删除');
}
$info['manager_list'] = $this->manager_list($info['user_list']);
return $this->success($info);
}
/**
* @remark :获取所有用户名称
* @name :manager_list
* @author :lyh
* @method :post
* @time :2023/8/7 14:17
*/
public function manager_list($manager_id){
$managerModel = new Manage();
$list = $managerModel->list(['id'=>['in',explode(',',trim($manager_id,','))]]);
$str = '';
foreach ($list as $k => $v){
$str .= $v['name'].',';
}
return trim($str,',');
}
/**
* @remark :保存
* @name :specialSave
* @author :lyh
* @method :post
* @time :2023/8/7 13:52
*/
public function specialSave(){
if(isset($this->param['user_list']) && !empty($this->param['user_list'])){
$this->param['user_list'] = ','.trim($this->param['user_list'],',').',';
}else{
$this->param['user_list'] = '';
}
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @remark :删除
* @name :specialDel
* @author :lyh
* @method :post
* @time :2023/8/7 13:52
*/
public function specialDel(){
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}