Skip to content

Commit

Permalink
Merge pull request #203 from Qsnh/dev
Browse files Browse the repository at this point in the history
v4.5.4
  • Loading branch information
Qsnh authored Dec 19, 2021
2 parents 50265e9 + c3cd569 commit 11eaa33
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 7 deletions.
10 changes: 10 additions & 0 deletions app/Http/Controllers/Api/V3/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
namespace App\Http\Controllers\Api\V3;

use Illuminate\Http\Request;
use App\Services\Base\Services\ConfigService;
use App\Http\Controllers\Api\V2\BaseController;
use App\Services\Course\Services\CourseService;
use App\Services\Other\Proxies\SearchRecordService;
use App\Services\Base\Interfaces\ConfigServiceInterface;
use App\Services\Other\Interfaces\SearchRecordServiceInterface;

class SearchController extends BaseController
Expand Down Expand Up @@ -53,6 +55,14 @@ public function index(Request $request)
return $this->error(__('请输入关键字'));
}

/**
* @var ConfigService $configService
*/
$configService = app()->make(ConfigServiceInterface::class);
if (!$configService->enabledFullSearch()) {
return $this->error(__('搜索服务未配置'));
}

/**
* @var SearchRecordService $searchService
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Meedu/MeEdu.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

class MeEdu
{
const VERSION = 'v4.5.3';
const VERSION = 'v4.5.4';
}
27 changes: 27 additions & 0 deletions app/Meedu/Search/VideoSearchNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@

namespace App\Meedu\Search;

use App\Services\Base\Services\ConfigService;
use App\Services\Other\Proxies\SearchRecordService;
use App\Services\Base\Interfaces\ConfigServiceInterface;
use App\Services\Other\Interfaces\SearchRecordServiceInterface;

class VideoSearchNotify implements SearchNotifyContract
{
public const RESOURCE_TYPE = 'video';

public function closed()
{
/**
* @var ConfigService $configService
*/
$configService = app()->make(ConfigServiceInterface::class);
return $configService->enabledFullSearch() === false;
}

