feat(ota): 新增OTA远程升级功能
- 创建OTA版本管理表结构,支持版本名称、构建号、APK文件等信息存储 - 实现后台OTA版本管理界面,包含新增、编辑、删除和发布功能 - 开发API接口用于设备版本检查和更新包下载 - 实现版本发布逻辑,自动归档旧版本并计算APK文件哈希值 - 添加强制更新、目标设备白名单和最低版本限制功能 - 集成文件上传和选择组件,支持APK文件管理 - 实现版本状态管理(草稿、已发布、已归档)和权限控制
This commit is contained in:
66
application/admin/model/ota/Version.php
Normal file
66
application/admin/model/ota/Version.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\ota;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* OTA 版本管理模型
|
||||
*
|
||||
* 支持草稿、发布、归档三种状态流转。
|
||||
*/
|
||||
class Version extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'ota_version';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'is_force_update_text',
|
||||
'status_text'
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取状态列表
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['draft' => __('Draft'), 'published' => __('Published'), 'archived' => __('Archived')];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态文本
|
||||
*
|
||||
* @param string $value
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['status'] ?? '');
|
||||
$list = $this->getStatusList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取强制更新状态文本
|
||||
*
|
||||
* @param string $value
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function getIsForceUpdateTextAttr($value, $data)
|
||||
{
|
||||
return ($data['is_force_update'] ?? 0) == 1 ? '是' : '否';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user