mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
增加微信媒体模型
This commit is contained in:
parent
f96035eccc
commit
c854252784
28
app/wechat/model/WechatMedia.php
Normal file
28
app/wechat/model/WechatMedia.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkAdmin
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 官方网站: https://thinkadmin.top
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 开源协议 ( https://mit-license.org )
|
||||||
|
// | 免费声明 ( https://thinkadmin.top/disclaimer )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||||
|
// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\wechat\model;
|
||||||
|
|
||||||
|
use think\admin\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信媒体文件模型
|
||||||
|
* Class WechatMedia
|
||||||
|
* @package app\wechat\model
|
||||||
|
*/
|
||||||
|
class WechatMedia extends Model
|
||||||
|
{
|
||||||
|
}
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
namespace app\wechat\service;
|
namespace app\wechat\service;
|
||||||
|
|
||||||
|
use app\wechat\model\WechatMedia;
|
||||||
use app\wechat\model\WechatNews;
|
use app\wechat\model\WechatNews;
|
||||||
use app\wechat\model\WechatNewsArticle;
|
use app\wechat\model\WechatNewsArticle;
|
||||||
use think\admin\Service;
|
use think\admin\Service;
|
||||||
@ -70,9 +71,9 @@ class MediaService extends Service
|
|||||||
public function upload(string $url, string $type = 'image', array $video = []): string
|
public function upload(string $url, string $type = 'image', array $video = []): string
|
||||||
{
|
{
|
||||||
$map = ['md5' => md5($url), 'appid' => WechatService::instance()->getAppid()];
|
$map = ['md5' => md5($url), 'appid' => WechatService::instance()->getAppid()];
|
||||||
if (($mediaId = $this->app->db->name('WechatMedia')->where($map)->value('media_id'))) return $mediaId;
|
if (($mediaId = WechatMedia::mk()->where($map)->value('media_id'))) return $mediaId;
|
||||||
$result = WechatService::WeChatMedia()->addMaterial(self::buildCurlFile($url), $type, $video);
|
$result = WechatService::WeChatMedia()->addMaterial(self::buildCurlFile($url), $type, $video);
|
||||||
data_save('WechatMedia', [
|
data_save(WechatMedia::class, [
|
||||||
'local_url' => $url, 'md5' => $map['md5'], 'type' => $type, 'appid' => $map['appid'],
|
'local_url' => $url, 'md5' => $map['md5'], 'type' => $type, 'appid' => $map['appid'],
|
||||||
'media_url' => $result['url'] ?? '', 'media_id' => $result['media_id'],
|
'media_url' => $result['url'] ?? '', 'media_id' => $result['media_id'],
|
||||||
], 'type', $map);
|
], 'type', $map);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user