no message
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\logic\app;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\app\AppVersion;
|
||||
use app\common\service\FileService;
|
||||
|
||||
/**
|
||||
* APP 版本管理逻辑
|
||||
* Class AppVersionLogic
|
||||
* @package app\adminapi\logic\app
|
||||
*/
|
||||
class AppVersionLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 添加版本
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
try {
|
||||
AppVersion::create([
|
||||
'version_name' => $params['version_name'],
|
||||
'version_code' => (int) $params['version_code'],
|
||||
'min_version_code' => (int) ($params['min_version_code'] ?? 0),
|
||||
'platform' => (int) $params['platform'],
|
||||
'package_type' => (int) $params['package_type'],
|
||||
'update_type' => (int) $params['update_type'],
|
||||
'download_url' => FileService::setFileUrl($params['download_url']),
|
||||
'title' => $params['title'],
|
||||
'update_content' => $params['update_content'],
|
||||
'status' => (int) $params['status'],
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑版本
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
try {
|
||||
AppVersion::update([
|
||||
'id' => $params['id'],
|
||||
'version_name' => $params['version_name'],
|
||||
'version_code' => (int) $params['version_code'],
|
||||
'min_version_code' => (int) ($params['min_version_code'] ?? 0),
|
||||
'platform' => (int) $params['platform'],
|
||||
'package_type' => (int) $params['package_type'],
|
||||
'update_type' => (int) $params['update_type'],
|
||||
'download_url' => FileService::setFileUrl($params['download_url']),
|
||||
'title' => $params['title'],
|
||||
'update_content' => $params['update_content'],
|
||||
'status' => (int) $params['status'],
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除版本
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return AppVersion::destroy($params['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本详情
|
||||
*/
|
||||
public static function detail(array $params): array
|
||||
{
|
||||
return AppVersion::findOrEmpty($params['id'])
|
||||
->append(['platform_text', 'package_type_text', 'update_type_text'])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
public static function updateStatus(array $params): bool
|
||||
{
|
||||
try {
|
||||
AppVersion::update([
|
||||
'id' => $params['id'],
|
||||
'status' => (int) $params['status'],
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user