|
|
@@ -2050,7 +2050,6 @@ class NewsService implements NewsServiceInterface
|
|
|
->pluck('zwpid');
|
|
|
$zwids = array_values(array_unique($zwids->toArray()));
|
|
|
}
|
|
|
- // return Result::success($rs_query);
|
|
|
$count = JobPosition::whereIn('zwid', $zwids)->count();
|
|
|
$position = JobPosition::whereIn('zwid', $zwids)
|
|
|
->offset(($page - 1) * $page_size)
|
|
|
@@ -2073,6 +2072,69 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 职位分类-添加
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function addJobPosition(array $data):array
|
|
|
+ {
|
|
|
+ $zw_name = JobPosition::where('zwpid', $data['zwpid'])
|
|
|
+ ->where('zwname', $data['zwname'])->first(['zwid']);
|
|
|
+ if(!empty($zw_name)){
|
|
|
+ return Result::error('职位分类已存在');
|
|
|
+ }
|
|
|
+ $zw = JobPosition::insertGetId($data);
|
|
|
+ if(empty($zw)){
|
|
|
+ return Result::error('添加失败');
|
|
|
+ }
|
|
|
+ return Result::success($zw);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 更新职位分类
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function upJobPosition(array $data):array
|
|
|
+ {
|
|
|
+ $zw_position = JobPosition::get();
|
|
|
+ if(!in_array($data['zwid'], $zw_position->pluck('zwid')->toArray())){
|
|
|
+ return Result::error('职位分类不存在');
|
|
|
+ }
|
|
|
+ $zw_name = $zw_position->where('zwid', '!=', $data['zwid'])
|
|
|
+ ->where('zwpid', $data['zwpid'])
|
|
|
+ ->where('zwname', $data['zwname'])->first();
|
|
|
+ if(!empty($zw_name)){
|
|
|
+ return Result::error('职位分类已存在');
|
|
|
+ }
|
|
|
+ $result = JobPosition::where('zwid', $data['zwid'])->update($data);
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error('更新失败');
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 删除职位分类
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function delJobPosition(array $data):array
|
|
|
+ {
|
|
|
+ $zw_jobposition = JobPosition::get();
|
|
|
+ $zw_id = $zw_jobposition->where('zwid', $data['zwid'])->first();
|
|
|
+ if(empty($zw_id)){
|
|
|
+ return Result::error('职位分类不存在');
|
|
|
+ }
|
|
|
+ $zw_job = JobPosition::when($zw_id->zwpid == 0,function($query)use($zw_id){
|
|
|
+ $query->where('zwpid', $zw_id->zwid);
|
|
|
+ })->first();
|
|
|
+ if(!empty($zw_job)){
|
|
|
+ return Result::error('请先删除子分类');
|
|
|
+ }
|
|
|
+ $result = JobPosition::where('zwid', $data['zwid'])->delete();
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error('删除失败');
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
}
|