作者 lyh

gx

... ... @@ -6,7 +6,7 @@ use App\Utils\LogUtils;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Carbon;
use App\Models\UpdateNotify;
use App\Models\File\File;
define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/');
/**
... ... @@ -438,7 +438,31 @@ if (!function_exists('getImageUrl')) {
return $url;
}
}
if (!function_exists('getImageUrl')) {
/**
* @remark :获取文件链接
* @name :getImageUrl
* @author :lyh
* @method :post
* @time :2023/7/20 16:46
*/
function getFileUrl($hash){
if(is_array($hash)){
foreach ($hash as $v){
$url[] = getFileUrl($v);
}
}else{
$fileModel = new File();
$info = $fileModel->read(['hash'=>$hash]);
if(!empty($info)){
$url = url('a/file/'.$info['hash']);
}else{
$url = $hash;
}
}
return $url;
}
}
/**
* @remark :字符串截取
* @name :characterTruncation
... ...
... ... @@ -12,19 +12,19 @@ class ProcessRecords extends Base
protected $table = 'gl_project_process_records';
public function setRecordAttribute($value){
// foreach ($value as &$v){
// $v['image'] = Upload::url2path($v['image']);
// $v['file'] = Upload::url2path($v['file']);
// }
foreach ($value as &$v){
$v['image'] = basename($v['image']);
$v['file'] = basename($v['file']);
}
$this->attributes['record'] = Arr::a2s($value);
}
public function getRecordAttribute($value){
$value = Arr::s2a($value);
// foreach ($value as &$v){
// $v['image'] = Upload::path2url($v['image']);
// $v['file'] = Upload::path2url($v['file']);
// }
foreach ($value as &$v){
$v['image'] = getImageUrl($v['image']);
$v['file'] = getFileUrl($v['file']);
}
return $value;
}
... ...