feat(ota): 新增OTA远程升级功能

- 创建OTA版本管理表结构,支持版本名称、构建号、APK文件等信息存储
- 实现后台OTA版本管理界面,包含新增、编辑、删除和发布功能
- 开发API接口用于设备版本检查和更新包下载
- 实现版本发布逻辑,自动归档旧版本并计算APK文件哈希值
- 添加强制更新、目标设备白名单和最低版本限制功能
- 集成文件上传和选择组件,支持APK文件管理
- 实现版本状态管理(草稿、已发布、已归档)和权限控制
This commit is contained in:
2026-04-09 17:51:34 +08:00
parent ab27bb6bf6
commit 1e22f5b452
11 changed files with 731 additions and 0 deletions

View 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 ? '是' : '否';
}
}