更新数据库加密相关操作

This commit is contained in:
2025-01-15 13:16:48 +08:00
parent 81069274be
commit 262ecc4f5e
12 changed files with 383 additions and 90 deletions

View 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;
}
}