更新数据库加密相关操作
This commit is contained in:
50
common/services/UtilsService.php
Normal file
50
common/services/UtilsService.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace common\services;
|
||||
|
||||
class UtilsService
|
||||
{
|
||||
|
||||
public $urlList = [
|
||||
'avatar',
|
||||
'logo',
|
||||
'url',
|
||||
'image_url',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var mixed 单例实例,确保该类只有一个全局实例
|
||||
*/
|
||||
private static mixed $_instance;
|
||||
|
||||
/**
|
||||
* 获取实例
|
||||
* @return null|static
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
$name = get_called_class();
|
||||
if (!isset(self::$_instance[$name])) {
|
||||
self::$_instance[$name] = new static();
|
||||
}
|
||||
|
||||
return self::$_instance[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取oss链接
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function truncatedOss($data)
|
||||
{
|
||||
foreach ($data as $key => &$value) {
|
||||
if (in_array($key, $this->urlList)) {
|
||||
$value = str_replace('http://xiaokang88.oss-cn-hangzhou.aliyuncs.com/', '', $value);
|
||||
$value = str_replace('https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/', '', $value);
|
||||
$value = explode('?', $value)[0];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user