56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
namespace app\adminapi\logic\platform;
|
|
|
|
|
|
use app\adminapi\validate\platform\PlatformValidate;
|
|
use app\common\model\platform\Platform;
|
|
use app\common\logic\BaseLogic;
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
* Platform逻辑
|
|
* Class PlatformLogic
|
|
* @package app\adminapi\logic
|
|
*/
|
|
class PlatformLogic extends BaseLogic
|
|
{
|
|
|
|
/**
|
|
* @notes 编辑
|
|
* @param array $params
|
|
* @return bool
|
|
* @author likeadmin
|
|
* @date 2023/08/28 13:37
|
|
*/
|
|
public static function saveData(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
$data = Platform::find(1);
|
|
if($data){
|
|
//更新
|
|
$params['id'] = $data['id'];
|
|
$params['update_time'] = time();
|
|
Platform::update($params);
|
|
}else{
|
|
//新增
|
|
$params['create_time'] = time();
|
|
$params['update_time'] = time();
|
|
Platform::create($params);
|
|
}
|
|
Db::commit();
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
Db::rollback();
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static function info() {
|
|
return Platform::findOrEmpty()->toArray();
|
|
}
|
|
} |