HrLogic.php
6.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
namespace App\Http\Logic\Aside\Manage;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\Group;
use App\Models\Manage\JobLevel;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Manage\Menu;
use Illuminate\Support\Facades\Hash;
/**
* Class ManageHrLogic
* @package App\Http\Logic\Aside\Manage
* @author zgj
* @date 2023/5/30
*/
class HrLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new ManageHr();
}
/**
* @remark :获取列表
* @name :getList
* @author :lyh
* @method :post
* @time :2023/7/24 11:50
*/
public function getHrList($map,$page,$row,$order = 'id',$filed = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$filed);
return $this->success($lists);
}
/**
* @remark :保存数据
* @name :hrSave
* @author :lyh
* @method :post
* @time :2023/9/6 10:17
*/
public function hrSave(){
//处理参数
foreach ($this->model::specieField() as $v){
$this->param = $this->setJson($v,$this->param);
}
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
//添加管理员账号
$this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']);
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('系统错误');
}
return $this->success();
}
/**
* @remark :获取详情
* @name :getHrInfo
* @author :lyh
* @method :post
* @time :2023/7/25 9:27
*/
public function getHrInfo($id){
//查看当前用户是否有人事权限
if($this->manager['gid'] != ManageHr::GID_ZERO){
$groupModel = new Group();
$groupInfo = $groupModel->read(['id'=>$this->manager['gid']]);
if (!in_array(20,$groupInfo['rights']) && ($id != $this->manager['id'])) {
$this->fail('无权限查看其他用户信息');
}
}
$data = $this->model->read(['id'=>$id]);
foreach ($this->model::specieField() as $v){
$data[$v] = json_decode($data[$v],true);
}
return $this->success($data);
}
//数组转json存储
public function setJson($str,$param){
if(isset($param[$str]) && is_array($param[$str])){
$param[$str] = json_encode($param[$str]);
}
return $param;
}
/**
* @remark :获取所有搜索参数
* @name :getParams
* @author :lyh
* @method :post
* @time :2023/7/24 11:05
*/
public function getSearchParams(){
$data['belong_group'] = $this->belongGroupList();
$data['education'] = $this->educationList();
$data['entry_position'] = $this->entryPositionList();
$data['p_level'] = $this->pLevel();
$data['political_outlook'] = $this->politicalOutlook();
$data['party_branch'] = $this->IsPartyBranch();
return $data;
}
/**
* @remark :获取归属小组
* @name :belongGroupList
* @author :lyh
* @method :post
* @time :2023/7/22 17:35
*/
public function belongGroupList(){
$belongingGroupModel = new BelongingGroup();
$lists = $belongingGroupModel->list();
return $this->success($lists);
}
/**
* @remark :获取学历
* @name :educationList
* @author :lyh
* @method :post
* @time :2023/7/22 17:49
*/
public function educationList(){
$data = [
1 => '专科',
2 => '本科',
3 => '研究生及以上',
0 => '其他',
];
return $this->success($data);
}
/**
* @remark :入职岗位
* @name :entryPositionList
* @author :lyh
* @method :post
* @time :2023/7/22 17:51
*/
public function entryPositionList(){
$entryPositionModel = new EntryPosition();
$lists = $entryPositionModel->list();
return $this->success($lists);
}
/**
* @remark :职务级别
* @name :pLevel
* @author :lyh
* @method :post
* @time :2023/7/22 18:10
*/
public function pLevel(){
$jobLevelModel = new JobLevel();
$lists = $jobLevelModel->list();
return $this->success($lists);
}
/**
* @remark :政治面貌
* @name :politicalOutlook
* @author :lyh
* @method :post
* @time :2023/7/24 10:57
*/
public function politicalOutlook(){
$data = [
1 => '预备党员',
2 => '正式党员',
0 => '群众',
];
return $this->success($data);
}
/**
* @remark :是否有党支部
* @name :IsPartyBranch
* @author :lyh
* @method :post
* @time :2023/7/24 11:01
*/
public function IsPartyBranch(){
$data = [
1 => '是',
2 => '否',
0 => '无',
];
return $this->success($data);
}
/**
* @remark :添加人事信息时 同步添加管理员账号
* @name :addManager
* @author :lyh
* @method :post
* @time :2023/9/6 10:18
*/
public function addManager($mobile,$name){
$managerModel = new Manage();
$info = $managerModel->read(['mobile'=>$mobile]);
if($info !== false){
$this->fail('当前号码已存在');
}
$data = [
'name'=>$name,
'mobile'=>$mobile,
'password'=>Hash::make('globalsov6'),
'gid'=>4,
];
return $managerModel->addReturnId($data);
}
/**
* @param $page_size
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getHrListForV5($page_size)
{
$list = $this->model->with('dept')->with('position')->select(['name', 'id_card', 'mobile', 'dept_id', 'entry_position', 'status'])->orderBy('id', 'desc')->paginate($page_size);
return $list;
}
}