其余文件

This commit is contained in:
2026-04-14 17:46:22 +08:00
parent 294b68fe37
commit 3691f4db22
1343 changed files with 189847 additions and 0 deletions

128
app/common/cache/CacheBase.php vendored Normal file
View File

@ -0,0 +1,128 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\common\cache;
use think\facade\Cache;
abstract class CacheBase
{
protected $tag;
protected $extend;
protected $name;
public function __construct($key = '', $extend = [])
{
$this->tag = $this->setTag();
$this->name = $this->tag . '_' . $key;
$this->extend = $extend;
}
public abstract function setTag();
/**
* 子类实现查出数据
* @return mixed
*/
public abstract function setData();
/**
* 创建并获取数据
* @param null $expire
* @return mixed
*/
public function set($expire = null)
{
$data = self::cacheGet($this->name);
if ($data !== false) {
return $data;
}
$data = $this->setData();
self::cacheSet($this->name, $data, $expire);
return $data;
}
/**
* User: 意象信息科技 lr
* Desc: 获取数据
* @return mixed
*/
public function get()
{
return self::cacheGet($this->name);
}
/**
* 判断数据是否为空
* @return bool
*/
public function isEmpty()
{
$data = self::cacheGet($this->name);
if ($data !== false) {
return false;
}
return true;
}
/**
* 删除数据
* @return bool
*/
public function del()
{
if (self::isEmpty()) {
return true;
}
return self::cacheRm($this->name);
}
public function delAll()
{
return Cache::clear($this->tag);
}
/**
* 刷新并获取
* @return mixed
*/
public function refresh()
{
$this->del();
return $this->set();
}
protected function cacheSet($name, $value, $expire = null)
{
Cache::tag($this->tag)->set($name, $value, $expire);
}
protected function cacheRm($name)
{
return Cache::delete($name);
}
protected function cacheGet($name, $default = false)
{
return Cache::get($name, $default);
}
}

View File

@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\common\cache;
class CommunityArticleCache extends CacheBase
{
public function setTag()
{
return 'community_article';
}
public function setData()
{
if (!empty($this->extend['has_new'])) {
return $this->extend['has_new'];
}
return [];
}
}

90
app/common/cache/ExportCache.php vendored Normal file
View File

@ -0,0 +1,90 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\common\cache;
class ExportCache extends CacheBase
{
protected $uniqid = '';
public function __construct($key = '')
{
parent::__construct($key);
//以微秒计的当前时间,生成一个唯一的 ID,以tagname为前缀
$this->uniqid = md5(uniqid($this->name,true).mt_rand());
}
/**
* @notes 获取缓存目录
* @return string
* @author 段誉
* @date 2022/4/21 11:17
*/
public function getSrc()
{
return app()->getRootPath() . 'runtime/file/export/'.date('Y-m').'/'.$this->uniqid.'/';
}
/**
* @notes 设置文件路径缓存地址
* @param $fileName
* @return string
* @author 令狐冲
* @date 2021/7/28 17:36
*/
public function setFile($fileName)
{
$src = $this->getSrc();
$key = md5($src . $fileName) . time();
$this->cacheSet($key, ['src' => $src, 'name' => $fileName], 300);
return $key;
}
/**
* @notes 获取文件
* @param $key
* @return mixed
* @author 段誉
* @date 2022/4/21 11:44
*/
public function getFile($key)
{
return $this->cacheGet($key);
}
/**
* @notes 设置标签
* @author 段誉
* @date 2022/4/21 11:45
*/
public function setTag()
{
return 'export';
}
public function setData()
{
}
}

43
app/common/cache/RegionCache.php vendored Normal file
View File

@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\common\cache;
use think\facade\Db;
class RegionCache extends CacheBase
{
public function setTag()
{
return 'region';
}
/**
* 子类实现查出数据
* @return mixed
*/
public function setData()
{
return Db::name('dev_region')
->column('name', 'id');
}
}