|
@@ -8615,4 +8615,147 @@ class NewsService implements NewsServiceInterface
|
|
|
$producer = ContextApplicationContext::getContainer()->get(Producer::class);
|
|
$producer = ContextApplicationContext::getContainer()->get(Producer::class);
|
|
|
$producer->produce($message);
|
|
$producer->produce($message);
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 行业分类管理 ------1121
|
|
|
|
|
+ * @param array $data
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getJobIndustryList(array $data):array
|
|
|
|
|
+ {
|
|
|
|
|
+ $page = $data['page'] ?? 1;
|
|
|
|
|
+ $page_size = $data['page_size'] ?? 10;
|
|
|
|
|
+ if(isset($data['hyname']) && !empty($data['hyname'])){
|
|
|
|
|
+ $where = ['hyname', 'like', '%' . $data['hyname'] . '%'];
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $where = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $rs_query = JobIndustry::when(!empty($where), function ($query) use ($where) {
|
|
|
|
|
+ $query->where([$where]); // 修复:将条件包装成二维数组
|
|
|
|
|
+ })
|
|
|
|
|
+ ->orderBy('updated_at', 'desc');
|
|
|
|
|
+ $count = $rs_query->count();
|
|
|
|
|
+ $hy = $rs_query->offset(($page - 1) * $page_size)->limit($page_size)->get()->all();
|
|
|
|
|
+ $result = [
|
|
|
|
|
+ 'count' => $count,
|
|
|
|
|
+ 'list' => $hy,
|
|
|
|
|
+ ];
|
|
|
|
|
+ if(empty($hy)){
|
|
|
|
|
+ return Result::success('暂无数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result::success($result);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 添加行业分类
|
|
|
|
|
+ * @param array $data
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ */
|
|
|
|
|
+ public function addJobIndustry(array $data):array
|
|
|
|
|
+ {
|
|
|
|
|
+ $hy_name = JobIndustry::where('hyname', $data['hyname'])->first(['hyid']);
|
|
|
|
|
+ if(!empty($hy_name)){
|
|
|
|
|
+ return Result::error('行业分类已存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ $hy = JobIndustry::insertGetId($data);
|
|
|
|
|
+ if(empty($hy)){
|
|
|
|
|
+ return Result::error('添加失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result::success($hy);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新行业分类
|
|
|
|
|
+ * @param array $data
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ */
|
|
|
|
|
+ public function upJobIndustry(array $data):array
|
|
|
|
|
+ {
|
|
|
|
|
+ $hy_query = JobIndustry::get();
|
|
|
|
|
+ $hy_ids = $hy_query->pluck('hyid')->toArray();
|
|
|
|
|
+ $hy_names = $hy_query->pluck('hyname')->toArray();
|
|
|
|
|
+ if(!in_array($data['hyid'], $hy_ids)){
|
|
|
|
|
+ return Result::error('行业分类不存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ if(isset($data['hyname']) && !empty($data['hyname'])){
|
|
|
|
|
+ $other_key_hy = array_search($data['hyid'], $hy_ids);
|
|
|
|
|
+ // return Result::success($other_key_hy);
|
|
|
|
|
+ unset($hy_names[$other_key_hy]);
|
|
|
|
|
+ if(in_array($data['hyname'], $hy_names)){
|
|
|
|
|
+ return Result::error('行业分类名称已存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $hy = JobIndustry::where('hyid', $data['hyid'])->update($data);
|
|
|
|
|
+ if(empty($hy)){
|
|
|
|
|
+ return Result::error('更新失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result::success($hy);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除行业分类
|
|
|
|
|
+ * @param array $data
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ */
|
|
|
|
|
+ public function delJobIndustry(array $data):array
|
|
|
|
|
+ {
|
|
|
|
|
+ $hy_id = JobIndustry::where('hyid', $data['hyid'])->first(['hyid']);
|
|
|
|
|
+ if(empty($hy_id)){
|
|
|
|
|
+ return Result::error('行业分类不存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ $hy = JobIndustry::where('hyid', $data['hyid'])->delete();
|
|
|
|
|
+ if(empty($hy)){
|
|
|
|
|
+ return Result::error('删除失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result::success($hy);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 职位分类-列表
|
|
|
|
|
+ * @param array $data
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getJobPositionList(array $data):array
|
|
|
|
|
+ {
|
|
|
|
|
+ $page = $data['page'] ?? 1;
|
|
|
|
|
+ $page_size = $data['page_size'] ?? 10;
|
|
|
|
|
+ if(isset($data['zwname']) && !empty($data['zwname'])){
|
|
|
|
|
+ $where = ['zwname', 'like', '%' . $data['zwname'] . '%'];
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $where = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ if($data['is_pid'] == 0){
|
|
|
|
|
+ $zwids = JobPosition::where('zwpid', 0)
|
|
|
|
|
+ ->when(!empty($where), function ($query) use ($where) {
|
|
|
|
|
+ $query->where([$where]); // 修复:将条件包装成二维数组
|
|
|
|
|
+ })
|
|
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
|
|
+ ->pluck('zwid');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $zwids = JobPosition::where('zwpid', '!=', 0)
|
|
|
|
|
+ ->when(!empty($where), function ($query) use ($where) {
|
|
|
|
|
+ $query->where([$where]); // 修复:将条件包装成二维数组
|
|
|
|
|
+ })
|
|
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
|
|
+ ->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)
|
|
|
|
|
+ ->limit($page_size)->get()
|
|
|
|
|
+ ->map(function ($item) use ($data, $where) {
|
|
|
|
|
+ $item->children = $item->where('zwpid', $item->zwid)
|
|
|
|
|
+ ->when(!empty($where) && $data['is_pid'] == 1, function ($query) use ($where) {
|
|
|
|
|
+ $query->where([$where]); // 修复:将条件包装成二维数组
|
|
|
|
|
+ })
|
|
|
|
|
+ ->get();
|
|
|
|
|
+ return $item;
|
|
|
|
|
+ })
|
|
|
|
|
+ ->all();
|
|
|
|
|
+ $result = [
|
|
|
|
|
+ 'count' => $count,
|
|
|
|
|
+ 'list' => $position,
|
|
|
|
|
+ ];
|
|
|
|
|
+ if(empty($result)){
|
|
|
|
|
+ return Result::success('暂无数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result::success($result);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|