|
@@ -1,5 +1,7 @@
|
|
<?php
|
|
<?php
|
|
|
|
+
|
|
namespace App\Repositories\Behavior;
|
|
namespace App\Repositories\Behavior;
|
|
|
|
+
|
|
use App\Models\Behavior;
|
|
use App\Models\Behavior;
|
|
use App\Models\BehaviorOperationLog;
|
|
use App\Models\BehaviorOperationLog;
|
|
use App\Models\CommentRecord;
|
|
use App\Models\CommentRecord;
|
|
@@ -23,7 +25,6 @@ use Illuminate\Database\QueryException;
|
|
* Date: 2019/6/10
|
|
* Date: 2019/6/10
|
|
* Time: 上午11:11
|
|
* Time: 上午11:11
|
|
*/
|
|
*/
|
|
-
|
|
|
|
class BehaviorRepository
|
|
class BehaviorRepository
|
|
{
|
|
{
|
|
public function __construct(Behavior $behavior, BehaviorOperationLog $behaviorOperationLog,
|
|
public function __construct(Behavior $behavior, BehaviorOperationLog $behaviorOperationLog,
|
|
@@ -38,7 +39,7 @@ class BehaviorRepository
|
|
$this->releaseRecord = $releaseRecord;
|
|
$this->releaseRecord = $releaseRecord;
|
|
//初始化virus域名
|
|
//初始化virus域名
|
|
$this->client = new Client([
|
|
$this->client = new Client([
|
|
- 'base_uri' => config('customer.VIRUS_URL'),
|
|
|
|
|
|
+ //'base_uri' => config('customer.VIRUS_URL'),
|
|
'timeout' => 3
|
|
'timeout' => 3
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
@@ -53,7 +54,7 @@ class BehaviorRepository
|
|
$signKey = urldecode(http_build_query($signKey));
|
|
$signKey = urldecode(http_build_query($signKey));
|
|
$sign = md5(config('customer.VIRUS_APP_SECRET') . $signKey);
|
|
$sign = md5(config('customer.VIRUS_APP_SECRET') . $signKey);
|
|
|
|
|
|
- $response = $this->client->request('GET', '/behaviorList', [
|
|
|
|
|
|
+ $response = $this->client->request('GET', config('customer.VIRUS_URL') . '/behaviorList', [
|
|
'headers' => [
|
|
'headers' => [
|
|
'Content-Type' => 'application/json',
|
|
'Content-Type' => 'application/json',
|
|
'app' => config('customer.VIRUS_APP_ID'),
|
|
'app' => config('customer.VIRUS_APP_ID'),
|
|
@@ -381,28 +382,28 @@ class BehaviorRepository
|
|
{
|
|
{
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
$where = [];
|
|
$where = [];
|
|
- if(isset($request['id'])){
|
|
|
|
- $where[] = ['id',$request['id']];
|
|
|
|
|
|
+ if (isset($request['id'])) {
|
|
|
|
+ $where[] = ['id', $request['id']];
|
|
}
|
|
}
|
|
- if(isset($request['is_open'])){
|
|
|
|
- $where[] = ['is_open',$request['is_open']];
|
|
|
|
|
|
+ if (isset($request['is_open'])) {
|
|
|
|
+ $where[] = ['is_open', $request['is_open']];
|
|
}
|
|
}
|
|
//行为级别唯一/多级筛选
|
|
//行为级别唯一/多级筛选
|
|
- if(isset($request['behavior_level'])){
|
|
|
|
- $where[] = ['behavior_level',$request['behavior_level']];
|
|
|
|
|
|
+ if (isset($request['behavior_level'])) {
|
|
|
|
+ $where[] = ['behavior_level', $request['behavior_level']];
|
|
}
|
|
}
|
|
- if(isset($request['name'])){
|
|
|
|
|
|
+ if (isset($request['name'])) {
|
|
$where[] = ['name', 'like', "%{$request['name']}%"];
|
|
$where[] = ['name', 'like', "%{$request['name']}%"];
|
|
}
|
|
}
|
|
|
|
|
|
$sort = 'desc';
|
|
$sort = 'desc';
|
|
$filed = 'id';
|
|
$filed = 'id';
|
|
- if(isset($request['search']) && isset($request['sort'])){
|
|
|
|
- $filed = $this->check_search($request['search']);
|
|
|
|
- $sort = $request['sort'] == 0 ? 'desc' : 'asc';
|
|
|
|
|
|
+ if (isset($request['search']) && isset($request['sort'])) {
|
|
|
|
+ $filed = $this->check_search($request['search']);
|
|
|
|
+ $sort = $request['sort'] == 0 ? 'desc' : 'asc';
|
|
}
|
|
}
|
|
|
|
|
|
- return $this->behavior->where($where)->orderBy($filed,$sort)->paginate($perPage);
|
|
|
|
|
|
+ return $this->behavior->where($where)->orderBy($filed, $sort)->paginate($perPage);
|
|
}
|
|
}
|
|
|
|
|
|
private function check_search($search)
|
|
private function check_search($search)
|