Merge branch 'develop' into dc
正在显示
6 个修改的文件
包含
26 行增加
和
20 行删除
| @@ -6,7 +6,7 @@ use App\Enums\Common\Code; | @@ -6,7 +6,7 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Helper\AyrShare as AyrShareHelper; | 6 | use App\Helper\AyrShare as AyrShareHelper; |
| 7 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 8 | use App\Http\Controllers\Bside\FileController; | 8 | use App\Http\Controllers\Bside\FileController; |
| 9 | -use App\Http\Controllers\file\ImageController; | 9 | +use App\Http\Controllers\File\ImageController; |
| 10 | use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; | 10 | use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; |
| 11 | use App\Http\Logic\Bside\AyrShare\AyrShareLogic; | 11 | use App\Http\Logic\Bside\AyrShare\AyrShareLogic; |
| 12 | use App\Models\File\Image; | 12 | use App\Models\File\Image; |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | -namespace App\Http\Controllers\file; | 3 | +namespace App\Http\Controllers\File; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\type; | 6 | use App\Http\Controllers\type; |
| @@ -41,6 +41,15 @@ class ImageController | @@ -41,6 +41,15 @@ class ImageController | ||
| 41 | $this->path = $this->config['root'].$this->uploads['path'].'/'; | 41 | $this->path = $this->config['root'].$this->uploads['path'].'/'; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | + /** | ||
| 45 | + * @param $hash | ||
| 46 | + * @param $w | ||
| 47 | + * @param $h | ||
| 48 | + * @name :index | ||
| 49 | + * @author :lyh | ||
| 50 | + * @method :post | ||
| 51 | + * @time :2023/5/11 17:19 | ||
| 52 | + */ | ||
| 44 | public function index($hash = '', $w = 0 ,$h = 0 ){ | 53 | public function index($hash = '', $w = 0 ,$h = 0 ){ |
| 45 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { | 54 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { |
| 46 | header("HTTP/1.1 304 Not Modified"); | 55 | header("HTTP/1.1 304 Not Modified"); |
| @@ -58,7 +67,7 @@ class ImageController | @@ -58,7 +67,7 @@ class ImageController | ||
| 58 | $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], | 67 | $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], |
| 59 | [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']); | 68 | [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']); |
| 60 | $content = file_get_contents($filename); | 69 | $content = file_get_contents($filename); |
| 61 | - $header['Content-Length'] = $info['size']; | 70 | + $header['Content-Length'] = strlen($content); |
| 62 | }else{ | 71 | }else{ |
| 63 | $path = $info['path']; | 72 | $path = $info['path']; |
| 64 | if (!is_file($path)) { | 73 | if (!is_file($path)) { |
| @@ -78,10 +87,7 @@ class ImageController | @@ -78,10 +87,7 @@ class ImageController | ||
| 78 | } | 87 | } |
| 79 | } | 88 | } |
| 80 | $header['Content-Type'] = 'image/'.$info['type']; | 89 | $header['Content-Type'] = 'image/'.$info['type']; |
| 81 | - $img_type = $info['type']; | ||
| 82 | - $content = base64_encode($content); | ||
| 83 | - $img_base64 = 'data:image/' . $img_type . ';base64,' . $content; | ||
| 84 | - return response($img_base64,200,$header); | 90 | + return response($content,200,$header); |
| 85 | } | 91 | } |
| 86 | 92 | ||
| 87 | /** | 93 | /** |
| @@ -6,7 +6,7 @@ namespace App\Http\Logic\Bside; | @@ -6,7 +6,7 @@ namespace App\Http\Logic\Bside; | ||
| 6 | use App\Enums\Common\Code; | 6 | use App\Enums\Common\Code; |
| 7 | use App\Enums\Common\Common; | 7 | use App\Enums\Common\Common; |
| 8 | use App\Exceptions\BsideGlobalException; | 8 | use App\Exceptions\BsideGlobalException; |
| 9 | -use App\Http\Controllers\file\ImageController; | 9 | +use App\Http\Controllers\File\ImageController; |
| 10 | use App\Http\Logic\Logic; | 10 | use App\Http\Logic\Logic; |
| 11 | use App\Models\File\Image as ImageModel; | 11 | use App\Models\File\Image as ImageModel; |
| 12 | use Illuminate\Support\Facades\Cache; | 12 | use Illuminate\Support\Facades\Cache; |
| @@ -59,19 +59,19 @@ class NewsLogic extends BaseLogic | @@ -59,19 +59,19 @@ class NewsLogic extends BaseLogic | ||
| 59 | $this->param['project_id'] = $this->user['project_id']; | 59 | $this->param['project_id'] = $this->user['project_id']; |
| 60 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); | 60 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); |
| 61 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); | 61 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); |
| 62 | -// DB::beginTransaction(); | ||
| 63 | -// try { | 62 | + DB::beginTransaction(); |
| 63 | + try { | ||
| 64 | if(isset($this->param['image'])){ | 64 | if(isset($this->param['image'])){ |
| 65 | $data = $this->upload(); | 65 | $data = $this->upload(); |
| 66 | $this->param['image'] = $data; | 66 | $this->param['image'] = $data; |
| 67 | } | 67 | } |
| 68 | $rs = $this->model->insertGetId($this->param); | 68 | $rs = $this->model->insertGetId($this->param); |
| 69 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); | 69 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); |
| 70 | -// DB::commit(); | ||
| 71 | -// }catch (\Exception $e){ | ||
| 72 | -// DB::rollBack(); | ||
| 73 | -// $this->fail('添加失败'); | ||
| 74 | -// } | 70 | + DB::commit(); |
| 71 | + }catch (\Exception $e){ | ||
| 72 | + DB::rollBack(); | ||
| 73 | + $this->fail('添加失败'); | ||
| 74 | + } | ||
| 75 | return $this->success(); | 75 | return $this->success(); |
| 76 | } | 76 | } |
| 77 | 77 |
| @@ -190,11 +190,11 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -190,11 +190,11 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 190 | }); | 190 | }); |
| 191 | //图片操作 | 191 | //图片操作 |
| 192 | Route::prefix('images')->group(function () { | 192 | Route::prefix('images')->group(function () { |
| 193 | - Route::post('/upload', [\App\Http\Controllers\file\ImageController::class, 'upload'])->name('image_upload'); | 193 | + Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('image_upload'); |
| 194 | }); | 194 | }); |
| 195 | //文件上传第三方操作 | 195 | //文件上传第三方操作 |
| 196 | Route::prefix('files')->group(function () { | 196 | Route::prefix('files')->group(function () { |
| 197 | - Route::post('/upload', [\App\Http\Controllers\file\FileController::class, 'upload'])->name('files_upload'); | 197 | + Route::post('/upload', [\App\Http\Controllers\File\FileController::class, 'upload'])->name('files_upload'); |
| 198 | }); | 198 | }); |
| 199 | //精准询盘 | 199 | //精准询盘 |
| 200 | Route::prefix('inquiry')->group(function () { | 200 | Route::prefix('inquiry')->group(function () { |
| @@ -260,6 +260,6 @@ Route::group([], function () { | @@ -260,6 +260,6 @@ Route::group([], function () { | ||
| 260 | Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); | 260 | Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); |
| 261 | // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); | 261 | // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); |
| 262 | Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); | 262 | Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); |
| 263 | - Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show'); | ||
| 264 | - Route::any('/file_hash/{hash}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show'); | 263 | + Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class,'index'])->name('image_show'); |
| 264 | + Route::any('/file_hash/{hash}/', [\App\Http\Controllers\File\FileController::class,'index'])->name('file_show'); | ||
| 265 | }); | 265 | }); |
-
请 注册 或 登录 后发表评论