public function create(int $resourceId, array $data)
{
if ($this->closed()) {
return;
}

/**
* @var SearchRecordService $searchRecordService
*/
Expand All @@ -32,6 +47,10 @@ public function create(int $resourceId, array $data)

public function update(int $resourceId, array $data)
{
if ($this->closed()) {
return;
}

/**
* @var SearchRecordService $searchRecordService
*/
Expand All @@ -47,6 +66,10 @@ public function update(int $resourceId, array $data)

public function delete(int $resourceId)
{
if ($this->closed()) {
return;
}

/**
* @var SearchRecordService $searchRecordService
*/
Expand All @@ -56,6 +79,10 @@ public function delete(int $resourceId)

public function deleteBatch(array $ids)
{
if ($this->closed()) {
return;
}

/**
* @var SearchRecordService $searchRecordService
*/
Expand Down
27 changes: 27 additions & 0 deletions app/Meedu/Search/VodSearchNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@

namespace App\Meedu\Search;

use App\Services\Base\Services\ConfigService;
use App\Services\Other\Proxies\SearchRecordService;
use App\Services\Base\Interfaces\ConfigServiceInterface;
use App\Services\Other\Interfaces\SearchRecordServiceInterface;

class VodSearchNotify implements SearchNotifyContract
{
public const RESOURCE_TYPE = 'vod';

public function closed()
{
/**
* @var ConfigService $configService
*/
$configService = app()->make(ConfigServiceInterface::class);
return $configService->enabledFullSearch() === false;
}

public function create(int $resourceId, array $data)
{
if ($this->closed()) {
return;
}

/**
* @var SearchRecordService $searchRecordService
*/
Expand All @@ -32,6 +47,10 @@ public function create(int $resourceId, array $data)

public function update(int $resourceId, array $data)
{
if ($this->closed()) {
return;
}

/**
* @var SearchRecordService $searchRecordService
*/
Expand All @@ -47,6 +66,10 @@ public function update(int $resourceId, array $data)

public function delete(int $resourceId)
{
if ($this->closed()) {
return;
}

/**
* @var SearchRecordService $searchRecordService
*/
Expand All @@ -56,6 +79,10 @@ public function delete(int $resourceId)

public function deleteBatch(array $ids)
{
if ($this->closed()) {
return;
}

/**
* @var SearchRecordService $searchRecordService
*/
Expand Down
2 changes: 2 additions & 0 deletions app/Meedu/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Meedu\UpgradeLog\UpgradeToV4;
use App\Meedu\UpgradeLog\UpgradeToV42;
use App\Meedu\UpgradeLog\UpgradeToV45;
use App\Meedu\UpgradeLog\UpgradeToV454;

class Upgrade
{
Expand All @@ -19,5 +20,6 @@ public function run()
UpgradeToV4::handle();
UpgradeToV42::handle();
UpgradeToV45::handle();
UpgradeToV454::handle();
}
}
51 changes: 51 additions & 0 deletions app/Meedu/UpgradeLog/UpgradeToV454.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) 杭州白书科技有限公司
*/

namespace App\Meedu\UpgradeLog;

use App\Services\Base\Model\AppConfig;

class UpgradeToV454
{
public static function handle()
{
self::appConfigAppUrlUpdate();
self::appConfigH5UrlUpdate();
self::appConfigPcUrlUpdate();
}

protected static function appConfigAppUrlUpdate()
{
AppConfig::query()
->where('key', 'app.url')
->update([
'name' => 'API访问地址',
'help' => '请填写API访问地址,需携带http://或https://协议',
]);
}

protected static function appConfigPcUrlUpdate()
{
AppConfig::query()
->where('key', 'meedu.system.pc_url')
->update([
'name' => 'PC访问地址',
'help' => '请填写PC界面访问地址,需携带http://或https://协议',
]);
}

protected static function appConfigH5UrlUpdate()
{
AppConfig::query()
->where('key', 'meedu.system.h5_url')
->update([
'name' => 'H5访问地址',
'help' => '请填写H5界面访问地址,需携带http://或https://协议',
]);
}
}
5 changes: 5 additions & 0 deletions app/Services/Base/Services/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,9 @@ public function getH5Url(): string
{
return config('meedu.system.h5_url');
}

public function enabledFullSearch(): bool
{
return (bool)config('scout.meilisearch.host');
}
}
11 changes: 7 additions & 4 deletions database/seeders/AppConfigSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,37 @@ public function run()
'default_value' => 0,
'key' => 'app.debug',
'value' => 0,
'help' => '开启后将可以看到网站报错详细信息',
],
[
'group' => '系统',
'name' => '网站地址',
'name' => 'API访问地址',
'field_type' => 'text',
'sort' => 1,
'default_value' => '',
'key' => 'app.url',
'value' => '',
'help' => '请填写API服务访问地址',
'help' => '请填写API访问地址,需携带http://或https://协议',
],
[
'group' => '系统',
'name' => 'PC网站地址',
'name' => 'PC访问地址',
'field_type' => 'text',
'sort' => 1,
'default_value' => '',
'key' => 'meedu.system.pc_url',
'value' => '',
'help' => '请填写PC界面访问地址,需携带http://或https://协议',
],
[
'group' => '系统',
'name' => 'H5网站地址',
'name' => 'H5访问地址',
'field_type' => 'text',
'sort' => 1,
'default_value' => '',
'key' => 'meedu.system.h5_url',
'value' => '',
'help' => '请填写H5界面访问地址,需携带http://或https://协议',
],
[
'group' => '系统',
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,6 @@
"search.vod": "Vod",
"search.video": "Video",
"订单状态错误": "Order status error",
"已超时,请重新绑定": "Timed out, please rebind"
"已超时,请重新绑定": "Timed out, please rebind",
"搜索服务未配置": "search service not enabled"
}
3 changes: 2 additions & 1 deletion resources/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,6 @@
"search.vod": "录播课程",
"search.video": "录播视频",
"订单状态错误": "订单状态错误",
"已超时,请重新绑定": "已超时,请重新绑定"
"已超时,请重新绑定": "已超时,请重新绑定",
"搜索服务未配置": "搜索服务未配置"
}

0 comments on commit 11eaa33

Please sign in to comment.