From 0b1acccc32a3443259ae756de98546efc813c457 Mon Sep 17 00:00:00 2001 From: guojia <445241500@qq.com> Date: Wed, 8 May 2024 22:49:08 +0800 Subject: [PATCH] trac --- app/api/controller/Square.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/api/controller/Square.php b/app/api/controller/Square.php index 1318aa9d..2b2b11ee 100644 --- a/app/api/controller/Square.php +++ b/app/api/controller/Square.php @@ -35,11 +35,7 @@ class Square extends Controller */ public function add(): Json { - if (!UserService::isStore()) { - throwError("无权限", 403); - } - - $useInfo = UserService::getCurrentLoginUser(true); + $useInfo = UserService::getCurrentLoginUser(true)->toArray(); $content = $this->request->post('content'); if (!$content) { @@ -52,6 +48,8 @@ class Square extends Controller $data = $this->postForm(); $data['merchant_id'] = $this->merchantId; + $data['user_name'] = $useInfo['user_id']; + $data['real_name'] = $useInfo['nick_name']; if ((new squareModel)->add($data)) { return $this->renderSuccess('添加成功'); } @@ -79,13 +77,10 @@ class Square extends Controller public function dynamicLike(int $id): Json { - if (!UserService::isStore()) { - throwError("无权限", 403); - } - $useInfo = UserService::getCurrentLoginUser(true); + $useInfo = UserService::getCurrentLoginUser(true)->toArray(); $model = new squarelikeModel; - $detail = squarelikeModel::detail($id, $useInfo['data']['user_name']); + $detail = squarelikeModel::detail($id, $useInfo['user_name']); $data = $this->postForm(); if (empty($detail)) { if ($model->add($data)) {