perf: 重写项目和会话接口数据

This commit is contained in:
kuaifan
2023-03-08 13:07:21 +08:00
parent 05b169c172
commit cb33b9fc51
12 changed files with 238 additions and 204 deletions

41
app/Module/TimeRange.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
namespace App\Module;
use Carbon\Carbon;
class TimeRange
{
public ?Carbon $updated;
public ?Carbon $deleted;
/**
* @param $data
*/
public function __construct($data)
{
if (is_array($data)) {
$range = Base::explodeInt($data['timerange']);
if ($data['updated_at'] || $data['at_after']) {
$range[0] = $data['updated_at'] ?: $data['at_after'];
}
if ($data['deleted_at']) {
$range[1] = $data['deleted_at'];
}
} else {
$range = Base::explodeInt($data);
}
//
$this->updated = $range[0] ? Carbon::parse($range[0]) : null;
$this->deleted = $range[1] ? Carbon::parse($range[1]) : null;
}
/**
* @param $data
* @return TimeRange
*/
public static function parse($data): TimeRange
{
return new self($data);
}
}