69 lines
1.7 KiB
PHP
69 lines
1.7 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([
|
|
'name' => $params['name'],
|
|
'url' => $params['url'],
|
|
'app_id' => create_app_id(),
|
|
'app_key' => create_app_key(),
|
|
'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'],
|
|
'name' => $params['name'],
|
|
'url' => $params['url'],
|
|
'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('id,name,app_id,app_key,url,status,create_time')->findOrEmpty($params['id']);
|
|
$data['status_text'] = $data->status_text;
|
|
return $data->toArray();
|
|
}
|
|
} |