|
|
@@ -8794,56 +8794,52 @@ class NewsService implements NewsServiceInterface
|
|
|
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
|
|
|
+ public function delJobPosition(array $data): array
|
|
|
{
|
|
|
- $zw_position = JobPosition::get();
|
|
|
- if (!in_array($data['zwid'], $zw_position->pluck('zwid')->toArray())) {
|
|
|
+ $zw_jobposition = JobPosition::get();
|
|
|
+ $zw_id = $zw_jobposition->where('zwid', $data['zwid'])->first();
|
|
|
+ if (empty($zw_id)) {
|
|
|
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('职位分类已存在');
|
|
|
+ if ($zw_id->zwpid == 0) {
|
|
|
+ $zw_job = JobPosition::where('zwpid', $zw_id->zwid)->first();
|
|
|
+ if (!empty($zw_job)) {
|
|
|
+ return Result::error('请先删除子分类');
|
|
|
+ }
|
|
|
}
|
|
|
- $result = JobPosition::where('zwid', $data['zwid'])->update($data);
|
|
|
+ $result = JobPosition::where('zwid', $data['zwid'])->delete();
|
|
|
if (empty($result)) {
|
|
|
- return Result::error('更新失败');
|
|
|
+ return Result::error('删除失败');
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 删除职位分类
|
|
|
+ * 更新职位分类
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function delJobPosition(array $data): array
|
|
|
+ public function upJobPosition(array $data): array
|
|
|
{
|
|
|
- $zw_jobposition = JobPosition::get();
|
|
|
- $zw_id = $zw_jobposition->where('zwid', $data['zwid'])->first();
|
|
|
- if (empty($zw_id)) {
|
|
|
+ $zw_position = JobPosition::get();
|
|
|
+ if (!in_array($data['zwid'], $zw_position->pluck('zwid')->toArray())) {
|
|
|
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('请先删除子分类');
|
|
|
+ $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'])->delete();
|
|
|
+ $result = JobPosition::where('zwid', $data['zwid'])->update($data);
|
|
|
if (empty($result)) {
|
|
|
- return Result::error('删除失败');
|
|
|
+ return Result::error('更新失败');
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|