作者 lyh

gx

@@ -2,19 +2,25 @@ @@ -2,19 +2,25 @@
2 2
3 namespace App\Models\Blog; 3 namespace App\Models\Blog;
4 4
  5 +use App\Enums\Common\Code;
5 use App\Models\Base; 6 use App\Models\Base;
6 use App\Models\User\User; 7 use App\Models\User\User;
  8 +use App\Services\ProjectServer;
7 9
8 class Blog extends Base 10 class Blog extends Base
9 { 11 {
10 protected $table = 'gl_blog'; 12 protected $table = 'gl_blog';
11 //连接数据库 13 //连接数据库
12 -// protected $connection = 'custom_mysql'; 14 + protected $connection = 'custom_mysql';
13 public function user(){ 15 public function user(){
14 return $this->hasMany(User::class,'operator_id','id'); 16 return $this->hasMany(User::class,'operator_id','id');
15 } 17 }
16 18
17 public static function getNumByProjectId($project_id){ 19 public static function getNumByProjectId($project_id){
  20 + $project = ProjectServer::useProject($project_id);
  21 + if(empty($project)){
  22 + return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
  23 + }
18 return self::where('project_id', $project_id)->where('status', 1)->count(); 24 return self::where('project_id', $project_id)->where('status', 1)->count();
19 } 25 }
20 } 26 }
@@ -2,7 +2,9 @@ @@ -2,7 +2,9 @@
2 2
3 namespace App\Models\News; 3 namespace App\Models\News;
4 4
  5 +use App\Enums\Common\Code;
5 use App\Models\Base; 6 use App\Models\Base;
  7 +use App\Services\ProjectServer;
6 8
7 class News extends Base 9 class News extends Base
8 { 10 {
@@ -11,6 +13,10 @@ class News extends Base @@ -11,6 +13,10 @@ class News extends Base
11 protected $connection = 'custom_mysql'; 13 protected $connection = 'custom_mysql';
12 14
13 public static function getNumByProjectId($project_id){ 15 public static function getNumByProjectId($project_id){
  16 + $project = ProjectServer::useProject($project_id);
  17 + if(empty($project)){
  18 + return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
  19 + }
14 return self::where('project_id', $project_id)->where('status', 1)->count(); 20 return self::where('project_id', $project_id)->where('status', 1)->count();
15 } 21 }
16 } 22 }
@@ -2,10 +2,12 @@ @@ -2,10 +2,12 @@
2 2
3 namespace App\Models\Product; 3 namespace App\Models\Product;
4 4
  5 +use App\Enums\Common\Code;
5 use App\Helper\Arr; 6 use App\Helper\Arr;
6 use App\Models\Base; 7 use App\Models\Base;
7 use App\Models\RouteMap; 8 use App\Models\RouteMap;
8 use App\Services\Facades\Upload; 9 use App\Services\Facades\Upload;
  10 +use App\Services\ProjectServer;
9 use Illuminate\Database\Eloquent\SoftDeletes; 11 use Illuminate\Database\Eloquent\SoftDeletes;
10 12
11 /** 13 /**
@@ -152,6 +154,10 @@ class Product extends Base @@ -152,6 +154,10 @@ class Product extends Base
152 // } 154 // }
153 155
154 public static function getNumByProjectId($project_id){ 156 public static function getNumByProjectId($project_id){
  157 + $project = ProjectServer::useProject($project_id);
  158 + if(empty($project)){
  159 + return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
  160 + }
155 return self::where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); 161 return self::where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
156 } 162 }
157 163