From 54ac69e11a34b7da16ff4209c98faa84d160cd03 Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Thu, 20 Jan 2022 21:20:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=85=BC=E5=AE=B9=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/Api/V1/EmoticonController.php | 11 ++++++----- app/Model/{ => Emoticon}/Emoticon.php | 4 +++- app/Model/{ => Emoticon}/EmoticonItem.php | 4 +++- app/Model/{ => Emoticon}/UsersEmoticon.php | 4 +++- app/Model/Robot.php | 3 ++- app/Model/Talk/TalkRecordsVoteAnswer.php | 3 +-- app/Model/Talk/TalkSession.php | 1 - app/Service/EmoticonService.php | 4 ++-- 8 files changed, 20 insertions(+), 14 deletions(-) rename app/Model/{ => Emoticon}/Emoticon.php (92%) rename app/Model/{ => Emoticon}/EmoticonItem.php (94%) rename app/Model/{ => Emoticon}/UsersEmoticon.php (92%) diff --git a/app/Controller/Api/V1/EmoticonController.php b/app/Controller/Api/V1/EmoticonController.php index 7e63b70..110bd3d 100644 --- a/app/Controller/Api/V1/EmoticonController.php +++ b/app/Controller/Api/V1/EmoticonController.php @@ -8,8 +8,8 @@ use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\HttpServer\Annotation\Middleware; use App\Middleware\JWTAuthMiddleware; use App\Constants\ResponseCode; -use App\Model\Emoticon; -use App\Model\EmoticonItem; +use App\Model\Emoticon\Emoticon; +use App\Model\Emoticon\EmoticonItem; use App\Service\EmoticonService; use League\Flysystem\Filesystem; use Psr\Http\Message\ResponseInterface; @@ -189,12 +189,13 @@ class EmoticonController extends CController public function delCollectEmoticon(): ResponseInterface { $params = $this->request->inputs(['ids']); + $this->validate($params, [ 'ids' => 'required|ids' ]); - return $this->emoticonService->deleteCollect($this->uid(), parse_ids($params['ids'])) ? - $this->response->success([]) : - $this->response->fail(); + $isTrue = $this->emoticonService->deleteCollect($this->uid(), parse_ids($params['ids'])); + + return $isTrue ? $this->response->success() : $this->response->fail(); } } diff --git a/app/Model/Emoticon.php b/app/Model/Emoticon/Emoticon.php similarity index 92% rename from app/Model/Emoticon.php rename to app/Model/Emoticon/Emoticon.php index 6458ad0..eeead54 100644 --- a/app/Model/Emoticon.php +++ b/app/Model/Emoticon/Emoticon.php @@ -2,7 +2,9 @@ declare (strict_types=1); -namespace App\Model; +namespace App\Model\Emoticon; + +use App\Model\BaseModel; /** * 表情包分组数据表模型 diff --git a/app/Model/EmoticonItem.php b/app/Model/Emoticon/EmoticonItem.php similarity index 94% rename from app/Model/EmoticonItem.php rename to app/Model/Emoticon/EmoticonItem.php index 8d4accf..709e570 100644 --- a/app/Model/EmoticonItem.php +++ b/app/Model/Emoticon/EmoticonItem.php @@ -2,7 +2,9 @@ declare (strict_types=1); -namespace App\Model; +namespace App\Model\Emoticon; + +use App\Model\BaseModel; /** * 表情包数据表模型 diff --git a/app/Model/UsersEmoticon.php b/app/Model/Emoticon/UsersEmoticon.php similarity index 92% rename from app/Model/UsersEmoticon.php rename to app/Model/Emoticon/UsersEmoticon.php index b12559b..76fa5c8 100644 --- a/app/Model/UsersEmoticon.php +++ b/app/Model/Emoticon/UsersEmoticon.php @@ -2,7 +2,9 @@ declare (strict_types=1); -namespace App\Model; +namespace App\Model\Emoticon; + +use App\Model\BaseModel; /** * 表情包收藏数据表模型 diff --git a/app/Model/Robot.php b/app/Model/Robot.php index 91df2f9..76d102b 100644 --- a/app/Model/Robot.php +++ b/app/Model/Robot.php @@ -19,11 +19,12 @@ use Hyperf\DbConnection\Model\Model; * @property int $type 机器人类型 * @property string $created_at 创建时间 * @property string $updated_at 更新时间 + * * @package App\Model */ class Robot extends Model { - protected $table = 'robots'; + protected $table = 'robot'; protected $fillable = [ 'user_id', diff --git a/app/Model/Talk/TalkRecordsVoteAnswer.php b/app/Model/Talk/TalkRecordsVoteAnswer.php index 9377c8e..5991b70 100644 --- a/app/Model/Talk/TalkRecordsVoteAnswer.php +++ b/app/Model/Talk/TalkRecordsVoteAnswer.php @@ -5,7 +5,6 @@ namespace App\Model\Talk; use App\Model\BaseModel; - /** * Class TalkRecordsVoteAnswer * @@ -30,6 +29,6 @@ class TalkRecordsVoteAnswer extends BaseModel protected $casts = [ 'vote_id' => 'integer', 'user_id' => 'integer', - 'created_at' => 'integer', + 'created_at' => 'datetime', ]; } diff --git a/app/Model/Talk/TalkSession.php b/app/Model/Talk/TalkSession.php index f075f55..ec7e658 100644 --- a/app/Model/Talk/TalkSession.php +++ b/app/Model/Talk/TalkSession.php @@ -41,7 +41,6 @@ class TalkSession extends BaseModel ]; protected $casts = [ - 'id' => 'integer', 'talk_type' => 'integer', 'user_id' => 'integer', 'receiver_id' => 'integer', diff --git a/app/Service/EmoticonService.php b/app/Service/EmoticonService.php index 2a9f929..e973e92 100644 --- a/app/Service/EmoticonService.php +++ b/app/Service/EmoticonService.php @@ -7,8 +7,8 @@ use App\Constants\TalkMessageType; use App\Constants\TalkModeConstant; use App\Model\Talk\TalkRecords; use App\Model\Talk\TalkRecordsFile; -use App\Model\EmoticonItem; -use App\Model\UsersEmoticon; +use App\Model\Emoticon\EmoticonItem; +use App\Model\Emoticon\UsersEmoticon; use App\Service\Group\GroupMemberService; /**