Commit b3ec1b80 authored by rlgy's avatar rlgy

app版本更新

parent 9633479d
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-22
* Time: 下午2:48
*/
namespace api\controllers;
use api\base\BaseController;
use common\models\pwallet\AppVersion;
class AppController extends BaseController
{
public function actionUpdate()
{
$type = \Yii::$app->request->post('type');
$data = AppVersion::getLastStable($type);
if ($data) {
$data['log'] = json_decode($data['log']);
}
return $data;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-22
* Time: 下午1:59
*/
namespace common\models\pwallet;
use Yii;
use common\core\BaseActiveRecord;
class AppVersion extends BaseActiveRecord
{
/**
* @return null|object|\yii\db\Connection
* @throws \yii\base\InvalidConfigException
*/
public static function getDb()
{
return Yii::$app->get('db_pwallet');
}
/**
* 获取最新的稳定版app
*
* @param int $type android(1) IOS(3)
* @return array
*/
public static function getLastStable($type = 1)
{
$query = <<<EOF
select
id,
status,
version,
download_url,
`log`
from app_version
where type = :type AND version = (SELECT MAX(version)
from app_version
where type = :type);
EOF;
try {
return self::getDb()->createCommand($query)->bindValue(':type', $type)->queryOne();
} catch (\Exception $exception) {
return [];
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment