first commit

This commit is contained in:
root
2025-06-18 10:31:43 +08:00
commit d9f820b55d
981 changed files with 449311 additions and 0 deletions

37
app/Model/AppAdminMenu.php Executable file
View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $id
* @property string $title
* @property string $icon
* @property string $key
* @property int $pid
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $href
* @property int $type
* @property int $weight
*/
class AppAdminMenu extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_admin_menus';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'pid' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'type' => 'integer', 'weight' => 'integer'];
}

125
app/Model/AppArticle.php Executable file
View File

@ -0,0 +1,125 @@
<?php
declare(strict_types=1);
namespace App\Model;
use App\Enums\ArticleModuleEnum;
use App\Enums\ArticlePublishedStatusEnum;
use App\Enums\LocationEnum;
use App\Helpers\TitleHelper;
use Hyperf\Database\Model\Events\Saving;
/**
* @property int $id
* @property string $aid
* @property string $title
* @property string $description
* @property string $cover
* @property int $year
* @property int $deleted_at
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $created_by
* @property int $updated_by
* @property int $spider_article_id
* @property int $style
* @property int $location
* @property int $images_count
* @property int $published_at
* @property mixed $images
* @property mixed $module
* @property mixed $brand
* @property mixed $brand_name
* @property mixed $published_status
*/
class AppArticle extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_articles';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'brand' => 'integer', 'year' => 'integer', 'module' => 'integer', 'deleted_at' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'created_by' => 'integer', 'updated_by' => 'integer', 'spider_article_id' => 'integer', 'style' => 'integer', 'location' => 'integer', 'images_count' => 'integer', 'published_status' => 'integer', 'published_at' => 'integer'];
protected ?string $dateFormat = 'U';
// public function saving(Saving $event)
// {
// if ($this->getAttribute('images_count') == 0) {
// $this->setAttribute('images_count', count(json_decode($this->getAttribute('images'), true)));
// }
// }
public function setImagesAttribute($value)
{
if (is_string($value)) {
$imagesValue = json_decode($value, true);
$this->setAttribute('images_count', count($imagesValue));
} elseif (is_array($value)) {
$this->setAttribute('images_count', count($value));
$value = json_encode(array_values($value));
}
$this->attributes['images'] = $value;
}
public function getImagesAttribute($value)
{
return $this->format('images', function (bool $isFormat) use ($value) {
return $isFormat ? json_decode($value, true) : $value;
});
}
public function getModuleAttribute($value)
{
return $this->format('module', function (bool $isFormat) use ($value) {
return $isFormat ? ArticleModuleEnum::from($value)->toString() : $value;
});
}
public function getLocationAttribute($value)
{
return $this->format('location', function (bool $isFormat) use ($value) {
return $isFormat ? LocationEnum::from($value)->toString() : $value;
});
}
public function getBrandAttribute($value)
{
return $this->format('brand', function (bool $isFormat) use ($value) {
return $isFormat ? AppBrand::find($value)?->name : $value;
});
}
public function getBrandNameAttribute($value)
{
return $this->format('brand_name', function (bool $isFormat) use ($value) {
return $isFormat ? AppBrand::find($value)?->name : $value;
});
}
public function getPublishedStatusAttribute($value)
{
return $this->format('published_status', function (bool $isFormat) use ($value) {
return $isFormat ? ArticlePublishedStatusEnum::from($value)->toString() : $value;
});
}
public function getTranslateTitleAttribute($value)
{
return $this->format('translate_title', function (bool $isFormat) use ($value) {
return $isFormat ? TitleHelper::translate($value) : $value;
});
}
}

41
app/Model/AppBrand.php Executable file
View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $id
* @property string $name
* @property string $cn_name
* @property string $first_letter
* @property string $logo
* @property string $description
* @property int $is_del
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $created_by
* @property int $updated_by
* @property string $spider_origin
*/
class AppBrand extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_brands';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'is_del' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'created_by' => 'integer', 'updated_by' => 'integer'];
protected ?string $dateFormat = 'U';
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $id
* @property string $keyword
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $deleted_at
* @property int $is_delete
* @property int $queried_at
* @property int $platform
*/
class AppKeywordsMonitor extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_keywords_monitor';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'integer', 'is_delete' => 'integer', 'queried_at' => 'integer', 'platform' => 'integer'];
function getQueriedAtAttribute($value): string
{
if (!$value) {
return '未查询';
}
return date('Y-m-d H:i:s', intval($value)) ?: '未查询';
}
}

