添加服务逻辑的编辑
接口:
添加服务列表
添加服务详情
添加服务点赞、收藏
This commit is contained in:
2025-12-24 23:03:48 +08:00
parent 49969d813a
commit 16d1adacca
14 changed files with 2145 additions and 321 deletions

View File

@@ -24,6 +24,20 @@ class Aliyun extends Server
parent::__construct();
$this->config = $config;
}
/**
* 创建并配置 OssClient
* @return OssClient
*/
private function createOssClient()
{
return new OssClient(
$this->config['access_key_id'],
$this->config['access_key_secret'],
$this->config['domain'],
true
);
}
/**
* 执行上传
@@ -33,12 +47,7 @@ class Aliyun extends Server
public function upload($save_dir)
{
try {
$ossClient = new OssClient(
$this->config['access_key_id'],
$this->config['access_key_secret'],
$this->config['domain'],
true
);
$ossClient = $this->createOssClient();
$ossClient->uploadFile(
$this->config['bucket'],
$save_dir . '/' . $this->fileName,
@@ -61,12 +70,7 @@ class Aliyun extends Server
public function fetch($url, $key = null)
{
try {
$ossClient = new OssClient(
$this->config['access_key_id'],
$this->config['access_key_secret'],
$this->config['domain'],
true
);
$ossClient = $this->createOssClient();
$content = file_get_contents($url);
$ossClient->putObject(
@@ -89,12 +93,7 @@ class Aliyun extends Server
public function delete($fileName)
{
try {
$ossClient = new OssClient(
$this->config['access_key_id'],
$this->config['access_key_secret'],
$this->config['domain'],
true
);
$ossClient = $this->createOssClient();
$ossClient->deleteObject($this->config['bucket'], $fileName);
} catch (OssException $e) {
$this->error = $e->getMessage();