Ver Fonte

添加行业分类相关接口:获取行业分类列表、添加行业分类、修改行业分类、删除行业分类、获取职位分类列表

FengR há 1 mês atrás
pai
commit
eefcf8518d
2 ficheiros alterados com 169 adições e 0 exclusões
  1. 143 0
      app/JsonRpc/NewsService.php
  2. 26 0
      app/JsonRpc/NewsServiceInterface.php

+ 143 - 0
app/JsonRpc/NewsService.php

@@ -8615,4 +8615,147 @@ class NewsService implements NewsServiceInterface
     $producer = ContextApplicationContext::getContainer()->get(Producer::class);
     $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);
+    }
 }

+ 26 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -460,4 +460,30 @@ interface NewsServiceInterface
     public function readJobResume(array $data): array;
     public function readJobApply(array $data): array;
     public function readNotice(array $data): array;
+    // 行业分类管理  ------1121
+     /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobIndustryList(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addJobIndustry(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function upJobIndustry(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function delJobIndustry(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobPositionList(array $data):array;
 }