mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-07-01 21:22:47 +08:00
feat(post-output): add save-only and load-history endpoints
This commit is contained in:
@@ -436,6 +436,59 @@ class Post extends Common
|
||||
return json(['code' => 0, 'msg' => '保存成功', 'data' => ['output_id' => $output->id]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅保存配置(不生成图片)
|
||||
*/
|
||||
public function savePostOutputConfig()
|
||||
{
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
if (empty($data['post_id'])) {
|
||||
return json(['code' => 500, 'msg' => '缺少文章ID']);
|
||||
}
|
||||
|
||||
try {
|
||||
$config = $data['config'] ?? [];
|
||||
if (isset($data['content_html']) && !isset($config['content_html'])) {
|
||||
$config['content_html'] = $data['content_html'];
|
||||
}
|
||||
|
||||
$admin_id = session('admin_id') ?? 0;
|
||||
$output = \app\common\tools\PhoneImage::saveConfigOnly((int) $data['post_id'], $config, (int) $admin_id);
|
||||
|
||||
return json(['code' => 0, 'msg' => '', 'data' => ['output_id' => $output->id]]);
|
||||
} catch (\Exception $e) {
|
||||
return json(['code' => 500, 'msg' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载历史记录配置
|
||||
*/
|
||||
public function loadPostOutputConfig()
|
||||
{
|
||||
$id = $this->request->param('id', 0);
|
||||
if (empty($id)) {
|
||||
return json(['code' => 500, 'msg' => '缺少ID']);
|
||||
}
|
||||
|
||||
$output = \app\model\PostOutput::find((int) $id);
|
||||
if (empty($output)) {
|
||||
return json(['code' => 500, 'msg' => '记录不存在']);
|
||||
}
|
||||
|
||||
$config = (array) $output->config;
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
'data' => [
|
||||
'config' => $config,
|
||||
'content_html' => $config['content_html'] ?? '',
|
||||
'output_id' => $output->id,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除输出记录
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user