View File

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $id
* @property int $aid
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $deleted_at
* @property int $is_delete
* @property int $queried_at
* @property string $title
* @property string $description
* @property string $platform
* @property string $url
* @property string $order
* @property string $ip_address
* @property string $ip_source
* @property string $screen_path
*/
class AppKeywordsMonitorResult extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_keywords_monitor_result';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'aid' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'integer', 'is_delete' => 'integer', 'queried_at' => 'integer'];
}

View File

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $id
* @property string $keyword
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $deleted_at
* @property int $is_delete
* @property int $queried_at
* @property int $platform
* @property int $aid
*/
class AppKeywordsMonitorTask extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_keywords_monitor_task';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'integer', 'is_delete' => 'integer', 'queried_at' => 'integer', 'platform' => 'integer', 'aid' => 'integer'];
}

48
app/Model/AppNews.php Normal file
View File

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $id
* @property string $title
* @property string $keywords
* @property string $content
* @property string $description
* @property \Carbon\Carbon $created_at
* @property int $created_by
* @property \Carbon\Carbon $updated_at
* @property int $updated_by
* @property int $deleted_at
* @property int $deleted_by
* @property int $platform
* @property int $is_record
* @property string $cover
*/
class AppNews extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_news';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'created_by' => 'integer', 'updated_at' => 'datetime', 'updated_by' => 'integer', 'deleted_at' => 'integer', 'deleted_by' => 'integer', 'platform' => 'integer', 'is_record' => 'integer'];
protected ?string $dateFormat = 'U';
public function getCreatedAtAttribute($value)
{
return date('Y-m-d H:i:s', intval($value));
}
}

84
app/Model/AppSpiderArticle.php Executable file
View File

@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace App\Model;
use App\Enums\ArticleModuleEnum;
use App\Enums\ArticlePublishedStatusEnum;
use App\Enums\SpiderArticlePublishedStatusEnum;
use Carbon\Carbon;
use Hyperf\Database\Model\Builder;
/**
* @property int $id
* @property string $title
* @property string $description
* @property string $cover
* @property int $brand
* @property int $year
* @property int $deleted_at
* @property Carbon $updated_at
* @property string $platform
* @property string $source_url
* @property int $published_status
* @property int $published_at
* @property mixed $created_at
* @property mixed $module
* @property mixed $images
*/
class AppSpiderArticle extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_spider_articles';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'brand' => 'integer', 'year' => 'integer', 'module' => 'integer', 'deleted_at' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'published_status' => 'integer', 'published_at' => 'integer'];
public function getCreatedAtAttribute($value): false|string
{
return $this->format('created_at', function (bool $isFormat) use ($value) {
return $isFormat ? date('Y-m-d H:i:s', intval($value)) : $value;
});
}
public function getModuleAttribute($value)
{
return $this->format('module', function (bool $isFormat) use ($value) {
return $isFormat ? ArticleModuleEnum::from($value)->toString() : $value;
});
}
public function getImagesAttribute($value)
{
return $this->format('images', function (bool $isFormat) use ($value) {
return $isFormat ? json_decode($value, true) : $value;
});
}
public function getBrandAttribute($value)
{
return $this->format('brand', function (bool $isFormat) use ($value) {
return $isFormat ? AppBrand::find($value)?->name : $value;
});
}
public function getPublishedStatusAttribute($value)
{
return $this->format('published_status', function (bool $isFormat) use ($value) {
return $isFormat ? SpiderArticlePublishedStatusEnum::from($value)->toString() : $value;
});
}
}

37
app/Model/AppUser.php Executable file
View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $id
* @property string $name
* @property string $unique_id
* @property string $avatar
* @property string $email
* @property string $email_verified_at
* @property string $password
* @property string $remember_token
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
class AppUser extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'app_users';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
}

46
app/Model/Model.php Executable file
View File

@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace App\Model;
use Hyperf\Context\Context;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model as BaseModel;
use Hyperf\ModelCache\Cacheable;
use Hyperf\ModelCache\CacheableInterface;
abstract class Model extends BaseModel implements CacheableInterface
{
use Cacheable;
protected ?string $dateFormat = 'U';
const ENABLED_FORMATTER = __CLASS__ . 'ENABLED_FORMATTER';
public static function formatQuery(array $formatFields = []): Builder
{
Context::set(self::ENABLED_FORMATTER, $formatFields);
return (new static())->newQuery();
}
public static function query(): Builder
{
Context::set(self::ENABLED_FORMATTER, []);
return (new static())->newQuery();
}
protected function format(string $keyName, \Closure $callable)
{
$formatFields = Context::get(self::ENABLED_FORMATTER);
return $callable(in_array($keyName, $formatFields ?: []));
}
}