refactor: 规范部分API接口响应格式

This commit is contained in:
xboard
2023-12-10 17:53:31 +08:00
parent 7bca6e1953
commit e04d82961f
11 changed files with 188 additions and 42 deletions
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ComissionLogResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
"id"=> $this['id'],
"order_amount" => $this['order_amount'],
"trade_no" => $this['trade_no'],
"get_amount" => $this['get_amount'],
"created_at" => $this['created_at']
];
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class InviteCodeResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$data = [
"user_id" => $this['user_id'],
"code" => $this['code'],
"pv" => $this['pv'],
"status" => $this['status'],
"created_at" => $this['created_at'],
"updated_at" => $this['updated_at']
];
if(!config('hidden_features.enable_exposed_user_count_fix')) $data['user_id']= $this['user_id'];
return $data;
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class NodeResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this['id'],
'name' => $this['name'],
'rate' => $this['rate'],
'tags' => $this['tags'],
'is_online' => $this['is_online']
];
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class TicketResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$data = [
"id" => $this['id'],
"level" => $this['level'],
"reply_status" => $this['reply_status'],
"status" => $this['status'],
"subject" => $this['subject'],
"created_at" => $this['created_at'],
"updated_at" => $this['updated_at']
];
if(!config('hidden_features.enable_exposed_user_count_fix')) $data['user_id']= $this['user_id'];
return $data;
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class TrafficLogResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$data = [
"d" => $this['d'],
"u" => $this['u'],
"record_at" => $this['record_at'],
"server_rate" => $this['server_rate'],
];
if(!config('hidden_features.enable_exposed_user_count_fix')) $data['user_id']= $this['user_id'];
return $data;
}
}