mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
torrent api + swip constants
This commit is contained in:
@@ -10,13 +10,13 @@ class ToolRepository extends BaseRepository
|
||||
public function getSystemInfo(): array
|
||||
{
|
||||
$systemInfo = [
|
||||
'nexus_version' => config('app.nexus_version'),
|
||||
'nexus_version' => VERSION_NUMBER,
|
||||
'nexus_release_date' => RELEASE_DATE,
|
||||
'laravel_version' => \Illuminate\Foundation\Application::VERSION,
|
||||
'php_version' => PHP_VERSION,
|
||||
'mysql_version' => DB::select(DB::raw('select version() as info'))[0]->info,
|
||||
'os' => PHP_OS,
|
||||
'server_software' => $_SERVER['SERVER_SOFTWARE'],
|
||||
|
||||
];
|
||||
|
||||
return $systemInfo;
|
||||
|
||||
127
app/Repositories/TorrentRepository.php
Normal file
127
app/Repositories/TorrentRepository.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\AudioCodec;
|
||||
use App\Models\Category;
|
||||
use App\Models\Codec;
|
||||
use App\Models\Media;
|
||||
use App\Models\Processing;
|
||||
use App\Models\Source;
|
||||
use App\Models\Standard;
|
||||
use App\Models\Team;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TorrentRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* fetch torrent list
|
||||
*
|
||||
* @param array $params
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getList(array $params)
|
||||
{
|
||||
$query = Torrent::query();
|
||||
if (!empty($params['category'])) {
|
||||
$query->where('category', $params['category']);
|
||||
}
|
||||
if (!empty($params['source'])) {
|
||||
$query->where('source', $params['source']);
|
||||
}
|
||||
if (!empty($params['medium'])) {
|
||||
$query->where('medium', $params['medium']);
|
||||
}
|
||||
if (!empty($params['codec'])) {
|
||||
$query->where('codec', $params['codec']);
|
||||
}
|
||||
if (!empty($params['audio_codec'])) {
|
||||
$query->where('audiocodec', $params['audio_codec']);
|
||||
}
|
||||
if (!empty($params['standard'])) {
|
||||
$query->where('standard', $params['standard']);
|
||||
}
|
||||
if (!empty($params['processing'])) {
|
||||
$query->where('processing', $params['processing']);
|
||||
}
|
||||
if (!empty($params['team'])) {
|
||||
$query->where('team', $params['team']);
|
||||
}
|
||||
if (!empty($params['owner'])) {
|
||||
$query->where('owner', $params['owner']);
|
||||
}
|
||||
if (!empty($params['visible'])) {
|
||||
$query->where('visible', $params['visible']);
|
||||
}
|
||||
|
||||
if (!empty($params['query'])) {
|
||||
$query->where(function (Builder $query) use ($params) {
|
||||
$query->where('name', 'like', "%{$params['query']}%")
|
||||
->orWhere('small_descr', 'like', "%{$params['query']}%");
|
||||
});
|
||||
}
|
||||
|
||||
list($sortField, $sortType) = $this->getSortFieldAndType($params);
|
||||
$query->orderBy($sortField, $sortType);
|
||||
|
||||
$with = ['user'];
|
||||
$torrents = $query->with($with)->paginate();
|
||||
return $torrents;
|
||||
}
|
||||
|
||||
public function getSearchBox()
|
||||
{
|
||||
$category = Category::query()->orderBy('sort_index')->orderBy('id')->get();
|
||||
$source = Source::query()->orderBy('sort_index')->orderBy('id')->get();
|
||||
$media = Media::query()->orderBy('sort_index')->orderBy('id')->get();
|
||||
$codec = Codec::query()->orderBy('sort_index')->orderBy('id')->get();
|
||||
$standard = Standard::query()->orderBy('sort_index')->orderBy('id')->get();
|
||||
$processing = Processing::query()->orderBy('sort_index')->orderBy('id')->get();
|
||||
$team = Team::query()->orderBy('sort_index')->orderBy('id')->get();
|
||||
$audioCodec = AudioCodec::query()->orderBy('sort_index')->orderBy('id')->get();
|
||||
|
||||
$modalRows = [];
|
||||
$modalRows[] = $categoryFormatted = $this->formatRow('类型', $category, 'category');
|
||||
$modalRows[] = $this->formatRow('媒介', $source, 'source');
|
||||
$modalRows[] = $this->formatRow('媒介', $media, 'medium');
|
||||
$modalRows[] = $this->formatRow('编码', $codec, 'codec');
|
||||
$modalRows[] = $this->formatRow('音频编码', $audioCodec, 'audio_codec');
|
||||
$modalRows[] = $this->formatRow('分辨率', $standard, 'standard');
|
||||
$modalRows[] = $this->formatRow('处理', $processing, 'processing');
|
||||
$modalRows[] = $this->formatRow('制作组', $team, 'team');
|
||||
|
||||
$results = [];
|
||||
$categories = $categoryFormatted['rows'];
|
||||
$categories[0]['active'] = 1;
|
||||
$results['categories'] = $categories;
|
||||
$results['modal_rows'] = $modalRows;
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function formatRow($header, $items, $name)
|
||||
{
|
||||
$result['header'] = $header;
|
||||
$result['rows'][] = [
|
||||
'label' => '全部',
|
||||
'value' => 0,
|
||||
'name' => $name,
|
||||
'active' => 1,
|
||||
];
|
||||
foreach ($items as $value) {
|
||||
$item = [
|
||||
'label' => $value->name,
|
||||
'value' => $value->id,
|
||||
'name' => $name,
|
||||
'active' => 0,
|
||||
];
|
||||
$result['rows'][] = $item;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user