Files
sbnews/server/app/common/model/app/AppVersion.php
T
2026-06-11 12:15:29 +08:00

63 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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 '';
}
// 已是完整 URLhttp/https)直接返回
if (preg_match('/^https?:\/\//i', $value)) {
return $value;
}
return FileService::getFileUrl($value);
}
}