文章
This commit is contained in:
@@ -34,6 +34,7 @@ class ArticleService extends BaseService
|
||||
'fields' => ['id', 'locale', 'title', 'subtitle', 'cover', 'content', 'user_id', 'is_top', 'sort', 'status', 'publish_time', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'creater' => ['id', 'nickname',],
|
||||
'comment' => ['id', 'article_id', 'content', 'avatar', 'name',],
|
||||
// 'translation' => ['model_id', 'name'],
|
||||
// 'brand.translation' => ['brand_id', 'name']
|
||||
],
|
||||
@@ -56,6 +57,7 @@ class ArticleService extends BaseService
|
||||
],
|
||||
'fields' => ['id', 'locale', 'title', 'subtitle', 'cover', 'content', 'user_id', 'is_top', 'sort', 'status', 'publish_time', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'comment' => ['id', 'article_id', 'content', 'avatar', 'name',],
|
||||
// 'translation' => ['model_id', 'name']
|
||||
],
|
||||
];
|
||||
@@ -71,6 +73,8 @@ class ArticleService extends BaseService
|
||||
}else{
|
||||
$params['publish_time'] = time();
|
||||
}
|
||||
$num = $params['num'] ?? 0;
|
||||
unset($params['num']);
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
@@ -79,6 +83,10 @@ class ArticleService extends BaseService
|
||||
throw new BusinessException('提交失败');
|
||||
}
|
||||
|
||||
if($num > 0){
|
||||
CommentService::createComment($info->id,$params['content'],$num);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $th) {
|
||||
@@ -91,6 +99,8 @@ class ArticleService extends BaseService
|
||||
{
|
||||
$params['locale'] = locale();
|
||||
$params['publish_time'] = strtotime($params['publish_time']);
|
||||
$num = $params['num'] ?? 0;
|
||||
unset($params['num']);
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
@@ -99,6 +109,9 @@ class ArticleService extends BaseService
|
||||
throw new BusinessException('提交失败');
|
||||
}
|
||||
|
||||
if($num > 0){
|
||||
CommentService::createComment($id,$params['content'],$num);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
Reference in New Issue
Block a user