update:微信回复
This commit is contained in:
parent
5fd218d26a
commit
0da4627217
@ -36,6 +36,18 @@ class Reply extends CatchController
|
|||||||
return CatchResponse::paginate($this->reply->getList());
|
return CatchResponse::paginate($this->reply->getList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取
|
||||||
|
*
|
||||||
|
* @time 2020年09月13日
|
||||||
|
* @param $id
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function read($id)
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->reply->findBy($id));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*
|
*
|
||||||
@ -48,6 +60,18 @@ class Reply extends CatchController
|
|||||||
return CatchResponse::success($this->reply->storeBy($request->param()));
|
return CatchResponse::success($this->reply->storeBy($request->param()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*
|
||||||
|
* @time 2020年09月13日
|
||||||
|
* @param $id
|
||||||
|
* @param CatchRequest $request
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function update($id, CatchRequest $request)
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->reply->updateBy($id, $request->param()));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*
|
*
|
||||||
|
@ -28,6 +28,13 @@ class WechatReplyRepository extends CatchRepository
|
|||||||
return $this->reply;
|
return $this->reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储
|
||||||
|
*
|
||||||
|
* @time 2020年09月13日
|
||||||
|
* @param array $data
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function storeBy(array $data)
|
public function storeBy(array $data)
|
||||||
{
|
{
|
||||||
$material = WeChat::officialAccount()->material;
|
$material = WeChat::officialAccount()->material;
|
||||||
@ -55,6 +62,41 @@ class WechatReplyRepository extends CatchRepository
|
|||||||
return parent::storeBy($data); // TODO: Change the autogenerated stub
|
return parent::storeBy($data); // TODO: Change the autogenerated stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*
|
||||||
|
* @time 2020年09月13日
|
||||||
|
* @param int $id
|
||||||
|
* @param array $data
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function updateBy(int $id, array $data)
|
||||||
|
{
|
||||||
|
$material = WeChat::officialAccount()->material;
|
||||||
|
|
||||||
|
$mediaUrl = $this->getLocalPath($data['media_url'] ?? '');
|
||||||
|
$imageUrl = $this->getLocalPath($data['image_url'] ?? '');
|
||||||
|
|
||||||
|
if ($imageUrl) {
|
||||||
|
// 音乐
|
||||||
|
if ($data['type'] == WechatReply::MUSIC) {
|
||||||
|
$data['media_id'] = $material->uploadThumb($imageUrl)['media_id'];
|
||||||
|
} else {
|
||||||
|
// $data['media_id'] = $material->uploadImage($imageUrl)['media_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 语音
|
||||||
|
if ($data['type'] == WechatReply::VOICE) {
|
||||||
|
$data['media_id'] = $material->uploadVoice($mediaUrl)['media_id'];
|
||||||
|
}
|
||||||
|
// 视频
|
||||||
|
if ($data['type'] == WechatReply::VIDEO) {
|
||||||
|
$data['media_id'] = $material->uploadVideo($mediaUrl, $data['title'], $data['content'])['media_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::updateBy($id, $data); // TODO: Change the autogenerated stub
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取本地地址
|
* 获取本地地址
|
||||||
*
|
*
|
||||||
|
@ -34,9 +34,7 @@ $router->group('wechat', function () use ($router){
|
|||||||
});
|
});
|
||||||
// 微信回复管理
|
// 微信回复管理
|
||||||
$router->group('official/reply', function () use ($router){
|
$router->group('official/reply', function () use ($router){
|
||||||
$router->get('', '\catchAdmin\wechat\controller\Reply@index');
|
$router->resource('', '\catchAdmin\wechat\controller\Reply');
|
||||||
$router->post('', '\catchAdmin\wechat\controller\Reply@save');
|
|
||||||
$router->delete('<id>', '\catchAdmin\wechat\controller\Reply@delete');
|
|
||||||
$router->put('enable/<id>', '\catchAdmin\wechat\controller\Reply@disOrEnable');
|
$router->put('enable/<id>', '\catchAdmin\wechat\controller\Reply@disOrEnable');
|
||||||
});
|
});
|
||||||
// 微信上传
|
// 微信上传
|
||||||
|
Loading…
x
Reference in New Issue
Block a user