Ver código fonte

第一期项目合并master

rkljw 5 meses atrás
pai
commit
e4a85e6201

+ 0 - 222
app/JsonRpc/NewsService.php

@@ -1,222 +0,0 @@
-<?php
-namespace App\JsonRpc;
-
-use App\Model\Article;
-use App\Model\ArticleData;
-use App\Model\Category;
-use Hyperf\DbConnection\Db;
-use Hyperf\RpcServer\Annotation\RpcService;
-use App\Tools\Result;
-
-#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
-class NewsService implements NewsServiceInterface
-{
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function getCategoryList(array $data): array
-    {
-        $where = [
-            ['name','like','%'.$data['keyWord'].'%'],
-            ['website_id','=',$data['website_id']],
-            ['pid','=',$data['pid']??0]
-        ];
-        $rep = Category::where($where)->limit($data['pageSize'])->orderBy("sort","asc")->offset(($data['page']-1)*$data['pageSize'])->get();
-        $count =  Category::where($where)->count();
-        $data = [
-            'rows'=>$rep->toArray(),
-            'count'=>$count
-        ];
-        if(empty($rep->toArray())){
-            return Result::error("没有栏目数据");
-        }
-        return Result::success($data);
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function categoryList(array $data): array
-    {
-       $result =  Category::where($data)->get();
-        if(empty($result)){
-            return Result::error("没有栏目数据");
-        }
-        return Result::success($result);
-    }
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function addCategory(array $data): array
-    {
-        $id = Category::insertGetId($data);
-        if(empty($id)){
-            return Result::error("添加失败");
-        }
-        return Result::success(['id'=>$id]);
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function delCategory(array $data): array
-    {
-        $categoryList = Category::where(['pid'=>$data['id']])->get();
-        var_dump("分类列表:",$data,$categoryList);
-        if($categoryList->toArray()){
-            return Result::error("分类下面有子分类不能删除");
-        }
-        $articleList = Article::where(['catid'=>$data['id']])->get();
-        var_dump("文章列表:",$articleList);
-        if($articleList->toArray()){
-            return Result::error("分类下面有资讯不能删除");
-        }
-        $result = Category::where($data)->delete();
-        if(!$result){
-            return Result::error("删除失败");
-        }
-        return Result::success($result);
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function updateCategory(array $data): array
-    {
-        $where = [
-            'id'=>$data['id']
-        ];
-        $result = Category::where($where)->update($data);
-        if($result){
-            return Result::success($result);
-        }else{
-            return Result::error("更新失败");
-        }
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function getArticleList(array $data): array
-    {
-        var_dump("资讯:",$data);
-        $where= [];
-        if(isset($data['keyWord'])){
-            $where[] =   ['article.title','like','%'.$data['keyWord'].'%'];
-            $where[] =   ['article.status','!=','5'];
-        }
-        $rep = Article::where($where)
-            ->leftJoin('category','article.catid','category.id')
-            ->leftJoin("article_data","article.id","article_data.article_id")
-            ->select("article.*","category.name","article_data.content")
-            ->orderBy("article.id","desc")
-            ->limit($data['pageSize'])
-            ->offset(($data['page']-1)*$data['pageSize'])->get();
-        $count =  Article::where($where)->count();
-        $data = [
-            'rows'=>$rep->toArray(),
-            'count'=>$count
-        ];
-        if(empty($rep)){
-            return Result::error("没有信息数据");
-        }
-        return Result::success($data);
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function addArticle(array $data): array
-    {
-        Db::beginTransaction();
-        try{
-
-        $data['cat_arr_id'] = isset($data['cat_arr_id'])?json_encode($data['cat_arr_id']):'';
-        $data['tag'] = isset($data['tag'])?json_encode($data['tag']):'';
-            $articleData = $data;
-            unset($articleData['content']);
-            $id = Article::insertGetId($articleData);
-            $articleDataContent = [
-                'article_id'=>$id,
-                'content'=>$data['content']
-            ];
-            ArticleData::insertGetId($articleDataContent);
-            Db::commit();
-        } catch(\Throwable $ex){
-            Db::rollBack();
-            var_dump($ex->getMessage());
-            return Result::error("创建失败",0);
-        }
-
-        return Result::success(['id'=>$id]);
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function delArticle(array $data): array
-    {
-        $result = Article::where($data)->update(['status'=>5]);
-        if(!$result){
-            return Result::error("删除失败");
-        }
-        return Result::success($result);
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function updateArticle(array $data): array
-    {
-        Db::beginTransaction();
-        try{
-            $data['cat_arr_id'] = isset($data['cat_arr_id'])?json_encode($data['cat_arr_id']):'';
-            $data['tag'] = isset($data['tag'])?json_encode($data['tag']):'';
-            $articleData = $data;
-            unset($articleData['content']);
-            unset($articleData['status_name']);
-            unset($articleData['name']);
-            unset($articleData['content']);
-            unset($articleData['pid_arr']);
-            unset($articleData['pid']);
-            $id = Article::where(['id'=>$data['id']])->update($articleData);
-            $articleDataContent = [
-                'content'=>$data['content']
-            ];
-            ArticleData::where(['article_id'=>$data['id']])->update($articleDataContent);
-        } catch(\Throwable $ex){
-            Db::rollBack();
-            var_dump($ex->getMessage());
-            return Result::error("更新失败",0);
-        }
-        return Result::success([]);
-
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function getArticleInfo(array $data): array
-    {
-        $where = [
-            'article.id'=>$data['id']
-        ];
-        $result = Article::where($where)->leftJoin("article_data","article.id","article_data.article_id")->first();
-        if($result){
-            return Result::success($result->toArray());
-        }else{
-            return Result::error("查询失败",0);
-        }
-    }
-}

+ 0 - 65
app/JsonRpc/NewsServiceInterface.php

@@ -1,65 +0,0 @@
-<?php
-namespace App\JsonRpc;
-interface NewsServiceInterface
-{
-    /**
-     * @param array $data
-     *  @return array
-    */
-    public function getCategoryList(array $data):array;
-    /**
-     * @param array $data
-     *  @return array
-     */
-    public function categoryList(array $data):array;
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function addCategory(array $data):array;
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function delCategory(array $data):array;
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function updateCategory(array $data):array;
-
-    /**
-     * @param string $keyword
-     * @param int $page
-     * @param int $pageSize
-     */
-    public function getArticleList(array $data):array;
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function addArticle(array $data):array;
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function delArticle(array $data):array;
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function updateArticle(array $data):array;
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function getArticleInfo(array $data):array;
-
-}

+ 32 - 14
app/JsonRpc/PublicRpcService.php

@@ -21,25 +21,22 @@ class PublicRpcService implements PublicRpcServiceInterface
     public function getDistrictList(array $data): array
     public function getDistrictList(array $data): array
     {
     {
         $where = [];
         $where = [];
-        if (isset($data['keyWord'])) {
-            $where = [
-                ['name', 'like', '%' . $data['keyWord'] . '%'],
-            ];
+       if(isset($data['keyWord'])){
+           $where = [
+               ['name','like','%'.$data['keyWord'].'%']
+           ];
         }
         }
-
-        $result = [];
-        if (isset($data['pageSize'])) {
-            $rep = District::where($where)->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("code", "asc")->get();
+        $result  = [];
+        if(isset($data['pageSize'])){
+            $rep = District::where($where)->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("code","asc")->get();
             $count = District::where($where)->count();
             $count = District::where($where)->count();
             $result = [
             $result = [
-                'rows' => $rep,
-                'count' => $count,
+                'rows'=>$rep,
+                'count'=>$count
+
             ];
             ];
-        } else {
-            $result = District::where($data)->orderBy("code", "asc")->get();
         }
         }
-
-        return $result ? Result::success($result) : Result::error("没有查到数据");
+        return $result?Result::success($result):Result::error("没有查到数据");
     }
     }
 
 
     /**
     /**
@@ -381,6 +378,7 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         }
 
 
     }
     }
+
     /**
     /**
      * 后台获取职能部门
      * 后台获取职能部门
      * @param array $data
      * @param array $data
@@ -460,4 +458,24 @@ class PublicRpcService implements PublicRpcServiceInterface
             return Result::success();
             return Result::success();
         }
         }
     }
     }
+
+
+    /**
+     * 查询职能列表
+     * @param array $data
+     * @return array
+     */
+    public function getDepartment(array $data) :array
+    {
+        $where = [
+            'pid'=>$data['pid']??0
+        ];
+        $result = Department::where($where)->orderBy("sort","desc")->get();
+        if (empty($result)) {
+            return Result::error("查询失败", 0);
+        }else{
+            return Result::success($result);
+        }
+    }
 }
 }
+

+ 5 - 0
app/JsonRpc/PublicRpcServiceInterface.php

@@ -97,8 +97,13 @@ interface PublicRpcServiceInterface
      * @param array $data
      * @param array $data
      * @return array
      * @return array
      */
      */
+
     public function getZhinengbumenList(array $data): array;
     public function getZhinengbumenList(array $data): array;
 
 
+    public function getDepartment(array $data): array;
+
+
+
     /**
     /**
      * @param array $data
      * @param array $data
      * @return array
      * @return array

+ 466 - 16
app/JsonRpc/WebsiteService.php

@@ -1,11 +1,16 @@
 <?php
 <?php
 namespace App\JsonRpc;
 namespace App\JsonRpc;
+use App\Model\Article;
+use App\Model\Category;
+use App\Model\LetterOfComplaint;
 use App\Model\TemplateClass;
 use App\Model\TemplateClass;
 use App\Model\Template;
 use App\Model\Template;
+use App\Model\User;
 use App\Model\WebsiteRole;
 use App\Model\WebsiteRole;
 use App\Model\WebsiteRoleUser;
 use App\Model\WebsiteRoleUser;
 use App\Model\Website;
 use App\Model\Website;
 use App\Model\WebsiteColumn;
 use App\Model\WebsiteColumn;
+use Hyperf\DbConnection\Db;
 use Hyperf\RpcServer\Annotation\RpcService;
 use Hyperf\RpcServer\Annotation\RpcService;
 use App\Tools\Result;
 use App\Tools\Result;
 use App\Model\WebsiteCategory;
 use App\Model\WebsiteCategory;
@@ -37,7 +42,7 @@ class WebsiteService implements WebsiteServiceInterface
             ->leftJoin("website_column","website.website_column_id","website_column.id")
             ->leftJoin("website_column","website.website_column_id","website_column.id")
             ->leftJoin("district","district.id","website.city_id")
             ->leftJoin("district","district.id","website.city_id")
             ->select("website.*","website_column.column_name","district.name as city_name")
             ->select("website.*","website_column.column_name","district.name as city_name")
-            ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->get();
+            ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("website.id","desc")->get();
 
 
         $count = Website::where($where)->count();
         $count = Website::where($where)->count();
         if (empty($result)) {
         if (empty($result)) {
@@ -116,7 +121,6 @@ class WebsiteService implements WebsiteServiceInterface
     public function delWebsite(int $id): array
     public function delWebsite(int $id): array
     {
     {
         $result = Website::where('id',$id )->delete();
         $result = Website::where('id',$id )->delete();
-        var_dump("删除站点",$result);
         if(empty($result)){
         if(empty($result)){
             return Result::error("删除失败",0);
             return Result::error("删除失败",0);
         }else{
         }else{
@@ -168,15 +172,16 @@ class WebsiteService implements WebsiteServiceInterface
      * @param int $pageSize
      * @param int $pageSize
      * @return array
      * @return array
      */
      */
-    public function getWebsiteColumnList(string $keyword,int $page,int $pageSize):array
+    public function getWebsiteColumnList(array $data):array
     {
     {
-        $where = [
-            ['website_column.column_name','like','%'.$keyword.'%']
-        ];
+        $where = [];
+        if(isset($data['keyword']) && $data['keyword']){
+            array_push($where,['website_column.column_name','like','%'.$data['keyword'].'%']);
+        }
         $result = WebsiteColumn::where($where)
         $result = WebsiteColumn::where($where)
             ->leftJoin("website_column as wc","website_column.pid","wc.id")
             ->leftJoin("website_column as wc","website_column.pid","wc.id")
             ->select("website_column.*","wc.column_name as parent_column_name")
             ->select("website_column.*","wc.column_name as parent_column_name")
-            ->limit($pageSize)->offset(($page-1)*$pageSize)->get();
+            ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->get();
         $count = WebsiteColumn::where($where)->count();
         $count = WebsiteColumn::where($where)->count();
         if (empty($result)) {
         if (empty($result)) {
             return Result::error("没有数据",0);
             return Result::error("没有数据",0);
@@ -237,6 +242,10 @@ class WebsiteService implements WebsiteServiceInterface
      */
      */
     public function delWebsiteColumn(int $id): array
     public function delWebsiteColumn(int $id): array
     {
     {
+        $list = WebsiteColumn::where(['pid'=>$id])->get();
+        if($list){
+            return Result::error("存在子网系,不能删除,请先删除子网系",0);
+        }
         $result = WebsiteColumn::where('id',$id )->delete();
         $result = WebsiteColumn::where('id',$id )->delete();
         if(empty($result)){
         if(empty($result)){
             return Result::error("删除失败",0);
             return Result::error("删除失败",0);
@@ -346,7 +355,7 @@ class WebsiteService implements WebsiteServiceInterface
             ['website_role_user.role_id','=',$roleId],
             ['website_role_user.role_id','=',$roleId],
         ];
         ];
         $count = WebsiteRoleUser::where($where)->count();
         $count = WebsiteRoleUser::where($where)->count();
-       $where[] =   ['u.user_name','like','%'.$keyword.'%'];
+        $where[] =   ['u.user_name','like','%'.$keyword.'%'];
         $result = WebsiteRoleUser::where($where)
         $result = WebsiteRoleUser::where($where)
             ->leftJoin("user as u","website_role_user.user_id","u.id")
             ->leftJoin("user as u","website_role_user.user_id","u.id")
             ->leftJoin("website as w","website_role_user.website_id","u.id")
             ->leftJoin("website as w","website_role_user.website_id","u.id")
@@ -431,10 +440,7 @@ class WebsiteService implements WebsiteServiceInterface
      */
      */
     public function getWebsiteId(array $data): array
     public function getWebsiteId(array $data): array
     {
     {
-        $where = [
-            'website_url'=>$data['website_url']
-        ];
-        $result = Website::where($where)->first();
+        $result = Website::whereJsonContains('website_url',$data['website_url'])->first();
         if(empty($result)){
         if(empty($result)){
             return Result::error("查询站点失败",0);
             return Result::error("查询站点失败",0);
         }else{
         }else{
@@ -467,6 +473,36 @@ class WebsiteService implements WebsiteServiceInterface
      */
      */
     public function getAdminIndex(array $data): array
     public function getAdminIndex(array $data): array
     {
     {
+        var_dump("用户类型:",$data['type_id']);
+         switch ($data['type_id']){
+             case 4:
+                 $result  = Db::select('SELECT  DATE(created_at) AS date,COUNT(*) AS total_count FROM  letter_of_complaint  WHERE  created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(created_at)  ORDER BY  date ASC;');
+                 return Result::success($result);
+                 break;
+             case 10000:
+                 $res = [];
+                 //网站
+                 $res['website']['count'] = 0;
+                 $res['website']['growth_rate'] = 0;
+                 //资讯
+                 $res['article']['count'] = 0;
+                 $res['article']['growth_rate'] = 0;
+                 //导航池
+                 $res['category']['count'] = 0;
+                 $res['category']['growth_rate'] = 0;
+                 //近一月数据
+                 $res['monthArticle']= [];
+                 //用户类型
+                 $res['userType'] = [];
+                 $res['website']['count']  = Website::where([])->count();
+                 $res['article']['count']  = Article::whereNotIn('status',['404'])->count();
+                 $res['category']['count']  = Category::where([])->count();
+                 $res['monthArticle']   = Db::select('SELECT  DATE(created_at) AS date,COUNT(*) AS total_count FROM  article  WHERE  created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(created_at)  ORDER BY  date ASC;');
+                 $res['userType']  = User::where([])->selectRaw("count(*) as counts,type_id")->groupBy('type_id')->get();
+                 return Result::success($res);
+
+         }
+
          return [];
          return [];
     }
     }
 
 
@@ -476,7 +512,11 @@ class WebsiteService implements WebsiteServiceInterface
      */
      */
     public function getTemplateClass(array $data): array
     public function getTemplateClass(array $data): array
     {
     {
-        $result = TemplateClass::orderBy('sort','asc')->get();
+        $where = [];
+        if(isset($data['name']) && $data['name']){
+            array_push($where,['name','like','%'.$data['name'].'%']);
+        }
+        $result = TemplateClass::where($where)->orderBy('sort','asc')->get();
         if(empty($result)){
         if(empty($result)){
             return Result::error("没有模板类型",0);
             return Result::error("没有模板类型",0);
         }else{
         }else{
@@ -551,9 +591,10 @@ class WebsiteService implements WebsiteServiceInterface
     {
     {
         $page = $data['page'];
         $page = $data['page'];
         $pageSize = $data['pageSize'];
         $pageSize = $data['pageSize'];
-        $where = [
-           'template_class_id'=> $data['template_class_id']
-        ];
+        $where = [];
+        if(isset($data['template_class_id'])  && $data['template_class_id']){
+            array_push($where,['template_class_id','=',$data['template_class_id']]);
+        }
         $result = Template::where($where)
         $result = Template::where($where)
             ->limit($pageSize)->offset(($page-1)*$pageSize)->get();
             ->limit($pageSize)->offset(($page-1)*$pageSize)->get();
         $count = Template::where($where)->count();
         $count = Template::where($where)->count();
@@ -628,4 +669,413 @@ class WebsiteService implements WebsiteServiceInterface
         }
         }
     }
     }
 
 
+    /**
+     * 搜索网站
+     * @param array $data
+     * @return array
+     */
+    public function websiteList(array $data): array
+    {
+        $where = [];
+        if(isset($data['keyword']) && !empty($data['keyword'])){
+            array_push($where,['website.website_name','like','%'.$data['keyword'].'%']);
+        }
+        $result = Website::where($where)->get();
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("没有网站",0);
+        }
+    }
+
+    public function addWebsiteCategory(array $data): array
+    {
+        $website_id = $data['website_id'];
+        $category_arr_id = $data['category_arr_id'];
+        $categoryList = Category::whereIn('id',$category_arr_id)->get();
+        $categoryListIds = [];
+        if($categoryList){
+            foreach ($categoryList->toArray() as $val){
+                array_push($categoryListIds,$val['id']);
+            }
+        }
+        $arr = [];
+        if($categoryListIds){
+            foreach ($categoryListIds as $v){
+                $ids =  $this->getUnderlingUIds(intval($v));
+                $ids_arr = explode(",", $ids);
+                array_push($arr,$ids_arr);
+            }
+        }
+        $mergedArray = [];
+        foreach ($arr as $subarray) {
+            $mergedArray = array_merge($mergedArray, $subarray);
+        }
+        var_dump("所有:",$arr,$mergedArray);
+        //查询出所有的分类进行分割插入 组装数据
+        $categoryListData = Category::whereIn('id',$mergedArray)->get();
+        $categoryListData = $categoryListData->toArray();
+        $insertData = [];
+        if($categoryListData){
+            foreach ($categoryListData as $key=>$value){
+                $insertData[$key]['website_id'] = $website_id;
+                $insertData[$key]['name'] = $value['name'];
+                $insertData[$key]['sort'] = $value['sort'];
+                $insertData[$key]['pid'] = $value['pid'];
+                $insertData[$key]['pid_arr'] = $value['pid_arr'];
+                $insertData[$key]['seo_title'] = $value['seo_title'];
+                $insertData[$key]['seo_keywords'] = $value['seo_keywords'];
+                $insertData[$key]['seo_description'] = $value['seo_description'];
+                $insertData[$key]['alias'] = $value['name'];
+                $insertData[$key]['category_id'] = $value['id'];
+            }
+        }
+        $result = WebsiteCategory::insert($insertData);
+        var_dump("插入数据状态:",$result);
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("创建失败",0);
+        }
+    }
+
+
+
+    /**
+     * 删除网站导航
+     * @param array $data
+     * @return array
+     */
+    public function delWebsiteCategory(array $data): array
+    {
+        $website_id = $data['website_id']??0;
+        $category_id = $data['category_id']??0;
+        $ids =  $this->getUnderlingUIds(intval($category_id));
+        $ids_arr = explode(",", $ids);
+        $result = WebsiteCategory::where(['website_id'=>$website_id])->whereIn("category_id",$ids_arr)->delete();
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("删除失败",0);
+        }
+    }
+
+    /**
+     * 获取网站导航
+     * @param array $data
+     * @return array
+     */
+    public function getAdminWebsiteCategory(array $data): array
+    {
+        $where = [
+            'website_id'=>$data['website_id'],
+            'pid'=>0
+        ];
+        $result = WebsiteCategory::where($where)->get();
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("查询失败",0);
+        }
+    }
+
+    /**
+     * 更新网站导航
+     * @param array $data
+     * @return array
+     */
+    public function upWebsiteCategory(array $data): array
+    {
+        Db::beginTransaction();
+        try{
+           //合并栏目id
+            $reqIds = array_merge($data['old_category_arr_id'],$data['new_category_arr_id']);
+            //对比old 数组差异化,把差异化的删除
+            $result = WebsiteCategory::where(['website_id'=>$data['website_id'],'pid'=>0])->get();
+            $result = $result->toArray();
+            $categoryIds = [];
+            if($result){
+                foreach ($result as $val){
+                    array_push($categoryIds,$val['category_id']);
+                }
+            }
+            //和原始数据对比取交际
+            $reqidsIntersect = array_intersect($reqIds,$categoryIds);
+            //再取差集 进行对比
+            $differenceIDS =  array_merge(array_diff($reqidsIntersect, $categoryIds),array_diff($categoryIds,$reqidsIntersect));
+            var_dump("差集:",$differenceIDS);
+            $arr_ids = [];
+            if(count($differenceIDS)>0){
+                foreach ($differenceIDS as $vv){
+                    $idV =  $this->getUnderlingUIds(intval($vv));
+                    $ids_arrV = explode(",", $idV);
+                    array_push($arr_ids,$ids_arrV);
+                }
+            }
+           $del_ids = array_reduce($arr_ids, 'array_merge', array());
+            //有差异  删除
+            if(count($del_ids)>0){
+                 WebsiteCategory::where(['website_id'=>$data['website_id']])->whereIn("category_id",$del_ids)->delete();
+            }
+            //传过来的值 和 交际 对比,选出要添加的值 进行插入
+           $insertIDS =  array_merge(array_diff($reqIds, $reqidsIntersect),array_diff($reqidsIntersect,$reqIds));
+            var_dump("要存储的:",$insertIDS);
+            //新的数组重新创建
+            if(count($insertIDS)>0){
+                $arr = [];
+                $categoryListIds = $insertIDS;
+                if($categoryListIds){
+                    foreach ($categoryListIds as $v){
+                        $ids =  $this->getUnderlingUIds(intval($v));
+                        $ids_arr = explode(",", $ids);
+                        array_push($arr,$ids_arr);
+                    }
+                }
+                $mergedArray = [];
+                foreach ($arr as $subarray) {
+                    $mergedArray = array_merge($mergedArray, $subarray);
+                }
+                var_dump("要插入的ID:",$mergedArray);
+                //查询出所有的分类进行分割插入 组装数据
+                $categoryListData = Category::whereIn('id',$mergedArray)->get();
+                $categoryListData = $categoryListData->toArray();
+                $insertData = [];
+                if($categoryListData){
+                    foreach ($categoryListData as $key=>$value){
+                        $insertData[$key]['website_id'] = $data['website_id'];
+                        $insertData[$key]['name'] = $value['name'];
+                        $insertData[$key]['sort'] = $value['sort'];
+                        $insertData[$key]['pid'] = $value['pid'];
+                        $insertData[$key]['pid_arr'] = $value['pid_arr'];
+                        $insertData[$key]['seo_title'] = $value['seo_title'];
+                        $insertData[$key]['seo_keywords'] = $value['seo_keywords'];
+                        $insertData[$key]['seo_description'] = $value['seo_description'];
+                        $insertData[$key]['alias'] = $value['name'];
+                        $insertData[$key]['category_id'] = $value['id'];
+                    }
+                }
+                 WebsiteCategory::insert($insertData);
+
+            }
+            Db::commit();
+        } catch(\Throwable $ex){
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("修改失败",0);
+        }
+
+        return Result::success();
+    }
+
+    /**
+     * 获取网站列表
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteCategoryList(array $data): array
+    {
+        $where = [];
+        if(isset($data['keyword']) && !empty($data['keyword'])){
+            array_push($where,['website.website_name','like','%'.$data['keyword'].'%']);
+        }
+        if(isset($data['website_column_id']) && !empty($data['website_column_id'])){
+            array_push($where,['website.website_column_id','=',$data['website_column_id']]);
+        }
+        $result = Website::where($where)
+            ->with(["websiteCategory"=>function ($query) {
+                $query->where(['pid'=>0])->select('website_id','name','alias','category_id');
+            }])
+            ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])
+            ->get();
+
+        $count = Website::where($where)->count();
+        if (empty($result)) {
+            return Result::error("没有数据",0);
+        }
+        $data = [
+            'rows'=>$result->toArray(),
+            'count'=>$count
+        ];
+         if($result){
+             return Result::success($data);
+         }else{
+             return Result::error("查询失败",0);
+         } 
+    }
+
+    /**
+     * 删除网站下的所有导航
+     * @param array $data
+     * @return array
+     */
+    public function delWebsiteAllCategory(array $data): array
+    {
+        $website_id = $data['website_id'];
+        $result = WebsiteCategory::where(['website_id'=>$website_id])->delete();
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("删除失败",0);
+        }
+    }
+
+    /**
+     * 获取网站下的某一个导航
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteCategoryOnes(array $data): array
+    {
+        $website_id = $data['website_id'];
+        $category_id = $data['category_id'];
+        $result = WebsiteCategory::where(['website_category.website_id'=>$website_id,'website_category.category_id'=>$category_id])
+            ->first();
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("查询失败",0);
+        }
+    }
+
+    /**
+     * 更新网闸下的某一个导航
+     * @param array $data
+     * @return array
+     */
+    public function upWebsiteCategoryones(array $data): array
+    {
+        $where = [
+            'website_id'=>$data['website_id'],
+            'category_id'=>$data['category_id'],
+        ];
+        $result = WebsiteCategory::where($where)->update($data);
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("更新失败",0);
+        }
+    }
+
+    /**
+     * 获取网站下的所有导航(包含子导航)
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteAllCategory(array $data): array
+    {
+        $where = [];
+        if(isset($data['website_id']) && !empty($data['website_id'])){
+            array_push($where,['website_category.website_id','=',$data['website_id']]);
+        }
+        if(isset($data['name']) && !empty($data['name'])){
+            array_push($where,['website_category.name','like','%'.$data['name'].'%']);
+        }
+        if(isset($data['alias']) && !empty($data['alias'])){
+            array_push($where,['website_category.alias','like','%'.$data['alias'].'%']);
+        }
+        if(isset($data['department_id']) && !empty($data['department_id'])){
+            array_push($where,['category.department_id','=',$data['department_id']]);
+        }
+        if(isset($data['city_id']) && !empty($data['city_id'])){
+            array_push($where,['category.city_id','=',$data['city_id']]);
+        }
+        $result = WebsiteCategory::where($where)
+            ->leftJoin("category",'website_category.category_id','category.id')
+            ->leftJoin("department",'category.department_id','department.id')
+            ->leftJoin("district",'category.city_id','district.id')
+            ->select("website_category.*","department.name as department_name","district.name as city_name")
+            ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])
+            ->get();
+
+        $count = WebsiteCategory::where($where)
+            ->leftJoin("category",'website_category.category_id','category.id')
+            ->leftJoin("department",'category.department_id','department.id')
+            ->leftJoin("district",'category.city_id','district.id')
+            ->count();
+        if (empty($result)) {
+            return Result::error("没有数据",0);
+        }
+        $data = [
+            'rows'=>$result->toArray(),
+            'count'=>$count
+        ];
+        if($result){
+            return Result::success($data);
+        }else{
+            return Result::error("查询失败",0);
+        }
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("查询失败",0);
+        }
+    }
+
+    /**
+     * 递归查询数据
+     * @param $id
+     * @param $ids
+     * @return string
+     */
+    public function getUnderlingUIds($id, $ids='')
+    {
+        $back =  Category::where(['pid'=>$id])->get();
+        $back = $back->toArray();
+        if (!empty($back) && is_array($back)) {
+            foreach ($back as $v) {
+                //防止当前人的ID重复去查询,形成恶性循环
+                if ($v['id'] == $id) {
+                    continue;
+                }
+                $back2 =  Category::where(['pid'=>$id])->count('id');
+                if ($back2 > 0) {
+                    $ids = $this->getUnderlingUIds($v['id'],$ids);
+                } else {
+                    $ids .= ','.$v['id'];
+                }
+            }
+        }
+        $ids = $id.','.$ids.',';
+        $ids = str_replace(',,', ",", $ids);
+        $ids = trim($ids, ',');
+        return $ids;
+    }
+
+    /**
+     * 检测网站名称是否重复
+     * @param array $data
+     * @return array
+     */
+    public function checkWebsiteName(array $data): array
+    {
+        if(isset($data['id'])){
+            $data[] = ['id',"!=",$data['id']];
+            unset($data['id']);
+        }
+        $websiteInfo = Website::query()->where($data)->first();
+        if (empty($websiteInfo)) {
+            return Result::error("找不到网站",0);
+        }
+        return Result::success($websiteInfo->toArray());
+    }
+
+    /**
+     * 检测网站url是否重复
+     * @param array $data
+     * @return array
+     */
+    public function checkWebsiteUrl(array $data): array
+    {
+        $whereData = [];
+        if(isset($data['id'])){
+            $whereData = [['id',"!=",$data['id']]];
+            unset($data['id']);
+        }
+        $websiteInfo = Website::query()->where($whereData)->whereJsonContains('website_url', $data['website_url'])->first();
+        if (empty($websiteInfo)) {
+            return Result::error("找不到URL",0);
+        }
+        return Result::success($websiteInfo->toArray());
+    }
+
 }
 }

+ 12 - 1
app/JsonRpc/WebsiteServiceInterface.php

@@ -33,7 +33,7 @@ interface WebsiteServiceInterface
     public function getWebsiteInfo(int $id): array;
     public function getWebsiteInfo(int $id): array;
 
 
     public function getWebsiteColumn(array $data): array;
     public function getWebsiteColumn(array $data): array;
-    public function getWebsiteColumnList(string $keyword,int $page,int $pageSize): array;
+    public function getWebsiteColumnList(array $data): array;
     public function createWebsiteColumn(array $data): array;
     public function createWebsiteColumn(array $data): array;
     public function updateWebsiteColumn(int $id,array $data): array;
     public function updateWebsiteColumn(int $id,array $data): array;
     public function getWebsiteRoleList(string $keyword,int $page,int $pageSize,int $websiteId): array;
     public function getWebsiteRoleList(string $keyword,int $page,int $pageSize,int $websiteId): array;
@@ -56,5 +56,16 @@ interface WebsiteServiceInterface
     public function addTemplate(array $data): array;
     public function addTemplate(array $data): array;
     public function upTemplate(array $data): array;
     public function upTemplate(array $data): array;
     public function delTemplate(array $data): array;
     public function delTemplate(array $data): array;
+    public function websiteList(array $data): array;
+    public function addWebsiteCategory(array $data): array;
+    public function delWebsiteCategory(array $data): array;
+    public function getAdminWebsiteCategory(array $data): array;
+    public function upWebsiteCategory(array $data): array;
+    public function getWebsiteCategoryList(array $data): array;
+
+    public function delWebsiteAllCategory(array $data): array;
+    public function getWebsiteCategoryOnes(array $data): array;
+    public function upWebsiteCategoryones(array $data): array;
+    public function getWebsiteAllCategory(array $data): array;
 
 
 }
 }

+ 2 - 0
app/Model/Department.php

@@ -40,6 +40,7 @@ use Hyperf\DbConnection\Model\Model;
  * @property int $contents 
  * @property int $contents 
  * @property string $tableid 
  * @property string $tableid 
  * @property int $sort 
  * @property int $sort 
+
  */
  */
 class Department extends Model
 class Department extends Model
 {
 {
@@ -57,4 +58,5 @@ class Department extends Model
      * The attributes that should be cast to native types.
      * The attributes that should be cast to native types.
      */
      */
     protected array $casts = ['id' => 'integer', 'pid' => 'integer', 'fid' => 'integer', 'fup' => 'integer', 'mid' => 'integer', 'class' => 'integer', 'sons' => 'integer', 'type' => 'integer', 'list' => 'integer', 'listorder' => 'integer', 'maxperpage' => 'integer', 'allowcomment' => 'integer', 'forbidshow' => 'integer', 'index_show' => 'integer', 'contents' => 'integer', 'sort' => 'integer'];
     protected array $casts = ['id' => 'integer', 'pid' => 'integer', 'fid' => 'integer', 'fup' => 'integer', 'mid' => 'integer', 'class' => 'integer', 'sons' => 'integer', 'type' => 'integer', 'list' => 'integer', 'listorder' => 'integer', 'maxperpage' => 'integer', 'allowcomment' => 'integer', 'forbidshow' => 'integer', 'index_show' => 'integer', 'contents' => 'integer', 'sort' => 'integer'];
+
 }
 }

+ 28 - 0
app/Model/User.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class User extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'user';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = ["user_name","avatar","status","email","rong_token"];
+    protected array $hidden = [];
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 6 - 1
app/Model/Website.php

@@ -5,7 +5,7 @@ declare(strict_types=1);
 namespace App\Model;
 namespace App\Model;
 
 
 use Hyperf\DbConnection\Model\Model;
 use Hyperf\DbConnection\Model\Model;
-
+use App\Model\WebsiteCategory;
 /**
 /**
  */
  */
 class Website extends Model
 class Website extends Model
@@ -24,4 +24,9 @@ class Website extends Model
      * The attributes that should be cast to native types.
      * The attributes that should be cast to native types.
      */
      */
     protected array $casts = [];
     protected array $casts = [];
+
+    public function websiteCategory()
+    {
+        return $this->hasMany(WebsiteCategory::class,'website_id','id');
+    }
 }
 }

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
runtime/container/classes.cache


Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
runtime/container/scan.cache


+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-65481
+1874

Diferenças do arquivo suprimidas por serem muito extensas
+ 7325 - 0
runtime/logs/hyperf.log


+ 1 - 2
vendor/composer/autoload_classmap.php

@@ -13,8 +13,6 @@ return array(
     'App\\Exception\\Handler\\JsonRpcExceptionHandler' => $baseDir . '/app/Exception/Handler/JsonRpcExceptionHandler.php',
     'App\\Exception\\Handler\\JsonRpcExceptionHandler' => $baseDir . '/app/Exception/Handler/JsonRpcExceptionHandler.php',
     'App\\JsonRpc\\LinkService' => $baseDir . '/app/JsonRpc/LinkService.php',
     'App\\JsonRpc\\LinkService' => $baseDir . '/app/JsonRpc/LinkService.php',
     'App\\JsonRpc\\LinkServiceInterface' => $baseDir . '/app/JsonRpc/LinkServiceInterface.php',
     'App\\JsonRpc\\LinkServiceInterface' => $baseDir . '/app/JsonRpc/LinkServiceInterface.php',
-    'App\\JsonRpc\\NewsService' => $baseDir . '/app/JsonRpc/NewsService.php',
-    'App\\JsonRpc\\NewsServiceInterface' => $baseDir . '/app/JsonRpc/NewsServiceInterface.php',
     'App\\JsonRpc\\PublicRpcService' => $baseDir . '/app/JsonRpc/PublicRpcService.php',
     'App\\JsonRpc\\PublicRpcService' => $baseDir . '/app/JsonRpc/PublicRpcService.php',
     'App\\JsonRpc\\PublicRpcServiceInterface' => $baseDir . '/app/JsonRpc/PublicRpcServiceInterface.php',
     'App\\JsonRpc\\PublicRpcServiceInterface' => $baseDir . '/app/JsonRpc/PublicRpcServiceInterface.php',
     'App\\JsonRpc\\WebsiteService' => $baseDir . '/app/JsonRpc/WebsiteService.php',
     'App\\JsonRpc\\WebsiteService' => $baseDir . '/app/JsonRpc/WebsiteService.php',
@@ -32,6 +30,7 @@ return array(
     'App\\Model\\Model' => $baseDir . '/app/Model/Model.php',
     'App\\Model\\Model' => $baseDir . '/app/Model/Model.php',
     'App\\Model\\Template' => $baseDir . '/app/Model/Template.php',
     'App\\Model\\Template' => $baseDir . '/app/Model/Template.php',
     'App\\Model\\TemplateClass' => $baseDir . '/app/Model/TemplateClass.php',
     'App\\Model\\TemplateClass' => $baseDir . '/app/Model/TemplateClass.php',
+    'App\\Model\\User' => $baseDir . '/app/Model/User.php',
     'App\\Model\\UserLevel' => $baseDir . '/app/Model/UserLevel.php',
     'App\\Model\\UserLevel' => $baseDir . '/app/Model/UserLevel.php',
     'App\\Model\\Website' => $baseDir . '/app/Model/Website.php',
     'App\\Model\\Website' => $baseDir . '/app/Model/Website.php',
     'App\\Model\\WebsiteCategory' => $baseDir . '/app/Model/WebsiteCategory.php',
     'App\\Model\\WebsiteCategory' => $baseDir . '/app/Model/WebsiteCategory.php',

+ 1 - 2
vendor/composer/autoload_static.php

@@ -702,8 +702,6 @@ class ComposerStaticInit88f2a4d4a4e81dc7d415bcdf39930654
         'App\\Exception\\Handler\\JsonRpcExceptionHandler' => __DIR__ . '/../..' . '/app/Exception/Handler/JsonRpcExceptionHandler.php',
         'App\\Exception\\Handler\\JsonRpcExceptionHandler' => __DIR__ . '/../..' . '/app/Exception/Handler/JsonRpcExceptionHandler.php',
         'App\\JsonRpc\\LinkService' => __DIR__ . '/../..' . '/app/JsonRpc/LinkService.php',
         'App\\JsonRpc\\LinkService' => __DIR__ . '/../..' . '/app/JsonRpc/LinkService.php',
         'App\\JsonRpc\\LinkServiceInterface' => __DIR__ . '/../..' . '/app/JsonRpc/LinkServiceInterface.php',
         'App\\JsonRpc\\LinkServiceInterface' => __DIR__ . '/../..' . '/app/JsonRpc/LinkServiceInterface.php',
-        'App\\JsonRpc\\NewsService' => __DIR__ . '/../..' . '/app/JsonRpc/NewsService.php',
-        'App\\JsonRpc\\NewsServiceInterface' => __DIR__ . '/../..' . '/app/JsonRpc/NewsServiceInterface.php',
         'App\\JsonRpc\\PublicRpcService' => __DIR__ . '/../..' . '/app/JsonRpc/PublicRpcService.php',
         'App\\JsonRpc\\PublicRpcService' => __DIR__ . '/../..' . '/app/JsonRpc/PublicRpcService.php',
         'App\\JsonRpc\\PublicRpcServiceInterface' => __DIR__ . '/../..' . '/app/JsonRpc/PublicRpcServiceInterface.php',
         'App\\JsonRpc\\PublicRpcServiceInterface' => __DIR__ . '/../..' . '/app/JsonRpc/PublicRpcServiceInterface.php',
         'App\\JsonRpc\\WebsiteService' => __DIR__ . '/../..' . '/app/JsonRpc/WebsiteService.php',
         'App\\JsonRpc\\WebsiteService' => __DIR__ . '/../..' . '/app/JsonRpc/WebsiteService.php',
@@ -721,6 +719,7 @@ class ComposerStaticInit88f2a4d4a4e81dc7d415bcdf39930654
         'App\\Model\\Model' => __DIR__ . '/../..' . '/app/Model/Model.php',
         'App\\Model\\Model' => __DIR__ . '/../..' . '/app/Model/Model.php',
         'App\\Model\\Template' => __DIR__ . '/../..' . '/app/Model/Template.php',
         'App\\Model\\Template' => __DIR__ . '/../..' . '/app/Model/Template.php',
         'App\\Model\\TemplateClass' => __DIR__ . '/../..' . '/app/Model/TemplateClass.php',
         'App\\Model\\TemplateClass' => __DIR__ . '/../..' . '/app/Model/TemplateClass.php',
+        'App\\Model\\User' => __DIR__ . '/../..' . '/app/Model/User.php',
         'App\\Model\\UserLevel' => __DIR__ . '/../..' . '/app/Model/UserLevel.php',
         'App\\Model\\UserLevel' => __DIR__ . '/../..' . '/app/Model/UserLevel.php',
         'App\\Model\\Website' => __DIR__ . '/../..' . '/app/Model/Website.php',
         'App\\Model\\Website' => __DIR__ . '/../..' . '/app/Model/Website.php',
         'App\\Model\\WebsiteCategory' => __DIR__ . '/../..' . '/app/Model/WebsiteCategory.php',
         'App\\Model\\WebsiteCategory' => __DIR__ . '/../..' . '/app/Model/WebsiteCategory.php',

+ 2 - 2
vendor/composer/installed.php

@@ -3,7 +3,7 @@
         'name' => 'hyperf/hyperf-skeleton',
         'name' => 'hyperf/hyperf-skeleton',
         'pretty_version' => 'dev-master',
         'pretty_version' => 'dev-master',
         'version' => 'dev-master',
         'version' => 'dev-master',
-        'reference' => '9272eb0d9f1d349196e0347d0de7258b37674dc9',
+        'reference' => 'c4c92ee3483e1c5bcad652be05a02e5b2587a966',
         'type' => 'project',
         'type' => 'project',
         'install_path' => __DIR__ . '/../../',
         'install_path' => __DIR__ . '/../../',
         'aliases' => array(),
         'aliases' => array(),
@@ -439,7 +439,7 @@
         'hyperf/hyperf-skeleton' => array(
         'hyperf/hyperf-skeleton' => array(
             'pretty_version' => 'dev-master',
             'pretty_version' => 'dev-master',
             'version' => 'dev-master',
             'version' => 'dev-master',
-            'reference' => '9272eb0d9f1d349196e0347d0de7258b37674dc9',
+            'reference' => 'c4c92ee3483e1c5bcad652be05a02e5b2587a966',
             'type' => 'project',
             'type' => 'project',
             'install_path' => __DIR__ . '/../../',
             'install_path' => __DIR__ . '/../../',
             'aliases' => array(),
             'aliases' => array(),

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff