feature/main20240421
郭嘉 7 months ago
parent e0d9d1daf0
commit d81ca839c3
  1. 18
      app/api/controller/Square.php
  2. 2
      app/api/model/Square.php

@ -97,18 +97,21 @@ class Square extends Controller
$model = new squarelikeModel; $model = new squarelikeModel;
$detail = squarelikeModel::detail($id, (String)$useInfo['user_id']); $detail = squarelikeModel::detail($id, (String)$useInfo['user_id']);
$data = $this->postData(); //$data = $this->postData();
$data['merchant_id'] = $this->merchantId;
$data['user_name'] = $useInfo['user_id']; $data1 = [];
$data['real_name'] = $useInfo['nick_name']; $data1['merchant_id'] = $this->merchantId;
$data1['user_name'] = $useInfo['user_id'];
$data1['square_id'] = $id;
$data1['real_name'] = $useInfo['nick_name'];
if (empty($detail)) { if (empty($detail)) {
if ($model->add($data)) { if ($model->add($data1)) {
$this->dynamicLikeNum($id); $this->dynamicLikeNum($id);
return $this->renderSuccess('操作成功'); return $this->renderSuccess('操作成功');
} }
} else { } else {
$data['squarelike_id'] = $detail['squarelike_id']; $data['squarelike_id'] = $detail['squarelike_id'];
if ($detail->delete($data)) { if ($model->delete($data1)) {
$this->dynamicLikeNum($id); $this->dynamicLikeNum($id);
return $this->renderSuccess('操作成功'); return $this->renderSuccess('操作成功');
} }
@ -121,9 +124,8 @@ class Square extends Controller
$count = squarelikeModel::getCount($id); $count = squarelikeModel::getCount($id);
$arr = [ $arr = [
'likeNum' => $count, 'likeNum' => $count,
'square_id' => $id //'square_id' => $id
]; ];
//print_r($arr);
$detail->edit($arr); $detail->edit($arr);
return $this->renderSuccess('操作成功'); return $this->renderSuccess('操作成功');
} }

@ -27,7 +27,7 @@ class Square extends \app\common\model\Square
public function edit(array $data): bool public function edit(array $data): bool
{ {
// 是否删除图片 // 是否删除图片
!isset($data['logo_image_id']) && $data['logo_image_id'] = 0; //!isset($data['logo_image_id']) && $data['logo_image_id'] = 0;
return $this->save($data) !== false; return $this->save($data) !== false;
} }

Loading…
Cancel
Save