52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\api\controller;
|
||
|
|
|
||
|
|
use think\Controller;
|
||
|
|
|
||
|
|
class Version extends controller
|
||
|
|
{
|
||
|
|
/*
|
||
|
|
* 获取app版本信息
|
||
|
|
* @param string $version 版本号
|
||
|
|
* @return id 版本id
|
||
|
|
* @return string $url 下载地址
|
||
|
|
* @return string $content 更新内容
|
||
|
|
* @return int $is_force 是否强制更新 1 是 0 否
|
||
|
|
* @return string $apiversion api版本号
|
||
|
|
* @return string $code 状态码
|
||
|
|
* @author:
|
||
|
|
* @date: 2025 5/5/14
|
||
|
|
*/
|
||
|
|
//初始化
|
||
|
|
protected function initialize()
|
||
|
|
{
|
||
|
|
//允许跨域
|
||
|
|
header('Access-Control-Allow-Origin: *');
|
||
|
|
}
|
||
|
|
//获取app版本信息
|
||
|
|
public function get_app_version()
|
||
|
|
{
|
||
|
|
$system = input('system', '');
|
||
|
|
if ($system == 'iOS') {
|
||
|
|
$type = 2;
|
||
|
|
}else{
|
||
|
|
$type = 1;
|
||
|
|
}
|
||
|
|
$reslut = model('Version')->where(['type' => $type, 'status' => 1])->order('id', 'desc')->find();
|
||
|
|
if (!$reslut) {
|
||
|
|
return V(0,'操作失败');
|
||
|
|
}
|
||
|
|
$data = [
|
||
|
|
'id' => $reslut['id'],
|
||
|
|
'version' => $reslut['newversion'],//新版本号
|
||
|
|
'url' => $reslut['downloadurl'],
|
||
|
|
'content' => $reslut['content'],
|
||
|
|
'is_force' => $reslut['enforce'],
|
||
|
|
'apiversion' => $reslut['apiversion'],
|
||
|
|
'code' => $reslut['code']
|
||
|
|
];
|
||
|
|
return V(1,'操作成功', $data);
|
||
|
|
}
|
||
|
|
}
|