This commit is contained in:
2025-07-02 17:12:38 +08:00
parent 5289483a8a
commit 6f82d5ff72
14 changed files with 1125 additions and 3 deletions
+117
View File
@@ -0,0 +1,117 @@
<?php
namespace app\common\controller;
use app\common\service\OssService;
use app\common\traits\ResponseTrait;
use support\Request;
use Shopwwi\WebmanFilesystem\Facade\Storage;
class UploadController
{
use ResponseTrait;
public function upload(Request $request)
{
try {
$scene = $request->input('scene', 'image');
$file = $request->file('file');
if ($file && $file->isValid()) {
$pathUrl = '/uploads/'.$scene.'/'.date('Ymd').'/'.md5($file->getUploadName() . time()).'.'.$file->getUploadExtension();
$fullPathUrl = public_path() . $pathUrl;
$file->move($fullPathUrl);
$data = [
'domain' => getenv('MAIN_DOMAIN'),
'file_url' => $pathUrl,
'full_url' => getenv('MAIN_DOMAIN') . $pathUrl,
'scene' => $scene,
];
return $this->success($data, 'upload success');
}
return $this->error('file not found');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
// 上传单文件附件
public function uploadFile(Request $request)
{
try {
$file = $request->file('file');
if (!$file || !$file->isValid()) {
return $this->error('上传失败');
}
$result = Storage::adapter('oss')
->path('vehicle_album/'.date('Ymd'))
->size(1024*1024*5)
->upload($file);
$ossservice = new OssService();
$data = [
'file_name' => $result->file_name,
'file_url' => $ossservice->generatePrivateUrl($result->file_name)
];
return $this->success($data);
}catch (\Throwable $e){
return $this->error($e->getMessage());
}
}
// 上传单文件图片
public function uploadImage(Request $request)
{
try {
$file = $request->file('image');
if (!$file || !$file->isValid()) {
return $this->error('上传失败');
}
$result = Storage::adapter('oss')
->path('vehicle_album/'.date('Ymd'))
->size(1024*1024*5)
->extYes(['image/jpeg','image/png'])
->extNo(['image/gif'])
->upload($file);
$ossservice = new OssService();
$data = [
'image_name' => $result->file_name,
'image_url' => $ossservice->generatePrivateUrl($result->file_name)
];
return $this->success($data);
}catch (\Throwable $e){
return $this->error($e->getMessage());
}
}
public function proxy(Request $request)
{
$filePath = $request->get('file'); // 原OSS文件路径
try {
// 生成签名URL
$signedUrl = (new \app\common\service\OssService())->generatePrivateUrl($filePath);
// 获取图片数据并返回
$imageData = file_get_contents($signedUrl);
// 根据文件类型设置Content-Type
$mime = mime_content_type('data://application/octet-stream;base64,'.base64_encode($imageData));
return response($imageData, 200, [
'Content-Type' => $mime,
'Cache-Control' => 'public, max-age=600' // 客户端缓存10分钟
]);
} catch (\Exception $e) {
return response('Image not found '.$e->getMessage(), 404);
}
}
}
+59
View File
@@ -0,0 +1,59 @@
<?php
namespace app\common\service;
use OSS\OssClient;
use OSS\Core\OssException;
use support\exception\BusinessException;
class OssService
{
private $accessKeyId;
private $accessKeySecret;
private $bucket;
private $endpoint;
private $ossClient;
public function __construct()
{
$this->accessKeyId = getenv('OSS_ACCESSID');
$this->accessKeySecret = getenv('OSS_ACCESSSECRET');
$this->bucket = getenv('OSS_BUCKET');
$this->endpoint = getenv('OSS_ENDPOINT');
$this->ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
}
/**
* 上传图片到 OSS
* @param string $filePath 本地文件路径
* @param string $objectKey OSS上存储的对象名称
* @return string 图片的 URL
*/
public function uploadImage($filePath, $objectKey)
{
try {
// 上传文件到 OSS
$this->ossClient->uploadFile($this->bucket, $objectKey, $filePath);
// 构造图片的私有 URL
$url = $this->generatePrivateUrl($objectKey);
return $url;
} catch (OssException $e) {
// 错误处理
throw new \RuntimeException('OSS Error: ' . $e->getMessage());
} catch (\Throwable $th) {
// 错误处理
throw new BusinessException('Error: ' . $th->getMessage());
}
}
/**
* 生成图片的私有访问 URL
* @param string $objectKey
* @return string
*/
public function generatePrivateUrl($objectKey, $expireTime = 3600)
{
// 生成 OSS 私有 URL(有效期为 3600 秒)
return $this->ossClient->signUrl($this->bucket, $objectKey, $expireTime);
}
}
@@ -0,0 +1,11 @@
<?php
namespace app\ticket\controller;
use app\ticket\service\TicketService;
use support\Request;
class AttachmentController extends BaseController
{
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace app\ticket\controller;
use support\Request;
use support\Response;
use support\exception\BusinessException;
use app\common\traits\ResponseTrait;
use think\Validate;
abstract class BaseController
{
use ResponseTrait;
protected mixed $validator = null;
/**
* 验证数据
*
* @param Validate $validator 验证器实例
* @param array $data 待验证的数据
* @param string $scene 验证场景
* @return array 验证后的数据
* @throws BusinessException 验证失败时抛出业务异常
*/
public function validate(Validate $validator, array $data, string $scene = ''): array
{
// 如果指定了验证场景,并且验证器支持场景方法,则设置验证场景
if ($scene && method_exists($validator, 'scene')) {
$validator->scene($scene);
}
// 执行数据验证
if (!$validator->check($data)) {
// 验证失败,抛出业务异常,异常信息为验证器返回的错误信息
throw new BusinessException($validator->getError());
}
// 验证成功,返回原始数据
return $data;
}
public function page($result){
$current = $result->currentPage();
$total = $result->total();
$size = $result->perPage();
$result = $result->toArray();
$result['current'] = $current;
$result['total'] = $total;
$result['size'] = $size;
return $result;
}
}
@@ -0,0 +1,46 @@
<?php
namespace app\ticket\controller;
use app\ticket\service\TicketService;
use support\Request;
class TicketController extends BaseController
{
public function index(Request $request)
{
try {
$result = (new TicketService())->list($request->all());
return $this->success($this->page($result));
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
public function add(Request $request)
{
try {
$request->setPost('user_id', 1);
return (new TicketService())->add($request->all())
? $this->success()
: $this->error();
} catch (\Throwable $th) {
return $this->error($th->getMessage().' '.$th->getLine().' '.$th->getFile());
}
}
public function edit(Request $request)
{
try {
$request->setPost('user_id', 1);
$result = (new TicketService())->edit($request->all());
return $result
? $this->success($result)
: $this->error();
} catch (\Throwable $th) {
return $this->error($th->getMessage().' '.$th->getLine().' '.$th->getFile());
}
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
namespace app\ticket\logic;
use app\common\model\UserTokenLog;
use app\common\model\Systems;
use app\common\model\User;
use app\common\model\UserSn;
use app\common\utils\Jwt;
use app\ticket\model\Attachment;
use app\ticket\model\Ticket;
use support\Redis;
use support\exception\BusinessException;
use support\Log;
class AttachmentLogic
{
public function adds(array $data,int $ticket_id,int $user_id)
{
try {
foreach ($data as $k=>$v){
$v['ticket_id'] = $ticket_id;
$v['user_id'] = $user_id;
$res = Attachment::create($v);
}
return $res;
} catch (\Throwable $e) {
Log::error('工单创建失败', [
'data' => $data,
'error' => $e->getMessage()
]);
throw new BusinessException($e->getMessage().'工单创建失败,请稍后重试', 500);
}
}
public function edit(array $data,int $ticket_id,int $user_id)
{
try {
$attachmentsId = [];
foreach ($data as $k=>$v){
$v['ticket_id'] = $ticket_id;
$v['user_id'] = $user_id;
if(!empty($v['id'])){ //修改附件
$attachmentId = $v['id'];
$attachmentsId[] = $attachmentId;
// $v_res = Attachment::update($attachmentId, $v);
$v_res = Attachment::updateOrCreate(['id' => $v['id']],$v);
if (!$v_res) {
throw new BusinessException('附件保存失败');
}
} else { //新增附件
unset($v['id']);
$v_res = Attachment::create($v);
if (!$v_res) {
throw new BusinessException('附件创建失败');
}
$vId = $v_res->id;
$attachmentsId[] = $vId;
}
}
//删除本次没有出现的附件
$res = Attachment::whereNotIn('id', $attachmentsId)->where('ticket_id',$ticket_id)->delete();
return $res;
} catch (\Throwable $e) {
Log::error('工单创建失败', [
'data' => $data,
'error' => $e->getMessage()
]);
throw new BusinessException($e->getMessage().'工单创建失败,请稍后重试', 500);
}
}
public static function generateSimpleTicketNo(): string
{
$date = date('Ymd'); // 日期
$prefix = 'GD'; // 前缀
$random = strtoupper(substr(md5(uniqid()), 0, 5)); // 5位随机字母数字
return $prefix . $date . '-' . $random; // 如 GD20240702-AB3X9Z
}
}
+61
View File
@@ -0,0 +1,61 @@
<?php
namespace app\ticket\logic;
use app\common\model\UserTokenLog;
use app\common\model\Systems;
use app\common\model\User;
use app\common\model\UserSn;
use app\common\utils\Jwt;
use app\ticket\model\Ticket;
use support\Redis;
use support\exception\BusinessException;
use support\Log;
class TicketLogic
{
public function list($params)
{
$where = [];
$size = $params['size'];
$current = $params['current'];
return Ticket::with('attachments')->where($where)->paginate($size, ['*'], 'page', $current);
}
public function add(array $data)
{
$data['status'] = 1;
$data['code'] = self::generateSimpleTicketNo();
try {
return Ticket::create($data);
} catch (\Throwable $e) {
Log::error('工单创建失败', [
'data' => $data,
'error' => $e->getMessage()
]);
throw new BusinessException($e->getMessage().'工单创建失败,请稍后重试', 500);
}
}
public function edit(array $data)
{
try {
unset($data['code']);
$ticket = Ticket::updateOrCreate(['id' => $data['id']],$data);
return $ticket;
} catch (\Throwable $e) {
Log::error('工单编辑失败', [
'data' => $data,
'error' => $e->getMessage()
]);
throw new BusinessException($e->getMessage().'工单提取方法…失败,请稍后重试', 500);
}
}
public static function generateSimpleTicketNo(): string
{
$date = date('Ymd'); // 日期
$prefix = 'GD'; // 前缀
$random = strtoupper(substr(md5(uniqid()), 0, 5)); // 5位随机字母数字
return $prefix . $date . '-' . $random; // 如 GD20240702-AB3X9Z
}
}
+66
View File
@@ -0,0 +1,66 @@
<?php
namespace app\ticket\model;
use app\common\model\Resource;
use app\common\model\Role;
use app\common\model\Systems;
use support\Model;
/**
* users 用户表
* @property integer $id 用户ID(主键)
* @property string $ticket_id 工单编号
* @property string $user_id 分类id
* @property string $original_name 内容
* @property string $storage_path 排序
* @property string $mime_type 状态
* @property integer $file_size 创建人id
* @property string $created_at
* @property string $updated_at
*/
class Attachment extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'ticket_attachment';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
protected $fillable = [
'ticket_id',
'user_id',
'original_name',
'storage_path',
'mime_type',
'file_size'
];
public function ticket(){
return $this->belongsTo(Ticket::class, 'ticket_id', 'id');
}
}
+73
View File
@@ -0,0 +1,73 @@
<?php
namespace app\ticket\model;
use app\common\model\Resource;
use app\common\model\Role;
use app\common\model\Systems;
use support\Model;
/**
* users 用户表
* @property integer $id 用户ID(主键)
* @property string $code 工单编号
* @property string $categorie_id 分类id
* @property string $content 内容
* @property string $sort 排序
* @property integer $status 状态
* @property string $user_id 创建人id
* @property string $created_at
* @property string $updated_at
*/
class Ticket extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'ticket';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
protected $dates = ['created_at', 'updated_at'];
protected $casts = [
'updated_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
];
protected $fillable = [
'code',
'categorie_id',
'content',
'sort',
'status',
'user_id'
];
public function attachments(){
return $this->hasMany(Attachment::class, 'ticket_id', 'id');
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace app\ticket\service;
use app\ticket\logic\AttachmentLogic;
use app\ticket\logic\TicketLogic;
use app\ticket\model\Ticket;
use support\Db;
use support\exception\BusinessException;
use support\Log;
class TicketService
{
public function list($params)
{
$res = (new TicketLogic())->list($params);
return $res;
}
public function add(array $data)
{
try {
$attachment = $data['attachment']??[];
$logic = new TicketLogic();
$result = $logic->add($data);
if(!empty($attachment)){
(new AttachmentLogic())->adds($attachment, $result->id, $data['user_id']);
}
return $result;
} catch (\Throwable $e) {
Db::rollback();
throw $e;
}
}
public function edit(array $data)
{
try {
Db::beginTransaction();
$attachment = $data['attachment']??[];
$logic = new TicketLogic();
$result = $logic->edit($data);
if(!empty($attachment)){
(new AttachmentLogic())->edit($attachment, $result->id, $data['user_id']);
}
Db::commit();
return $result;
} catch (\Throwable $e) {
Db::rollback();
throw $e;
}
}
}
+3 -1
View File
@@ -37,7 +37,9 @@
"vlucas/phpdotenv": "^5.6",
"firebase/php-jwt": "^6.11",
"league/oauth2-server": "^9.2",
"topthink/think-validate": "^3.0"
"topthink/think-validate": "^3.0",
"shopwwi/webman-filesystem": "1.1",
"shopwwi/filesystem-oss": "^1.0"
},
"suggest": {
"ext-event": "For better performance. "
Generated
+376 -1
View File
@@ -4,8 +4,59 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "eecf8b50860214e48bdcb8407fd40e14",
"content-hash": "7421030f864dacf31b06378e1045d034",
"packages": [
{
"name": "aliyuncs/oss-sdk-php",
"version": "v2.7.2",
"source": {
"type": "git",
"url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
"reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5",
"reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"php-coveralls/php-coveralls": "*",
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"psr-4": {
"OSS\\": "src/OSS"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aliyuncs",
"homepage": "http://www.aliyun.com"
}
],
"description": "Aliyun OSS SDK for PHP",
"homepage": "http://www.aliyun.com/product/oss/",
"support": {
"issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues",
"source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.7.2"
},
"time": "2024-10-28T10:41:12+00:00"
},
{
"name": "brick/math",
"version": "0.13.1",
@@ -1997,6 +2048,212 @@
},
"time": "2024-09-04T16:06:53+00:00"
},
{
"name": "league/flysystem",
"version": "3.29.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "0adc0d9a51852e170e0028a60bd271726626d3f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/0adc0d9a51852e170e0028a60bd271726626d3f0",
"reference": "0adc0d9a51852e170e0028a60bd271726626d3f0",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"league/flysystem-local": "^3.0.0",
"league/mime-type-detection": "^1.0.0",
"php": "^8.0.2"
},
"conflict": {
"async-aws/core": "<1.19.0",
"async-aws/s3": "<1.14.0",
"aws/aws-sdk-php": "3.209.31 || 3.210.0",
"guzzlehttp/guzzle": "<7.0",
"guzzlehttp/ringphp": "<1.1.1",
"phpseclib/phpseclib": "3.0.15",
"symfony/http-client": "<5.2"
},
"require-dev": {
"async-aws/s3": "^1.5 || ^2.0",
"async-aws/simple-s3": "^1.1 || ^2.0",
"aws/aws-sdk-php": "^3.295.10",
"composer/semver": "^3.0",
"ext-fileinfo": "*",
"ext-ftp": "*",
"ext-mongodb": "^1.3",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.5",
"google/cloud-storage": "^1.23",
"guzzlehttp/psr7": "^2.6",
"microsoft/azure-storage-blob": "^1.1",
"mongodb/mongodb": "^1.2",
"phpseclib/phpseclib": "^3.0.36",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.5.11|^10.0",
"sabre/dav": "^4.6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\Flysystem\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frankdejonge.nl"
}
],
"description": "File storage abstraction for PHP",
"keywords": [
"WebDAV",
"aws",
"cloud",
"file",
"files",
"filesystem",
"filesystems",
"ftp",
"s3",
"sftp",
"storage"
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/3.29.0"
},
"time": "2024-09-29T11:59:11+00:00"
},
{
"name": "league/flysystem-local",
"version": "3.29.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-local.git",
"reference": "e0e8d52ce4b2ed154148453d321e97c8e931bd27"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/e0e8d52ce4b2ed154148453d321e97c8e931bd27",
"reference": "e0e8d52ce4b2ed154148453d321e97c8e931bd27",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-fileinfo": "*",
"league/flysystem": "^3.0.0",
"league/mime-type-detection": "^1.0.0",
"php": "^8.0.2"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\Flysystem\\Local\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frankdejonge.nl"
}
],
"description": "Local filesystem adapter for Flysystem.",
"keywords": [
"Flysystem",
"file",
"files",
"filesystem",
"local"
],
"support": {
"source": "https://github.com/thephpleague/flysystem-local/tree/3.29.0"
},
"time": "2024-08-09T21:24:39+00:00"
},
{
"name": "league/mime-type-detection",
"version": "1.15.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/mime-type-detection.git",
"reference": "ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301",
"reference": "ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-fileinfo": "*",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.2",
"phpstan/phpstan": "^0.12.68",
"phpunit/phpunit": "^8.5.8 || ^9.3 || ^10.0"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\MimeTypeDetection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frankdejonge.nl"
}
],
"description": "Mime-type detection for Flysystem",
"support": {
"issues": "https://github.com/thephpleague/mime-type-detection/issues",
"source": "https://github.com/thephpleague/mime-type-detection/tree/1.15.0"
},
"funding": [
{
"url": "https://github.com/frankdejonge",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/league/flysystem",
"type": "tidelift"
}
],
"time": "2024-01-28T23:22:08+00:00"
},
{
"name": "league/oauth2-server",
"version": "9.2.0",
@@ -3267,6 +3524,124 @@
},
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "shopwwi/filesystem-oss",
"version": "v1.0.3",
"source": {
"type": "git",
"url": "https://github.com/shopwwi/filesystem-oss.git",
"reference": "85cb385d1a5d11ca3c22bc485a7b18c588fe7645"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/shopwwi/filesystem-oss/zipball/85cb385d1a5d11ca3c22bc485a7b18c588fe7645",
"reference": "85cb385d1a5d11ca3c22bc485a7b18c588fe7645",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"aliyuncs/oss-sdk-php": "^2.4",
"league/flysystem": "^2.1|^3.0",
"php": ">=7.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Shopwwi\\FilesystemOss\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Tycoon Song",
"email": "8988354@qq.com"
}
],
"description": "AliYun OSS adapter for flysystem V2. aliyuncs/oss-sdk-php ~2.4",
"homepage": "https://github.com/phcent/filesystem-oss",
"keywords": [
"Flysystem",
"aliyun-oss",
"flysystem-aliyun-oss"
],
"support": {
"issues": "https://github.com/shopwwi/filesystem-oss/issues",
"source": "https://github.com/shopwwi/filesystem-oss/tree/v1.0.3"
},
"time": "2022-10-01T03:00:18+00:00"
},
{
"name": "shopwwi/webman-filesystem",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/shopwwi/webman-filesystem.git",
"reference": "26ac82515d3787943573c50d1a6f0ca339f0d3d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/shopwwi/webman-filesystem/zipball/26ac82515d3787943573c50d1a6f0ca339f0d3d4",
"reference": "26ac82515d3787943573c50d1a6f0ca339f0d3d4",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"league/flysystem": "^2.3|^3.0",
"php": ">=7.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Shopwwi\\WebmanFilesystem\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Tycoon Song",
"email": "8988354@qq.com"
}
],
"description": "Flysystem V2 adapter for the webman",
"keywords": [
"cos",
"filesystem",
"oss",
"qiniu",
"webman"
],
"support": {
"issues": "https://github.com/shopwwi/webman-filesystem/issues",
"source": "https://github.com/shopwwi/webman-filesystem/tree/v1.1.0"
},
"time": "2024-01-21T08:03:36+00:00"
},
{
"name": "symfony/cache",
"version": "v7.3.0",
+116
View File
@@ -0,0 +1,116 @@
<?php
/**
*-------------------------------------------------------------------------p*
* 配置文件
*-------------------------------------------------------------------------h*
* @copyright Copyright (c) 2015-2022 Shopwwi Inc. (http://www.shopwwi.com)
*-------------------------------------------------------------------------c*
* @license http://www.shopwwi.com s h o p w w i . c o m
*-------------------------------------------------------------------------e*
* @link http://www.shopwwi.com by 象讯科技 phcent.com
*-------------------------------------------------------------------------n*
* @since shopwwi象讯·PHP商城系统Pro
*-------------------------------------------------------------------------t*
*/
return [
'enable' => true,
'default' => 'local',
'max_size' => 1024 * 1024 * 10, //单个文件大小10M
'ext_yes' => [], //允许上传文件类型 为空则为允许所有
'ext_no' => [], // 不允许上传文件类型 为空则不限制
'storage' => [
'public' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\LocalAdapterFactory::class,
'root' => public_path(),
'url' => '//127.0.0.1:8787' // 静态文件访问域名
],
'local' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\LocalAdapterFactory::class,
'root' => runtime_path(),
'url' => '//127.0.0.1:8787' // 静态文件访问域名
],
'ftp' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\FtpAdapterFactory::class,
'host' => 'ftp.example.com',
'username' => 'username',
'password' => 'password',
'url' => '' // 静态文件访问域名
// 'port' => 21,
// 'root' => '/path/to/root',
// 'passive' => true,
// 'ssl' => true,
// 'timeout' => 30,
// 'ignorePassiveAddress' => false,
// 'timestampsOnUnixListingsEnabled' => true,
],
'memory' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\MemoryAdapterFactory::class,
],
's3' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\S3AdapterFactory::class,
'credentials' => [
'key' => 'S3_KEY',
'secret' => 'S3_SECRET',
],
'region' => 'S3_REGION',
'version' => 'latest',
'bucket_endpoint' => false,
'use_path_style_endpoint' => false,
'endpoint' => 'S3_ENDPOINT',
'bucket_name' => 'S3_BUCKET',
'url' => '' // 静态文件访问域名
],
'minio' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\S3AdapterFactory::class,
'credentials' => [
'key' => 'S3_KEY',
'secret' => 'S3_SECRET',
],
'region' => 'S3_REGION',
'version' => 'latest',
'bucket_endpoint' => false,
'use_path_style_endpoint' => true,
'endpoint' => 'S3_ENDPOINT',
'bucket_name' => 'S3_BUCKET',
'url' => '' // 静态文件访问域名
],
'oss' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\AliyunOssAdapterFactory::class,
'accessId' => getenv('OSS_ACCESSID'),
'accessSecret' => getenv('OSS_ACCESSSECRET'),
'bucket' => getenv('OSS_BUCKET'),
'endpoint' => getenv('OSS_ENDPOINT'),
'url' => getenv('OSS_STATIC_URL'), // 静态文件访问域名
// 'timeout' => 3600,
// 'connectTimeout' => 10,
// 'isCName' => false,
// 'token' => null,
// 'proxy' => null,
],
'qiniu' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\QiniuAdapterFactory::class,
'accessKey' => 'QINIU_ACCESS_KEY',
'secretKey' => 'QINIU_SECRET_KEY',
'bucket' => 'QINIU_BUCKET',
'domain' => 'QINBIU_DOMAIN',
'url' => '' // 静态文件访问域名
],
'cos' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\CosAdapterFactory::class,
'region' => 'COS_REGION',
'app_id' => 'COS_APPID',
'secret_id' => 'COS_SECRET_ID',
'secret_key' => 'COS_SECRET_KEY',
// 可选,如果 bucket 为私有访问请打开此项
// 'signed_url' => false,
'bucket' => 'COS_BUCKET',
'read_from_cdn' => false,
'url' => '' // 静态文件访问域名
// 'timeout' => 60,
// 'connect_timeout' => 60,
// 'cdn' => '',
// 'scheme' => 'https',
],
],
];
+10 -1
View File
@@ -31,4 +31,13 @@ Route::group('/common', function () {
Route::post('/login', [app\common\controller\AuthController::class, 'login']);
Route::post('/register', [app\common\controller\AuthController::class, 'register']);
});
});
});
Route::group('/ticket', function () {
Route::post('/ticket/add', [app\ticket\controller\TicketController::class, 'add']);
Route::post('/ticket/edit', [app\ticket\controller\TicketController::class, 'edit']);
Route::get('/ticket/list', [app\ticket\controller\TicketController::class, 'index']);
Route::post('/upload', [app\common\controller\UploadController::class, 'uploadFile']);
});