2023-09-18 09:11:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\adminapi\logic\systems;
|
|
|
|
|
|
|
|
use app\common\logic\BaseLogic;
|
|
|
|
use app\common\model\systems\System;
|
|
|
|
|
|
|
|
class SystemLogic extends BaseLogic
|
|
|
|
{
|
|
|
|
//新增
|
|
|
|
public static function add(array $params): bool
|
|
|
|
{
|
|
|
|
try{
|
|
|
|
System::create([
|
2023-09-19 09:18:45 +08:00
|
|
|
'app_id' => create_app_id(),
|
|
|
|
'app_key' => create_app_key(),
|
2023-11-22 09:37:21 +08:00
|
|
|
'name' => $params['name'],
|
|
|
|
'url' => $params['url'],
|
|
|
|
'down_url' => $params['down_url'],
|
|
|
|
'icon' => $params['icon'],
|
2023-11-22 09:54:27 +08:00
|
|
|
'sort' => $params['sort'] ?? 9999,
|
2023-11-22 09:37:21 +08:00
|
|
|
'app_version' => $params['app_version'],
|
2023-11-21 11:36:22 +08:00
|
|
|
'register_status' => $params['register_status'],
|
2023-09-19 09:18:45 +08:00
|
|
|
'status' => 0,
|
2023-09-18 09:11:13 +08:00
|
|
|
]);
|
|
|
|
return true;
|
|
|
|
}catch (\Exception $e) {
|
|
|
|
self::setError($e->getMessage());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除
|
|
|
|
public static function delete(array $params): bool
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
System::update([
|
|
|
|
'id' => $params['id'],
|
2023-09-19 09:18:45 +08:00
|
|
|
'status' => 2,
|
2023-09-18 09:11:13 +08:00
|
|
|
'update_time' => time()
|
|
|
|
]);
|
|
|
|
return true;
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
self::setError($e->getMessage());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//修改
|
|
|
|
public static function edit(array $params) : bool
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
System::update([
|
|
|
|
'id' => $params['id'],
|
2023-09-19 09:18:45 +08:00
|
|
|
'name' => $params['name'],
|
|
|
|
'url' => $params['url'],
|
2023-11-22 09:37:21 +08:00
|
|
|
'down_url' => $params['down_url'],
|
|
|
|
'icon' => $params['icon'],
|
2023-11-22 09:54:27 +08:00
|
|
|
'sort' => $params['sort'] ?? 9999,
|
2023-11-22 09:37:21 +08:00
|
|
|
'app_version' => $params['app_version'],
|
2023-11-21 11:36:22 +08:00
|
|
|
'register_status' => $params['register_status'],
|
2023-11-22 09:37:21 +08:00
|
|
|
'status' => $params['status'],
|
2023-09-18 09:11:13 +08:00
|
|
|
'update_time' => time()
|
|
|
|
]);
|
|
|
|
return true;
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
self::setError($e->getMessage());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 查看
|
|
|
|
public static function detail($params) : array
|
|
|
|
{
|
2023-11-22 09:37:21 +08:00
|
|
|
$data = System::field('*')->findOrEmpty($params['id']);
|
2023-09-19 09:18:45 +08:00
|
|
|
$data['status_text'] = $data->status_text;
|
2023-09-18 09:11:13 +08:00
|
|
|
return $data->toArray();
|
|
|
|
}
|
|
|
|
}
|