feat: allow editing community post content
This commit is contained in:
@@ -50,6 +50,27 @@ class CommunityPostLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
public static function editContent(array $params): bool
|
||||
{
|
||||
$post = CommunityPost::findOrEmpty($params['id']);
|
||||
if ($post->isEmpty()) {
|
||||
self::setError('帖子不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$post->content = (string) $params['content'];
|
||||
$post->save();
|
||||
if ((int) $post->status === 1) {
|
||||
KbSyncService::enqueue('post', 'post', (int) $post->id, 'upsert', 30);
|
||||
}
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setTop(array $params): bool
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user