微信回复功能

This commit is contained in:
JaguarJack 2020-06-29 19:51:44 +08:00
parent 09c409fc76
commit 08fb8b3397
5 changed files with 161 additions and 0 deletions

View File

@ -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));
}
}

View File

@ -0,0 +1,48 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class WechatReply extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->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();
}
}

View File

@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catchAdmin\wechat\model;
use catcher\base\CatchModel;
class WechatReply extends CatchModel
{
protected $name = 'wechat_reply';
protected $field = [
'id', //
'keyword', // 关键字
'media_id', // 微信资源ID
'media_url', // 本地资源 URL
'image_url', // 图片资源
'title', // 内容
'content', // 内容
'type', // 1文字 2图文 3图片 4音乐 5视频 6语音 7转客服
'status', // 1 正常 2 禁用
'rule_type', // 1 关键字 2 关注 3 默认
'creator_id', // 创建人ID
'created_at', // 创建时间
'updated_at', // 更新时间
'deleted_at', // 软删除
];
const KEYWORD_RULE = 1;
const ATTENTION_RULE = 2;
const DEFAULT_RULE = 3;
const WORD = 1;
const GRAPHIC = 2;
const IMAGE = 3;
const MUSIC = 4;
const VIDEO = 5;
const VOICE = 6;
const CUSTOMER_SERVICE = 7;
}

View File

@ -8,3 +8,27 @@
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catchAdmin\wechat\repository;
use catchAdmin\wechat\model\WechatReply;
use catcher\base\CatchRepository;
class WechatReplyRepository extends CatchRepository
{
protected $reply;
public function __construct(WechatReply $reply)
{
$this->reply = $reply;
}
public function model()
{
return $this->reply;
}
public function storeBy(array $data)
{
return parent::storeBy($data); // TODO: Change the autogenerated stub
}
}

View File

@ -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');
// 消息