Эх сурвалжийг харах

修改接口:修改调研选题列表;新增接口:添加官网导航的接口;

FengR 13 цаг өмнө
parent
commit
b9b1c3aabf

+ 7 - 1
app/JsonRpc/NewsService.php

@@ -9465,7 +9465,7 @@ class NewsService implements NewsServiceInterface
     ])
     ->leftJoin('user', 'user.id', '=', 'research_topic.user_id')
     ->select('research_topic.id','research_topic.title','research_topic.updated_at','research_topic.status',
-    'research_topic.due_time','user.nickname')
+    'research_topic.due_time','user.nickname','research_topic.column_id','research_topic.user_id')
     ->orderBy('research_topic.updated_at', 'desc')
     ->paginate($data['page_size'], ['*'], 'page', $data['page']);
     if(empty($research_topic->items())){
@@ -9482,6 +9482,12 @@ class NewsService implements NewsServiceInterface
         }else{
           $result['rows'][$key]['is_update'] = 0;
         }
+      }else{
+        if($value['user_id'] == $data['user_id']){
+          $result['rows'][$key]['is_update'] = 1;
+        }else{
+          $result['rows'][$key]['is_update'] = 0;
+        }
       }
       if(!empty($value['retopicUsers'])){
         $retopic_users = $value['retopicUsers'];

+ 55 - 1
app/JsonRpc/WebsiteService.php

@@ -59,7 +59,9 @@ use Hyperf\Utils\Parallel;
 use Hyperf\Coroutine\Concurrent;
 use function Hyperf\Coroutine\batch;
 use Swoole\Coroutine;
-
+use Fukuball\Jieba\Jieba;
+use Fukuball\Jieba\Finalseg;
+use App\Model\WebCateinfo;
 #[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class WebsiteService implements WebsiteServiceInterface
 {
@@ -3474,4 +3476,56 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($result);
     }
+    /**
+     * 添加网站导航
+     * @param array $data
+     */
+    public function addWebCateinfo(array $data): array
+    {
+        $user = User::where('id', $data['user_id'])->first();
+        if (empty($user)) {
+            return Result::error('用户不存在');
+        }
+        if($user['type_id'] == 10000){
+            $data['status'] = 1;
+        }else{
+            $data['status'] = 0;
+        }
+        if ($data['keyword'] == '') {
+            //提取标题+内容中的关键词
+            $data['keyword'] = $data['title'];
+            //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
+            Jieba::init(); // 初始化 jieba-php
+            Finalseg::init();
+            $segList = Jieba::cut($data['keyword']);
+            $segList1 = array_slice($segList, 0, 8);
+            $data['keyword'] = implode(',', $segList1);
+        }
+        if ($data['description'] == '') {
+            //提取内容中的描述
+            $content = $data['content'];
+            // 去除 <style> 和 <script> 标签及其内容
+            $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+            // 去除所有 HTML 标签
+            $content = strip_tags($content);
+            // 去除 HTML 实体
+            $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+            // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+            $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+            // 去除多余空白
+            $content = preg_replace('/\s+/u', '', $content);
+            // 截取 100 个字符
+            $data['description'] = mb_substr($content, 0, 100);
+        }
+        $data['cate_name'] = empty($data['cate_name']) ? '官网导航' : $data['cate_name'];
+        $data['province_id'] = empty($data['province_id']) ? null : $data['province_id'];
+        $data['city_id'] = empty($data['city_id']) ? null : $data['city_id'];
+        $data['county_id'] = empty($data['county_id']) ? null : $data['county_id'];
+        unset($data['users_id']);
+        $result = WebCateinfo::insertGetId($data);
+        if (empty($result)) {
+            return Result::error('添加失败');
+        }
+        return Result::success($result);
+    }
 }

+ 5 - 0
app/JsonRpc/WebsiteServiceInterface.php

@@ -173,4 +173,9 @@ interface WebsiteServiceInterface
      * @return array
      */
     public function getWebsiteFootAll(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addWebCateinfo(array $data): array;
 }

+ 27 - 0
app/Model/WebCateinfo.php

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