fix(api): 修复创建文章500错误和更新文章数据覆盖问题

This commit is contained in:
augushong
2026-05-01 16:17:00 +08:00
parent 83a2bd48a2
commit 2f5846225e
2 changed files with 16 additions and 25 deletions

View File

@@ -271,27 +271,6 @@ class Articles extends BaseController
$post_data['content_html'] = $converter->convert($post_data['content'])->getContent();
}
// 提供字段默认值,避免数据库严格模式报错
$default_fields = [
'jump_to_btn_title' => '',
'jump_to_url' => '',
'jump_to_url_status' => 0,
'poster' => '',
'desc' => '',
'author_name' => '',
'hits' => 0,
'is_top' => 0,
'sort' => 0,
'files' => '',
'pictures' => '',
'tpl_name' => '',
];
foreach ($default_fields as $field => $default) {
if (!isset($post_data[$field])) {
$post_data[$field] = $default;
}
}
$model_post->save($post_data);
return json_message([], 0, '更新成功');