From 08fb8b339747302d31919d4d9382c6f53586e2ce Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Mon, 29 Jun 2020 19:51:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=9B=9E=E5=A4=8D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/wechat/controller/Reply.php | 36 ++++++++++++++ .../20200628031742_wechat_reply.php | 48 ++++++++++++++++++ catch/wechat/model/WechatReply.php | 49 +++++++++++++++++++ .../repository/WechatReplyRepository.php | 24 +++++++++ catch/wechat/route.php | 4 ++ 5 files changed, 161 insertions(+) create mode 100644 catch/wechat/database/migrations/20200628031742_wechat_reply.php create mode 100644 catch/wechat/model/WechatReply.php diff --git a/catch/wechat/controller/Reply.php b/catch/wechat/controller/Reply.php index ef90e0a..a73f2a2 100644 --- a/catch/wechat/controller/Reply.php +++ b/catch/wechat/controller/Reply.php @@ -8,3 +8,39 @@ // +---------------------------------------------------------------------- // | Author: JaguarJack [ njphper@gmail.com ] // +---------------------------------------------------------------------- +namespace catchAdmin\wechat\controller; + +use catchAdmin\wechat\repository\WechatReplyRepository; +use catcher\base\CatchController; +use catcher\base\CatchRequest; +use catcher\CatchResponse; + +class Reply extends CatchController +{ + protected $reply; + + public function __construct(WechatReplyRepository $reply) + { + $this->reply = $reply; + } + + public function index(CatchRequest $request) + { + return CatchResponse::paginate($this->reply->getList()); + } + + public function save(CatchRequest $request) + { + return CatchResponse::success($this->reply->storeBy($request->param())); + } + + public function update($id, CatchRequest $request) + { + return CatchResponse::success($this->reply->updateBy($id, $request->param())); + } + + public function delete($id) + { + return CatchResponse::success($this->reply->deleteBy($id)); + } +} \ No newline at end of file diff --git a/catch/wechat/database/migrations/20200628031742_wechat_reply.php b/catch/wechat/database/migrations/20200628031742_wechat_reply.php new file mode 100644 index 0000000..27653bb --- /dev/null +++ b/catch/wechat/database/migrations/20200628031742_wechat_reply.php @@ -0,0 +1,48 @@ +table('wechat_reply', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信回复' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]); + $table->addColumn('keyword', 'string', ['limit' => 255, 'default' => '', 'comment' => '关键字',]) + ->addColumn('media_id', 'string', ['default' => '', 'limit' => 100,'signed' => true,'comment' => '微信资源ID']) + ->addColumn('media_url', 'string', ['default' => '', 'limit' => 255,'signed' => true,'comment' => '本地资源 URL']) + ->addColumn('image_url', 'string', ['default' => '', 'limit' => 255,'signed' => true,'comment' => '本地图片 URL']) + ->addColumn('title', 'string', ['limit' => '255', 'default' => '', 'comment' => '标题']) + ->addColumn('content', 'string', ['limit' => 1000, 'comment' => '内容', 'default' => '',]) + ->addColumn('type', 'integer', ['limit' => MysqlAdapter::INT_TINY,'null' => false,'default' => 1,'signed' => true,'comment' => '1文字 2图文 3图片 4音乐 5视频 6语音 7转客服',]) + ->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY,'default' => 1,'signed' => true,'comment' => '1 正常 2 禁用',]) + ->addColumn('rule_type', 'integer', ['limit' => MysqlAdapter::INT_TINY,'null' => false,'default' => 1,'signed' => true,'comment' => '1 关键字 2 关注 3 默认',]) + ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建人ID',]) + ->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',]) + ->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',]) + ->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',]) + ->create(); + } +} diff --git a/catch/wechat/model/WechatReply.php b/catch/wechat/model/WechatReply.php new file mode 100644 index 0000000..96a596c --- /dev/null +++ b/catch/wechat/model/WechatReply.php @@ -0,0 +1,49 @@ +reply = $reply; + } + + public function model() + { + return $this->reply; + } + + public function storeBy(array $data) + { + return parent::storeBy($data); // TODO: Change the autogenerated stub + } +} \ No newline at end of file diff --git a/catch/wechat/route.php b/catch/wechat/route.php index 16c881a..e937788 100644 --- a/catch/wechat/route.php +++ b/catch/wechat/route.php @@ -32,6 +32,10 @@ $router->group('wechat', function () use ($router){ $router->group('official/graphic', function () use ($router){ $router->resource('', '\catchAdmin\wechat\controller\Graphic'); }); + // 微信回复管理 + $router->group('official/reply', function () use ($router){ + $router->resource('', '\catchAdmin\wechat\controller\Reply'); + }); })->middleware('auth'); // 消息