mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 11:27:24 +08:00
API add more log
This commit is contained in:
@@ -28,8 +28,11 @@ class TorrentController extends Controller
|
||||
|
||||
public function index(Request $request, string $section = null)
|
||||
{
|
||||
do_log("controller torrent index entry");
|
||||
$result = $this->repository->getList($request, Auth::user(), $section);
|
||||
do_log("controller torrent index getList");
|
||||
$resource = TorrentResource::collection($result);
|
||||
do_log("controller torrent index prepare resource");
|
||||
return $this->success($resource);
|
||||
}
|
||||
|
||||
@@ -55,11 +58,13 @@ class TorrentController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
do_log("controller torrent show entry");
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
$user = Auth::user();
|
||||
$torrent = $this->repository->getDetail($id, $user);
|
||||
do_log("controller torrent show getDetail");
|
||||
$resource = new TorrentResource($torrent);
|
||||
$additional = [];
|
||||
if ($this->hasExtraField('bonus_reward_values')) {
|
||||
@@ -68,6 +73,7 @@ class TorrentController extends Controller
|
||||
$extraSettingsNames = ['torrent.claim_torrent_user_counts_up_limit'];
|
||||
$this->appendExtraSettings($additional, $extraSettingsNames);
|
||||
$resource->additional($additional);
|
||||
do_log("controller torrent show prepare resource");
|
||||
return $this->success($resource);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,9 @@ class TorrentRepository extends BaseRepository
|
||||
if (!$apiQueryBuilder->hasSort() || !$apiQueryBuilder->hasSort('id')) {
|
||||
$query->orderBy("id", "DESC");
|
||||
}
|
||||
do_log("before query torrent list");
|
||||
$torrents = $query->paginate($this->getPerPageFromRequest($request));
|
||||
do_log("after query torrent list");
|
||||
return $this->appendIncludeFields($apiQueryBuilder, $user, $torrents);
|
||||
}
|
||||
|
||||
@@ -175,7 +177,9 @@ class TorrentRepository extends BaseRepository
|
||||
->allowIncludeCounts($allowIncludeCounts)
|
||||
->allowIncludeFields($allowIncludeFields)
|
||||
;
|
||||
do_log("before query torrent detail");
|
||||
$torrent = $apiQueryBuilder->build()->findOrFail($id);
|
||||
do_log("before query torrent detail");
|
||||
$torrentList = $this->appendIncludeFields($apiQueryBuilder, $user, [$torrent]);
|
||||
return $torrentList[0];
|
||||
}
|
||||
@@ -199,6 +203,7 @@ class TorrentRepository extends BaseRepository
|
||||
if ($hasFieldHasRewarded = $apiQueryBuilder->hasIncludeField('has_rewarded')) {
|
||||
$rewardData = $user->reward_torrent_logs()->whereIn('torrentid', $torrentIdArr)->get()->keyBy('torrentid');
|
||||
}
|
||||
do_log("after prepare has data");
|
||||
|
||||
foreach ($torrentList as $torrent) {
|
||||
$id = $torrent->id;
|
||||
@@ -216,7 +221,9 @@ class TorrentRepository extends BaseRepository
|
||||
}
|
||||
|
||||
if ($apiQueryBuilder->hasIncludeField('description') && $apiQueryBuilder->hasInclude('extra')) {
|
||||
do_log("before format_description of torrent: {$torrent->id}");
|
||||
$descriptionArr = format_description($torrent->extra->descr ?? '');
|
||||
do_log("after format_description of torrent: {$torrent->id}");
|
||||
$torrent->description = $descriptionArr;
|
||||
$torrent->images = get_image_from_description($descriptionArr);
|
||||
}
|
||||
@@ -224,6 +231,7 @@ class TorrentRepository extends BaseRepository
|
||||
$torrent->download_url = $this->getDownloadUrl($id, $user);
|
||||
}
|
||||
}
|
||||
do_log("after fill has data");
|
||||
return $torrentList;
|
||||
}
|
||||
|
||||
|
||||
@@ -542,6 +542,7 @@ function nexus_json_encode($data)
|
||||
|
||||
function api(...$args)
|
||||
{
|
||||
do_log("api begin");
|
||||
if (func_num_args() < 3) {
|
||||
//参数少于3个时,默认为错误状态。
|
||||
$ret = -1;
|
||||
@@ -555,6 +556,7 @@ function api(...$args)
|
||||
if ($data instanceof \Illuminate\Http\Resources\Json\JsonResource) {
|
||||
$data = $data->response()->getData(true);
|
||||
}
|
||||
do_log("api after prepare data");
|
||||
// dd($data);
|
||||
$time = (float)number_format(microtime(true) - nexus()->getStartTimestamp(), 3);
|
||||
$count = null;
|
||||
@@ -583,7 +585,7 @@ function api(...$args)
|
||||
$results['recordsTotal'] = $count;
|
||||
$results['recordsFiltered'] = $count;
|
||||
}
|
||||
|
||||
do_log("api end");
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -599,6 +601,7 @@ function success(...$args)
|
||||
$msg = $args[0];
|
||||
$data = $args[1];
|
||||
}
|
||||
do_log("success before api");
|
||||
return api($ret, $msg, $data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user