修改App版本管理
parent
8e75b26beb
commit
5daa6cba72
|
|
@ -31,7 +31,8 @@ class AppVersionController extends AdminController
|
||||||
2=>'success',
|
2=>'success',
|
||||||
]);
|
]);
|
||||||
$grid->column('is_force')->bool();
|
$grid->column('is_force')->bool();
|
||||||
$grid->column('link');
|
$grid->column('apk_link');
|
||||||
|
$grid->column('wgt_link');
|
||||||
$grid->column('created_at')->sortable();
|
$grid->column('created_at')->sortable();
|
||||||
|
|
||||||
//排序
|
//排序
|
||||||
|
|
@ -98,7 +99,8 @@ class AppVersionController extends AdminController
|
||||||
2=>'安卓',
|
2=>'安卓',
|
||||||
]);
|
]);
|
||||||
$form->switch('is_force');
|
$form->switch('is_force');
|
||||||
$form->text('link')->required();
|
$form->text('apk_link')->required();
|
||||||
|
$form->text('wgt_link');
|
||||||
|
|
||||||
$form->display('created_at');
|
$form->display('created_at');
|
||||||
$form->display('updated_at');
|
$form->display('updated_at');
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Endpoint\Api\Http\Controllers;
|
namespace App\Endpoint\Api\Http\Controllers;
|
||||||
|
|
||||||
use App\Endpoint\Api\Http\Resources\AppVersionResource;
|
|
||||||
use App\Exceptions\BizException;
|
use App\Exceptions\BizException;
|
||||||
use App\Models\AppVersion;
|
use App\Models\AppVersion;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -18,12 +17,12 @@ class AppVersionController extends Controller
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$cate = (string) $request->query('cate');
|
$cate = (string) $request->query('cate');
|
||||||
|
$v = (int) $request->query('v');
|
||||||
|
|
||||||
if (empty($cate)) {
|
if (empty($cate)) {
|
||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dd($cate);
|
|
||||||
//只拿最新的版本信息
|
//只拿最新的版本信息
|
||||||
$appVersion = AppVersion::filter($request->all())
|
$appVersion = AppVersion::filter($request->all())
|
||||||
->orderBy('v', 'desc')->orderBy('created_at', 'desc')->first();
|
->orderBy('v', 'desc')->orderBy('created_at', 'desc')->first();
|
||||||
|
|
@ -31,6 +30,30 @@ class AppVersionController extends Controller
|
||||||
throw (new BizException('信息未找到'))->status(404);
|
throw (new BizException('信息未找到'))->status(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AppVersionResource::make($appVersion);
|
//如果未传版本号,或者版本号为0,则返回最新的apk地址;
|
||||||
|
if (empty($v)) {
|
||||||
|
$res = [
|
||||||
|
'link' => (string) $appVersion->apk_link,
|
||||||
|
];
|
||||||
|
} elseif ($appVersion->v > ($v+1)) {//如果版本号差异大于1,则强制更新APK
|
||||||
|
$res = [
|
||||||
|
'title'=>$appVersion->title,
|
||||||
|
'context'=>$appVersion->context,
|
||||||
|
'name' => (string) $appVersion->name,
|
||||||
|
'v' => (int) $appVersion->v,
|
||||||
|
'is_force' => true,
|
||||||
|
'link' => (string) $appVersion->apk_link,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$res = [
|
||||||
|
'title'=>$appVersion->title,
|
||||||
|
'context'=>$appVersion->context,
|
||||||
|
'name' => (string) $appVersion->name,
|
||||||
|
'v' => (int) $appVersion->v,
|
||||||
|
'is_force' => (bool) $appVersion->is_force,
|
||||||
|
'link' => (string) $appVersion->wgt_link ?? $appVersion->apk_link,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ class AppVersionResource extends JsonResource
|
||||||
'name' => (string) $this->name,
|
'name' => (string) $this->name,
|
||||||
'v' => (int) $this->v,
|
'v' => (int) $this->v,
|
||||||
'is_force' => (bool) $this->is_force,
|
'is_force' => (bool) $this->is_force,
|
||||||
'link' => (string) $this->link,
|
'apk_link' => (string) $this->apk_link,
|
||||||
|
'wgt_link' => (string) $this->wgt_link,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ class CreateAppVersionsTable extends Migration
|
||||||
$table->unsignedBigInteger('v')->comment('版本号');
|
$table->unsignedBigInteger('v')->comment('版本号');
|
||||||
$table->unsignedTinyInteger('cate')->comment('类别:1ios,2android');
|
$table->unsignedTinyInteger('cate')->comment('类别:1ios,2android');
|
||||||
$table->unsignedTinyInteger('is_force')->default(0)->comment('是否强制更新');
|
$table->unsignedTinyInteger('is_force')->default(0)->comment('是否强制更新');
|
||||||
$table->text('link')->comment('资源链接');
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddLinkToAppVersionsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('app_versions', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->string('apk_link')->comment('资源链接');
|
||||||
|
$table->string('wgt_link')->nullable()->comment('热更新增量包链接');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('app_versions', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->dropColumn(['apk_link', 'wgt_link']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,8 @@ return [
|
||||||
'v' => '版本号',
|
'v' => '版本号',
|
||||||
'cate' => '平台',
|
'cate' => '平台',
|
||||||
'is_force' => '强制更新',
|
'is_force' => '强制更新',
|
||||||
'link' => '资源链接',
|
'apk_link' => '全量包',
|
||||||
|
'wgt_link' => '增量包',
|
||||||
],
|
],
|
||||||
'options' => [
|
'options' => [
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue