63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
||
|
||
namespace app\common\model\app;
|
||
|
||
use app\common\model\BaseModel;
|
||
use app\common\service\FileService;
|
||
use think\model\concern\SoftDelete;
|
||
|
||
/**
|
||
* APP 版本管理模型
|
||
* Class AppVersion
|
||
* @package app\common\model\app
|
||
*/
|
||
class AppVersion extends BaseModel
|
||
{
|
||
use SoftDelete;
|
||
|
||
protected $name = 'app_version';
|
||
protected $deleteTime = 'delete_time';
|
||
|
||
/**
|
||
* 平台名称
|
||
*/
|
||
public function getPlatformTextAttr($value, $data): string
|
||
{
|
||
$map = [1 => 'Android', 2 => 'iOS'];
|
||
return $map[$data['platform']] ?? '';
|
||
}
|
||
|
||
/**
|
||
* 包类型名称
|
||
*/
|
||
public function getPackageTypeTextAttr($value, $data): string
|
||
{
|
||
$map = [1 => 'wgt热更', 2 => 'apk整包', 3 => 'ipa/AppStore'];
|
||
return $map[$data['package_type']] ?? '';
|
||
}
|
||
|
||
/**
|
||
* 升级类型名称
|
||
*/
|
||
public function getUpdateTypeTextAttr($value, $data): string
|
||
{
|
||
$map = [1 => '普通升级', 2 => '强制升级', 3 => '静默升级'];
|
||
return $map[$data['update_type']] ?? '';
|
||
}
|
||
|
||
/**
|
||
* 完整下载链接
|
||
*/
|
||
public function getDownloadUrlAttr($value): string
|
||
{
|
||
if (empty($value)) {
|
||
return '';
|
||
}
|
||
// 已是完整 URL(http/https)直接返回
|
||
if (preg_match('/^https?:\/\//i', $value)) {
|
||
return $value;
|
||
}
|
||
return FileService::getFileUrl($value);
|
||
}
|
||
}
|