data_center/app/adminapi/logic/systems/SystemLogic.php

81 lines
2.3 KiB
PHP

<?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([
'app_id' => $params['app_id'],
'app_key' => $params['app_key'],
'name' => $params['name'],
'url' => $params['url'],
'down_url' => $params['down_url'],
'icon' => $params['icon'],
'sort' => $params['sort'] ?? 9999,
'app_version' => $params['app_version'],
'register_status' => $params['register_status'],
'status' => 0,
]);
return true;
}catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
//删除
public static function delete(array $params): bool
{
try {
System::update([
'id' => $params['id'],
'status' => 2,
'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'],
'app_id' => $params['app_id'],
'app_key' => $params['app_key'],
'name' => $params['name'],
'url' => $params['url'],
'down_url' => $params['down_url'],
'icon' => $params['icon'],
'sort' => $params['sort'] ?? 9999,
'app_version' => $params['app_version'],
'register_status' => $params['register_status'],
'status' => $params['status'],
'update_time' => time()
]);
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
// 查看
public static function detail($params) : array
{
$data = System::field('*')->findOrEmpty($params['id']);
$data['status_text'] = $data->status_text;
return $data->toArray();
}
}