作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\type;
use App\Http\Controllers\统一返回参数;
use App\Models\File\Image as ImageModel;
use App\Models\User\User as UserModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Storage;
... ... @@ -24,6 +25,8 @@ class ImageController
'Content-Description' => 'File Transfer',
],
];
const TYPE = 1;
public $path = '';
public $config = '';
... ... @@ -39,7 +42,7 @@ class ImageController
$this->path = $this->config['root'];
}
public function index($hash = '', $w = 0 ,$h = 0){
public function index($hash = '',$type = self::TYPE, $w = 0 ,$h = 0 ){
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
header("HTTP/1.1 304 Not Modified");
exit;
... ... @@ -50,6 +53,7 @@ class ImageController
$this->response('指定图片不存在!', Code::USER_ERROR);
}
//查看缩略图是否存在
// $header['Content-Type'] = 'image/'.$info['type'];
$filename = $this->path . $info['hash'] . $w . '_' . $h;
if(is_file($filename)){
$last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
... ... @@ -78,7 +82,12 @@ class ImageController
$img_type = $info['type'];
$content = base64_encode($content);
$img_base64 = 'data:image/' . $img_type . ';base64,' . $content;
return response($img_base64, 200, $header);
if($type != self::TYPE){
header('Content-Type: image/' . $img_type);
echo base64_decode($content);
exit;
}
return response($img_base64,200,$header);
}
/**
... ... @@ -114,7 +123,7 @@ class ImageController
$imageModel = new ImageModel();
$image_hash = $imageModel->read(['hash'=>$hash]);
if($image_hash !== false){
return $hash;
return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
}
$url = $this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
... ... @@ -133,7 +142,7 @@ class ImageController
if ($rs === false) {
return $this->response('添加失败', Code::USER_ERROR);
}
return $hash;
return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
}
/**
* 生成缩略图缓存
... ... @@ -186,7 +195,7 @@ class ImageController
$data[] = $hash;
}
$imageModel->insert($save_data);
return $data;
return $this->response('图片资源',Code::SUCCESS,['image'=>$data]);
}
//下载
... ... @@ -206,10 +215,50 @@ class ImageController
$result = [
'msg' => $msg == ' ' ? $code->description : $msg,
'code' => $code->value,
'data' => $data,
'data' => $this->_extents($data),
];
$this->header['Content-Type'] = $type;
$response = response($result,$result_code,$this->header);
throw new HttpResponseException($response);
}
/**
* @param $data
* @name :返回参数处理
* @return array|string
* @author :liyuhang
* @method
*/
protected function _extents($data) {
if (empty($data) || !is_array($data)) {
return empty($data) ? is_array($data) ? [] : '' : $data;
}
foreach ($data as $k => $v) {
if (is_array($v)) {
$data[$k] = $this->_extents($v);
} else {
if (is_null($v)) {
$data[$k] = '';
continue;
}
//获取操作人
switch ((string) $k) {
case 'image':
$data['image_link'] = url('/b/image/' . $v);
break;
case 'images':
$v = explode(',',$v);
foreach ($v as $k1=>$v1){
$data['images_link'][$k1] = url('/b/image/' . $v1);
}
break;
case 'file':
$data['file_link'] = url('/b/file_hash/' . $v);
break;
}
}
}
return $data;
}
}
... ...
... ... @@ -47,7 +47,7 @@ class WebSettingFromLogic extends BaseLogic
$this->param['data'][$k] = $v;
}
//新增
$this->model->add_all($this->param['data']);
$this->model->insert($this->param['data']);
}catch (\Exception $e){
$this->fail('error');
}
... ...
... ... @@ -41,7 +41,7 @@ class WebSettingReceivingLogic extends BaseLogic
$v['updated_at'] = date('Y-m-d H:i:s');
$this->param['data'][$k] = $v;
}
$this->model->add_all($this->param['data']);
$this->model->insert($this->param['data']);
}catch (\Exception $e){
$this->fail('error');
}
... ...
... ... @@ -36,7 +36,8 @@ class WebSettingServiceLogic extends BaseLogic
* @time :2023/5/4 11:10
*/
public function setting_service_save(){
// try {
DB::beginTransaction();
try {
$this->param['data'] = Common::uniqueMultiArray($this->param['data']);
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
... ... @@ -46,10 +47,12 @@ class WebSettingServiceLogic extends BaseLogic
$v['updated_at'] = date('Y-m-d H:i:s');
$this->param['data'][$k] = $v;
}
$this->model->add_all($this->param['data']);
// }catch (\Exception $e){
// $this->fail('error');
// }
$this->model->insert($this->param['data']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -66,10 +66,12 @@ class WebSettingTextLogic extends BaseLogic
$web_setting->edit($data,['project_id'=>$this->user['project_id']]);
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$v['project_id'] = $this->user['project_id'];
$this->param['data'][$k] = $v;
}
$this->model->add_all($this->param['data']);
$this->model->insert($this->param['data']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ...
... ... @@ -114,16 +114,6 @@ class Base extends Model
}
/**
* @name :(获取数据条数)count
* @author :lyh
* @method :post
* @time :2023/5/8 15:51
*/
public function get_count($condition){
$query = $this->formatQuery($condition);
$query->count();
}
/**
* @name :新增
* @return void
* @author :liyuhang
... ... @@ -136,15 +126,6 @@ class Base extends Model
}
/**
* @name :(批量插入(data二维数组))add_all
* @author :lyh
* @method :post
* @time :2023/5/8 17:41
*/
public function add_all($data){
return $this->insert($data);
}
/**
* @name :编辑
* @return void
* @author :liyuhang
... ...
... ... @@ -252,6 +252,6 @@ Route::group([], function () {
Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login');
// Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
Route::any('/file_hash/{hash}', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
});
... ...