帖子修改
This commit is contained in:
@@ -172,10 +172,42 @@ class PostService
|
|||||||
*/
|
*/
|
||||||
public function beforeServiceUpdate($data, Request $request)
|
public function beforeServiceUpdate($data, Request $request)
|
||||||
{
|
{
|
||||||
// $data['user_id'] = $request->user->uid;;
|
if(empty($data['id'])){
|
||||||
// $media = serialize($data['media']);
|
throw new BusinessException('id不能为空');
|
||||||
// redis::set('PostMedia_'.$data['user_id'],$media,30);
|
}
|
||||||
// unset($data['media']);
|
$post = Post::where(['id'=>$data['id']])->first();
|
||||||
|
if($post['user_id'] != $request->user->uid){
|
||||||
|
throw new BusinessException('非发布人不允许修改');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['user_id'] = $request->user->uid;;
|
||||||
|
if(empty($data['sku_id'])){
|
||||||
|
throw new BusinessException('未选择关联产品');
|
||||||
|
}
|
||||||
|
$user = User::where('id', $data['user_id'])->first();
|
||||||
|
if(empty($user->latitude) || empty($user->longitude) || empty($user->mobile)){
|
||||||
|
throw new BusinessException('请补全个人中心的门店位置及电话');
|
||||||
|
}
|
||||||
|
if(empty($user->is_release)){
|
||||||
|
$UserOld = UserOld::where('mobile', $user->mobile)->first();
|
||||||
|
if(!empty($UserOld)){
|
||||||
|
$user->is_release = 1;
|
||||||
|
$user->save();
|
||||||
|
}else{
|
||||||
|
throw new BusinessException('请联系管理员申请发布权限');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['latitude'] = $user->latitude;
|
||||||
|
$data['longitude'] = $user->longitude;
|
||||||
|
$data['location_name'] = $user->location_name;
|
||||||
|
$data['shop_name'] = $user->shop_name;
|
||||||
|
$media = serialize($data['media']);
|
||||||
|
redis::set('PostMedia_U_'.$data['user_id'],$media,30);
|
||||||
|
unset($data['media']);
|
||||||
|
|
||||||
|
$sku = Sku::where('id',$data['sku_id'])->first();
|
||||||
|
$data['category_id'] = $sku->category_id;
|
||||||
|
$data['model'] = $sku->model;
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@@ -185,16 +217,19 @@ class PostService
|
|||||||
*/
|
*/
|
||||||
public function afterServiceUpdate($res)
|
public function afterServiceUpdate($res)
|
||||||
{
|
{
|
||||||
// PostMedia::where('post_id', $res->id)->delete();
|
$media = redis::get('PostMedia_U_'.$res['user_id']);
|
||||||
// $media = redis::get('PostMedia_'.$res['user_id']);
|
$media = unserialize($media);
|
||||||
// $media = unserialize($media);
|
if(!is_array($media)){
|
||||||
// foreach ($media as $v) {
|
$media = explode(',',$media);
|
||||||
// PostMedia::create([
|
}
|
||||||
// 'post_id' => $res->id,
|
PostMedia::where('post_id',$res['id'])->delete();
|
||||||
// 'media_type' => $this->getMediaTypeByUrl($v['url']),
|
foreach ($media as $v) {
|
||||||
// 'url' => $v['url'],
|
PostMedia::create([
|
||||||
// ]);
|
'post_id' => $res['id'],
|
||||||
// }
|
'media_type' => $this->getMediaTypeByUrl($v),
|
||||||
|
'url' => $v,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ Route::group('/common', function () {
|
|||||||
Route::any('/show', [app\common\controller\PostController::class, 'show']);
|
Route::any('/show', [app\common\controller\PostController::class, 'show']);
|
||||||
Route::any('/interaction', [app\common\controller\PostController::class, 'interaction']);
|
Route::any('/interaction', [app\common\controller\PostController::class, 'interaction']);
|
||||||
Route::any('/store', [app\common\controller\PostController::class, 'store']);
|
Route::any('/store', [app\common\controller\PostController::class, 'store']);
|
||||||
|
Route::any('/update', [app\common\controller\PostController::class, 'update']);
|
||||||
|
|
||||||
// 评论
|
// 评论
|
||||||
Route::group('/comment', function () {
|
Route::group('/comment', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user