69 lines
1.9 KiB
PHP
69 lines
1.9 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([
|
||
|
'system_name' => $params['system_name'],
|
||
|
'system_url' => $params['system_url'],
|
||
|
'system_appid' => create_appid(),
|
||
|
'system_appkey' => create_appkey(),
|
||
|
'system_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'],
|
||
|
'system_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'],
|
||
|
'system_name' => $params['system_name'],
|
||
|
'system_url' => $params['system_url'],
|
||
|
'system_status' => $params['system_status'],
|
||
|
'update_time' => time()
|
||
|
]);
|
||
|
return true;
|
||
|
} catch (\Exception $e) {
|
||
|
self::setError($e->getMessage());
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 查看
|
||
|
public static function detail($params) : array
|
||
|
{
|
||
|
$data = System::field('id,system_name,system_appid,system_appkey,system_url,system_status,system_type,create_time')->findOrEmpty($params['id']);
|
||
|
$data['system_status_text'] = $data->system_status_text;
|
||
|
return $data->toArray();
|
||
|
}
|
||
|
}
|