正在显示
2 个修改的文件
包含
34 行增加
和
10 行删除
| @@ -6,7 +6,7 @@ use App\Utils\LogUtils; | @@ -6,7 +6,7 @@ use App\Utils\LogUtils; | ||
| 6 | use GuzzleHttp\Client; | 6 | use GuzzleHttp\Client; |
| 7 | use GuzzleHttp\Exception\GuzzleException; | 7 | use GuzzleHttp\Exception\GuzzleException; |
| 8 | use Illuminate\Support\Carbon; | 8 | use Illuminate\Support\Carbon; |
| 9 | -use App\Models\UpdateNotify; | 9 | +use App\Models\File\File; |
| 10 | 10 | ||
| 11 | define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); | 11 | define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); |
| 12 | /** | 12 | /** |
| @@ -438,7 +438,31 @@ if (!function_exists('getImageUrl')) { | @@ -438,7 +438,31 @@ if (!function_exists('getImageUrl')) { | ||
| 438 | return $url; | 438 | return $url; |
| 439 | } | 439 | } |
| 440 | } | 440 | } |
| 441 | - | 441 | +if (!function_exists('getImageUrl')) { |
| 442 | + /** | ||
| 443 | + * @remark :获取文件链接 | ||
| 444 | + * @name :getImageUrl | ||
| 445 | + * @author :lyh | ||
| 446 | + * @method :post | ||
| 447 | + * @time :2023/7/20 16:46 | ||
| 448 | + */ | ||
| 449 | + function getFileUrl($hash){ | ||
| 450 | + if(is_array($hash)){ | ||
| 451 | + foreach ($hash as $v){ | ||
| 452 | + $url[] = getFileUrl($v); | ||
| 453 | + } | ||
| 454 | + }else{ | ||
| 455 | + $fileModel = new File(); | ||
| 456 | + $info = $fileModel->read(['hash'=>$hash]); | ||
| 457 | + if(!empty($info)){ | ||
| 458 | + $url = url('a/file/'.$info['hash']); | ||
| 459 | + }else{ | ||
| 460 | + $url = $hash; | ||
| 461 | + } | ||
| 462 | + } | ||
| 463 | + return $url; | ||
| 464 | + } | ||
| 465 | +} | ||
| 442 | /** | 466 | /** |
| 443 | * @remark :字符串截取 | 467 | * @remark :字符串截取 |
| 444 | * @name :characterTruncation | 468 | * @name :characterTruncation |
| @@ -12,19 +12,19 @@ class ProcessRecords extends Base | @@ -12,19 +12,19 @@ class ProcessRecords extends Base | ||
| 12 | protected $table = 'gl_project_process_records'; | 12 | protected $table = 'gl_project_process_records'; |
| 13 | 13 | ||
| 14 | public function setRecordAttribute($value){ | 14 | public function setRecordAttribute($value){ |
| 15 | -// foreach ($value as &$v){ | ||
| 16 | -// $v['image'] = Upload::url2path($v['image']); | ||
| 17 | -// $v['file'] = Upload::url2path($v['file']); | ||
| 18 | -// } | 15 | + foreach ($value as &$v){ |
| 16 | + $v['image'] = basename($v['image']); | ||
| 17 | + $v['file'] = basename($v['file']); | ||
| 18 | + } | ||
| 19 | $this->attributes['record'] = Arr::a2s($value); | 19 | $this->attributes['record'] = Arr::a2s($value); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | public function getRecordAttribute($value){ | 22 | public function getRecordAttribute($value){ |
| 23 | $value = Arr::s2a($value); | 23 | $value = Arr::s2a($value); |
| 24 | -// foreach ($value as &$v){ | ||
| 25 | -// $v['image'] = Upload::path2url($v['image']); | ||
| 26 | -// $v['file'] = Upload::path2url($v['file']); | ||
| 27 | -// } | 24 | + foreach ($value as &$v){ |
| 25 | + $v['image'] = getImageUrl($v['image']); | ||
| 26 | + $v['file'] = getFileUrl($v['file']); | ||
| 27 | + } | ||
| 28 | return $value; | 28 | return $value; |
| 29 | } | 29 | } |
| 30 | 30 |
-
请 注册 或 登录 后发表评论