|
|
@@ -36,7 +36,7 @@ class UploadService
|
|
|
* @author 段誉
|
|
|
* @date 2021/12/29 16:30
|
|
|
*/
|
|
|
- public static function image($cid, int $sourceId = 0, int $source = FileEnum::SOURCE_ADMIN, string $saveDir = 'uploads/images')
|
|
|
+ public static function image($cid, int $sourceId = 0, int $source = FileEnum::SOURCE_ADMIN, string $saveDir = 'uploads/images',$tenant_id=0)
|
|
|
{
|
|
|
try {
|
|
|
$config = [
|
|
|
@@ -69,15 +69,29 @@ class UploadService
|
|
|
}
|
|
|
|
|
|
// 4、写入数据库中
|
|
|
- $file = (AdminTerminalEnum::isTenant() ? new TenantFile() : new File())->create([
|
|
|
- 'cid' => $cid,
|
|
|
- 'type' => FileEnum::IMAGE_TYPE,
|
|
|
- 'name' => $fileInfo['name'],
|
|
|
- 'uri' => $saveDir . '/' . str_replace("\\","/", $fileName),
|
|
|
- 'source' => $source,
|
|
|
- 'source_id' => $sourceId,
|
|
|
- 'create_time' => time(),
|
|
|
- ]);
|
|
|
+ if(AdminTerminalEnum::isTenant()){
|
|
|
+ $file = (new TenantFile())->create([
|
|
|
+ 'tenant_id' => $tenant_id,
|
|
|
+ 'cid' => $cid,
|
|
|
+ 'type' => FileEnum::IMAGE_TYPE,
|
|
|
+ 'name' => $fileInfo['name'],
|
|
|
+ 'uri' => $saveDir . '/' . str_replace("\\","/", $fileName),
|
|
|
+ 'source' => $source,
|
|
|
+ 'source_id' => $sourceId,
|
|
|
+ 'create_time' => time(),
|
|
|
+ ]);
|
|
|
+ }else{
|
|
|
+ $file = (new File())->create([
|
|
|
+ 'cid' => $cid,
|
|
|
+ 'type' => FileEnum::IMAGE_TYPE,
|
|
|
+ 'name' => $fileInfo['name'],
|
|
|
+ 'uri' => $saveDir . '/' . str_replace("\\","/", $fileName),
|
|
|
+ 'source' => $source,
|
|
|
+ 'source_id' => $sourceId,
|
|
|
+ 'create_time' => time(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 5、返回结果
|
|
|
return [
|
|
|
@@ -105,7 +119,7 @@ class UploadService
|
|
|
* @author 段誉
|
|
|
* @date 2021/12/29 16:32
|
|
|
*/
|
|
|
- public static function video($cid, int $sourceId = 0, int $source = FileEnum::SOURCE_ADMIN, string $saveDir = 'uploads/video')
|
|
|
+ public static function video($cid, int $sourceId = 0, int $source = FileEnum::SOURCE_ADMIN, string $saveDir = 'uploads/video',$tenant_id=0)
|
|
|
{
|
|
|
try {
|
|
|
$config = [
|
|
|
@@ -138,15 +152,29 @@ class UploadService
|
|
|
}
|
|
|
|
|
|
// 4、写入数据库中
|
|
|
- $file = (AdminTerminalEnum::isTenant() ? new TenantFile() : new File())->create([
|
|
|
- 'cid' => $cid,
|
|
|
- 'type' => FileEnum::VIDEO_TYPE,
|
|
|
- 'name' => $fileInfo['name'],
|
|
|
- 'uri' => $saveDir . '/' . str_replace("\\","/", $fileName),
|
|
|
- 'source' => $source,
|
|
|
- 'source_id' => $sourceId,
|
|
|
- 'create_time' => time(),
|
|
|
- ]);
|
|
|
+ if(AdminTerminalEnum::isTenant()){
|
|
|
+ $file = (new TenantFile())->create([
|
|
|
+ 'tenant_id' => $tenant_id,
|
|
|
+ 'cid' => $cid,
|
|
|
+ 'type' => FileEnum::VIDEO_TYPE,
|
|
|
+ 'name' => $fileInfo['name'],
|
|
|
+ 'uri' => $saveDir . '/' . str_replace("\\","/", $fileName),
|
|
|
+ 'source' => $source,
|
|
|
+ 'source_id' => $sourceId,
|
|
|
+ 'create_time' => time(),
|
|
|
+ ]);
|
|
|
+ }else{
|
|
|
+ $file = (new File())->create([
|
|
|
+ 'cid' => $cid,
|
|
|
+ 'type' => FileEnum::VIDEO_TYPE,
|
|
|
+ 'name' => $fileInfo['name'],
|
|
|
+ 'uri' => $saveDir . '/' . str_replace("\\","/", $fileName),
|
|
|
+ 'source' => $source,
|
|
|
+ 'source_id' => $sourceId,
|
|
|
+ 'create_time' => time(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 5、返回结果
|
|
|
return [
|
|
|
@@ -174,7 +202,7 @@ class UploadService
|
|
|
* @author dw
|
|
|
* @date 2023/06/26
|
|
|
*/
|
|
|
- public static function file($cid, int $sourceId = 0, int $source = FileEnum::SOURCE_ADMIN, string $saveDir = 'uploads/file')
|
|
|
+ public static function file($cid, int $sourceId = 0, int $source = FileEnum::SOURCE_ADMIN, string $saveDir = 'uploads/file',$tenant_id=0)
|
|
|
{
|
|
|
try {
|
|
|
$config = [
|
|
|
@@ -207,15 +235,29 @@ class UploadService
|
|
|
}
|
|
|
|
|
|
// 4、写入数据库中
|
|
|
- $file = (AdminTerminalEnum::isTenant() ? new TenantFile() : new File())->create([
|
|
|
- 'cid' => $cid,
|
|
|
- 'type' => FileEnum::FILE_TYPE,
|
|
|
- 'name' => $fileInfo['name'],
|
|
|
- 'uri' => $saveDir . '/' . str_replace("\\", "/", $fileName),
|
|
|
- 'source' => $source,
|
|
|
- 'source_id' => $sourceId,
|
|
|
- 'create_time' => time(),
|
|
|
- ]);
|
|
|
+ if(AdminTerminalEnum::isTenant()) {
|
|
|
+ $file = (new TenantFile())->create([
|
|
|
+ 'tenant_id' => $tenant_id,
|
|
|
+ 'cid' => $cid,
|
|
|
+ 'type' => FileEnum::FILE_TYPE,
|
|
|
+ 'name' => $fileInfo['name'],
|
|
|
+ 'uri' => $saveDir . '/' . str_replace("\\", "/", $fileName),
|
|
|
+ 'source' => $source,
|
|
|
+ 'source_id' => $sourceId,
|
|
|
+ 'create_time' => time(),
|
|
|
+ ]);
|
|
|
+ }else{
|
|
|
+ $file = (new File())->create([
|
|
|
+ 'cid' => $cid,
|
|
|
+ 'type' => FileEnum::FILE_TYPE,
|
|
|
+ 'name' => $fileInfo['name'],
|
|
|
+ 'uri' => $saveDir . '/' . str_replace("\\", "/", $fileName),
|
|
|
+ 'source' => $source,
|
|
|
+ 'source_id' => $sourceId,
|
|
|
+ 'create_time' => time(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 5、返回结果
|
|
|
return [
|
|
|
@@ -232,7 +274,7 @@ class UploadService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static function base64Image($cid, $base64_image, string $saveDir = 'uploads/signs')
|
|
|
+ public static function base64Image($cid, $base64_image, string $saveDir = 'uploads/signs',$tenant_id=0)
|
|
|
{
|
|
|
try {
|
|
|
// 提取Base64数据,去掉"data:image/png;base64,"前缀
|
|
|
@@ -256,14 +298,27 @@ class UploadService
|
|
|
}
|
|
|
|
|
|
// 4、写入数据库中
|
|
|
- $file = (AdminTerminalEnum::isTenant() ? new TenantFile() : new File())->create([
|
|
|
- 'cid' => $cid,
|
|
|
- 'type' => FileEnum::IMAGE_TYPE,
|
|
|
- 'name' => $file_name,
|
|
|
- 'uri' => $file_path,
|
|
|
- 'source_id' => 0,
|
|
|
- 'create_time' => time(),
|
|
|
- ]);
|
|
|
+ if(AdminTerminalEnum::isTenant()) {
|
|
|
+ $file = (new TenantFile())->create([
|
|
|
+ 'tenant_id' => $tenant_id,
|
|
|
+ 'cid' => $cid,
|
|
|
+ 'type' => FileEnum::IMAGE_TYPE,
|
|
|
+ 'name' => $file_name,
|
|
|
+ 'uri' => $file_path,
|
|
|
+ 'source_id' => 0,
|
|
|
+ 'create_time' => time(),
|
|
|
+ ]);
|
|
|
+ }else{
|
|
|
+ $file = (new File())->create([
|
|
|
+ 'cid' => $cid,
|
|
|
+ 'type' => FileEnum::IMAGE_TYPE,
|
|
|
+ 'name' => $file_name,
|
|
|
+ 'uri' => $file_path,
|
|
|
+ 'source_id' => 0,
|
|
|
+ 'create_time' => time(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 5、返回结果
|
|
|
return [
|
|
|
@@ -304,7 +359,7 @@ class UploadService
|
|
|
* @author 林海涛
|
|
|
* @date 2024/7/19 下午5:02
|
|
|
*/
|
|
|
- public static function uploadFies($cid, int $sourceId = 0, int $source = FileEnum::SOURCE_ADMIN, string $saveDir = 'uploads/file')
|
|
|
+ public static function uploadFies($cid, int $sourceId = 0, int $source = FileEnum::SOURCE_ADMIN, string $saveDir = 'uploads/file',$tenant_id=0)
|
|
|
{
|
|
|
try{
|
|
|
$data =[];
|