dddmo 5 months ago
parent
commit
21da553061

+ 13 - 6
.gitignore

@@ -1,9 +1,16 @@
-/vendor/
+# Build and Release Folders
+bin-debug/
+bin-release/
+[Oo]bj/
+[Bb]in/
 
-public/
-public
-runtime/
-runtime
+# Other files and folders
 
-.env
+# Executables
 
+vendor
+runtime
+.env
+# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
+# should NOT be excluded as they contain compiler settings and other important
+# information for Eclipse / Flash Builder.

+ 36 - 0
README.en.md

@@ -0,0 +1,36 @@
+# news_producer
+
+#### Description
+新闻资讯
+
+#### Software Architecture
+Software architecture description
+
+#### Installation
+
+1.  xxxx
+2.  xxxx
+3.  xxxx
+
+#### Instructions
+
+1.  xxxx
+2.  xxxx
+3.  xxxx
+
+#### Contribution
+
+1.  Fork the repository
+2.  Create Feat_xxx branch
+3.  Commit your code
+4.  Create Pull Request
+
+
+#### Gitee Feature
+
+1.  You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
+2.  Gitee blog [blog.gitee.com](https://blog.gitee.com)
+3.  Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
+4.  The most valuable open source project [GVP](https://gitee.com/gvp)
+5.  The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
+6.  The most popular members  [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

+ 120 - 0
app/JsonRpc/CollectorService.php

@@ -0,0 +1,120 @@
+<?php
+namespace App\JsonRpc;
+
+use App\Model\OldModel\Article as OldArticle;
+use App\Model\Article;
+use App\Model\Web;
+use Hyperf\DbConnection\Db;
+use Hyperf\RpcServer\Annotation\RpcService;
+use App\Tools\Result;
+
+
+#[RpcService(name: "CollectorService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+class CollectorService implements CollectorServiceInterface
+{
+    /**
+     * 添加网站
+     * @param array $data
+     * @return array|mixed
+     */
+    public function addWeb(array $data): array
+    {
+        $where = [
+            'name' => $data['name']
+        ];
+        $isweb = Web::where($where)->first();
+        if(empty($isweb)){
+            date_default_timezone_set('Asia/Shanghai');
+            $time = time();
+            $catetime = date('Y-m-d H:i:s', $time);
+            $data['created_at'] = $catetime;
+            $web = Web::insert($data);
+            
+        }else{
+            return Result::error('此网站已存在,不可重复添加!');
+        }
+        if(empty($web)){
+            return Result::error('添加失败');
+        }
+        return Result::success('添加成功');
+    }
+    /**
+     * 获取并搜索网站
+     * @param array $data
+     * @return array|mixed
+     */
+    public function getWeb(array $data): array
+    {
+        
+        if(isset($data['keyWord'])){
+            $where = [
+                ['name','like','%'.$data['keyWord'].'%']
+            ];
+            $webss = Web::where($where)->first();
+            if(empty($webss)){
+                return Result::error('未查找到相关网站!');
+            }
+        }else{
+            $web = Web::get();
+        }
+        
+        if(empty($web)){
+            return Result::error('您还未添加网站,请先去添加!');
+            
+        }
+        
+        return Result::success($web);
+    }
+    /**
+     * 修改网站
+     * @param array $data
+     * @return array|mixed
+     */
+    public function upWeb(array $data): array
+    {
+        $web = Web::where('id',$data['id'])->first();
+        if(empty($web)){
+            return Result::error('请输入正确的网站id!');
+            
+        }else{
+            $id = Web::where('id',$data['id'])->update($data);
+            if(empty($id)){
+                return Result::error('无法修改!');
+            }
+        }
+        return Result::success($id);
+    }
+    /**
+     * 删除网站
+     * @param array $data
+     * @return array|mixed
+     */
+    public function delWeb(array $data): array
+    {
+        $web = Web::where('id',$data['id'])->first();
+        if(empty($web)){
+            return Result::error('请输入正确的网站id!');
+            
+        }else{
+            $id = Web::where('id',$data['id'])->delete();
+            if(empty($id)){
+                return Result::error('无法删除!');
+            }
+        }
+        return Result::success($id);
+    }
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function sendCrawler(array $data): array
+    {
+        $result =  Article::get();
+        $b = OldArticle::get();
+        $a = [
+            'old'=>$b,
+            'new'=>$result
+        ];
+        return  Result::success($a);
+    }
+}

+ 34 - 0
app/JsonRpc/CollectorServiceInterface.php

@@ -0,0 +1,34 @@
+<?php
+namespace App\JsonRpc;
+interface CollectorServiceInterface
+{
+    
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function addWeb(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function getWeb(array $data):array;
+     /**
+     * @param array $data
+     *  @return array
+    */
+    public function upWeb(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function delWeb(array $data):array;
+     /**
+     * @param array $data
+     * @return array
+     */
+    public function sendCrawler(array $data): array;
+
+}
+
+

+ 0 - 32
app/JsonRpc/CrawlerService.php

@@ -1,32 +0,0 @@
-<?php
-
-namespace App\JsonRpc;
-
-use App\Model\Article;
-use App\Model\OldModel\Article as OLDArticle;
-use Hyperf\RpcServer\Annotation\RpcService;
-use App\Tools\Result;
-
-
-#[RpcService(name: "CrawlerService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
-class CrawlerService implements CrawlerServiceInterface
-{
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function sendCrawler(array $data): array
-    {
-        $result =  Article::get();
-        $b = OLDArticle::get();
-        $a = [
-            'old'=>$b,
-            'new'=>$result
-        ];
-        return  Result::success($a);
-    }
-
-
-
-}

+ 0 - 12
app/JsonRpc/CrawlerServiceInterface.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace App\JsonRpc;
-interface CrawlerServiceInterface
-{
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function sendCrawler(array $data): array;
-
-}

+ 0 - 1
app/Model/Article.php

@@ -24,5 +24,4 @@ class Article extends Model
      * The attributes that should be cast to native types.
      */
     protected array $casts = [];
-
 }

+ 1 - 1
app/Model/OldModel/Article.php

@@ -14,8 +14,8 @@ class Article extends Model
      * The table associated with the model.
      */
     protected ?string $table = 'article';
+    protected ?string $connection = 'secondary';
 
-    protected ?string$connection = 'secondary';
     /**
      * The attributes that are mass assignable.
      */

+ 27 - 0
app/Model/Web.php

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

+ 0 - 1
composer.json

@@ -30,7 +30,6 @@
         "hyperf/logger": "~3.1.0",
         "hyperf/memory": "~3.1.0",
         "hyperf/nacos": "^3.1",
-        "hyperf/paginator": "^3.1",
         "hyperf/process": "~3.1.0",
         "hyperf/redis": "~3.1.0",
         "hyperf/rpc-server": "*",

File diff suppressed because it is too large
+ 185 - 186
composer.lock


+ 3 - 3
config/autoload/databases.php

@@ -15,8 +15,8 @@ return [
     'default' => [
         'driver' => env('DB_DRIVER2', 'mysql'),
         'host' => env('DB_HOST2', 'localhost'),
-        'database' => env('DB_DATABASE2', 'collector'),
-        'port' => env('DB_PORT2', 13306),
+        'database' => env('DB_DATABASE2', 'hyperf'),
+        'port' => env('DB_PORT2', 3306),
         'username' => env('DB_USERNAME2', 'root'),
         'password' => env('DB_PASSWORD2', ''),
         'charset' => env('DB_CHARSET2', 'utf8'),
@@ -44,7 +44,7 @@ return [
     'secondary' => [
         'driver' => env('DB_DRIVER', 'mysql'),
         'host' => env('DB_HOST', 'localhost'),
-        'database' => env('DB_DATABASE', 'collector'),
+        'database' => env('DB_DATABASE', 'hyperf'),
         'port' => env('DB_PORT', 3306),
         'username' => env('DB_USERNAME', 'root'),
         'password' => env('DB_PASSWORD', ''),

File diff suppressed because it is too large
+ 0 - 0
runtime/container/classes.cache


File diff suppressed because it is too large
+ 0 - 0
runtime/container/scan.cache


+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-57137
+249

File diff suppressed because it is too large
+ 0 - 7352
runtime/logs/hyperf.log


Some files were not shown because too many files changed in this diff