浏览代码

master的news

the_bug 4 月之前
父节点
当前提交
84617e6b43

+ 0 - 92
app/JsonRpc/NewsService.php

@@ -156,7 +156,6 @@ class NewsService implements NewsServiceInterface
         }
         if(isset($data['status']) && $data['status']!==""){
             array_push($where,['article.status','=',$data['status']]);
-
         }
         
         $rep = Article::where($where)
@@ -279,95 +278,4 @@ class NewsService implements NewsServiceInterface
             return Result::error("查询失败",0);
         }
     }
-    /**
-     *  获取新闻
-     * @param array $data
-     * @return array
-    */
-    public function getWebsiteArticlett(array $data): array   
-    {
-    
-       $category = WebsiteCategory::where('website_id',$data['website_id'])->select('category_id')->get();
-       $category = $category->toArray();
-       $result= [];
-       if($category){
-            $category_ids = [];
-            foreach($category as $val){
-                array_push($category_ids,$val['category_id']);
-            }
-            if(isset($data['placeid'])){
-                $placeid=$data['placeid']-1;
-                $result=Article::where('status',1)->where('level',$data['level'])->whereIn("catid",$category_ids)->orderBy("created_at","desc")->offset($placeid)->limit($data['pageSize'])->get();
-            }else{
-                $result=Article::where('status',1)->where('level',$data['level'])->whereIn("catid",$category_ids)->orderBy("created_at","desc")->offset(0)->limit($data['pageSize'])->get();
-            }
-            if(empty($result)){
-                return Result::error("暂无头条新闻",0);
-            }            
-            return Result::success($result); 
-        }else{
-            return Result::error("本网站下暂无相关栏目",0);
-        }
-    }
-    /**
-     * 获取模块新闻
-     * @param array $data
-     * @return array
-    */
-   
-    public function getWebsiteModelArticles(array $data): array    
-    {
-        $catid=$data['catid'];
-        $category = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$catid)->select('category_id')->get();
-        $category = $category->toArray();
-        if(!empty($category)){
-            $where=[
-                'status' => 1,
-                'catid' => $catid
-            ];
-            if($data['level']==1){
-                $level=[
-                    0=>'1',
-                    1=>'4',
-                    2=>'5'
-                ];
-                $result = Article::where($where)->whereIn('level',$level)->orderBy("created_at","desc")->limit($data['pagesize'])->get();
-            }elseif($data['level']==2){
-                $level='2';
-                $result = Article::where($where)->where('level',$level)->orderBy("created_at","desc")->limit($data['pagesize'])->get();
-
-            }else{
-                $level='3';
-                $result = Article::where($where)->where('level',$level)->orderBy("created_at","desc")->limit($data['pagesize'])->get();
-            }
-            $result= $result->toArray();
-            if(!empty($result) && isset($data['placeid']) && !empty($data['placeid'])){
-                $placeid=$data['placeid']-1;
-                if($level==2 || $level==3){
-                    $where =[
-                        'level' => $level
-                    ];
-                    $result = Article::where($where)
-                    ->orderBy("created_at","desc")
-                    ->offset($placeid)
-                    ->limit($data['pagesize'])->get();
-                }else{
-                    $result = Article::where($where)
-                    ->whereIn('level',$level)
-                    ->offset($placeid)
-                    ->orderBy("created_at","desc")
-                    ->limit($data['pagesize'])->get();
-                } 
-            }
-            if(empty($result)){
-                return Result::error("此栏目暂无相关新闻",0);
-            }
-        }else{
-            return Result::error("此网站暂无此栏目",0);
-        
-        }
-        return Result::success($result);  
-        
-    }
-    
 }

+ 27 - 0
app/Model/ArticleData.php

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

+ 27 - 0
app/Model/Category.php

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

+ 27 - 0
app/Model/Link.php

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

+ 19 - 0
app/Model/Model.php

@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://hyperf.wiki
+ * @contact  group@hyperf.io
+ * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
+ */
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model as BaseModel;
+
+abstract class Model extends BaseModel
+{
+}

+ 27 - 0
app/Model/Website.php

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

+ 27 - 0
app/Model/WebsiteColumn.php

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

+ 27 - 0
app/Model/WebsiteRole.php

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

+ 27 - 0
app/Model/WebsiteRoleUser.php

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

+ 0 - 29
config/autoload/databases.php

@@ -13,35 +13,6 @@ use function Hyperf\Support\env;
 
 return [
     'default' => [
-        'driver' => env('DB_DRIVER2', 'mysql'),
-        'host' => env('DB_HOST2', 'localhost'),
-        'database' => env('DB_DATABASE2', 'hyperf'),
-        'port' => env('DB_PORT2', 3306),
-        'username' => env('DB_USERNAME2', 'root'),
-        'password' => env('DB_PASSWORD2', ''),
-        'charset' => env('DB_CHARSET2', 'utf8'),
-        'collation' => env('DB_COLLATION2', 'utf8_unicode_ci'),
-        'prefix' => env('DB_PREFIX2', ''),
-        'pool' => [
-            'min_connections' => 1,
-            'max_connections' => 10,
-            'connect_timeout' => 10.0,
-            'wait_timeout' => 3.0,
-            'heartbeat' => -1,
-            'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
-        ],
-        'variables' => [
-            'time_zone' => '+08:00', // 设置MySQL连接的时区
-        ],
-        'commands' => [
-            'gen:model' => [
-                'path' => 'app/Model',
-                'force_casts' => true,
-                'inheritance' => 'Model',
-            ],
-        ],
-    ],
-    'secondary' => [
         'driver' => env('DB_DRIVER', 'mysql'),
         'host' => env('DB_HOST', 'localhost'),
         'database' => env('DB_DATABASE', 'hyperf'),

+ 1 - 1
config/autoload/server.php

@@ -20,7 +20,7 @@ return [
             'name' => 'jsonrpc-http',
             'type' => Server::SERVER_HTTP,
             'host' => '0.0.0.0',
-            'port' => 9505,
+            'port' => 9505, 
             'sock_type' => SWOOLE_SOCK_TCP,
             'callbacks' => [
                 Event::ON_REQUEST => [Hyperf\JsonRpc\HttpServer::class, 'onRequest'],