103 lines
2.2 KiB
PHP
103 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\admin\logic;
|
|
|
|
|
|
use app\common\model\ChangeLog;
|
|
use app\common\logic\BaseLogic;
|
|
use support\exception\BusinessException;
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
* ChangeLog逻辑
|
|
* Class ChangeLogLogic
|
|
* @package app\admin\logic
|
|
*/
|
|
class ChangeLogLogic extends BaseLogic
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 添加
|
|
* @param array $params
|
|
* @return bool
|
|
* @author admin
|
|
* @date 2025/01/06 10:03
|
|
*/
|
|
public static function add(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
ChangeLog::create([
|
|
'model' => $params['model'],
|
|
'link_id' => $params['link_id'],
|
|
'nums' => $params['nums'],
|
|
'pm' => $params['pm'],
|
|
'url' => $params['url'],
|
|
'mark' => $params['mark'],
|
|
]);
|
|
|
|
Db::commit();
|
|
return true;
|
|
} catch (\Throwable $e) {
|
|
Db::rollback();
|
|
throw new BusinessException($e->getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 编辑
|
|
* @param array $params
|
|
* @return bool
|
|
* @author admin
|
|
* @date 2025/01/06 10:03
|
|
*/
|
|
public static function edit(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
ChangeLog::where('id', $params['id'])->update([
|
|
'model' => $params['model'],
|
|
'link_id' => $params['link_id'],
|
|
'nums' => $params['nums'],
|
|
'pm' => $params['pm'],
|
|
'url' => $params['url'],
|
|
'mark' => $params['mark'],
|
|
]);
|
|
|
|
Db::commit();
|
|
return true;
|
|
} catch (\Throwable $e) {
|
|
Db::rollback();
|
|
throw new BusinessException($e->getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 删除
|
|
* @param array $params
|
|
* @return bool
|
|
* @author admin
|
|
* @date 2025/01/06 10:03
|
|
*/
|
|
public static function delete(array $params): bool
|
|
{
|
|
return ChangeLog::destroy($params['id']);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取详情
|
|
* @param $params
|
|
* @return array
|
|
* @author admin
|
|
* @date 2025/01/06 10:03
|
|
*/
|
|
public static function detail($params): array
|
|
{
|
|
return ChangeLog::findOrEmpty($params['id'])->toArray();
|
|
}
|
|
} |