作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -55,13 +55,13 @@ class UpdateRoute extends Command @@ -55,13 +55,13 @@ class UpdateRoute extends Command
55 */ 55 */
56 public function handle(){ 56 public function handle(){
57 $projectModel = new Project(); 57 $projectModel = new Project();
58 - $list = $projectModel->list(['id'=>['in',[1535]]]); 58 + $list = $projectModel->list(['id'=>['in',[1155]]]);
59 $data = []; 59 $data = [];
60 foreach ($list as $v){ 60 foreach ($list as $v){
61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
62 ProjectServer::useProject($v['id']); 62 ProjectServer::useProject($v['id']);
63 -// $this->getProduct();  
64 - $this->setProductKeyword(); 63 + $this->getProduct();
  64 +// $this->setProductKeyword();
65 // $this->getBlog(); 65 // $this->getBlog();
66 DB::disconnect('custom_mysql'); 66 DB::disconnect('custom_mysql');
67 } 67 }
@@ -926,6 +926,28 @@ function base62_encode($num) { @@ -926,6 +926,28 @@ function base62_encode($num) {
926 return $result; 926 return $result;
927 } 927 }
928 928
  929 +/**
  930 + * @remark :腾讯云安全的base64
  931 + * @name :urlSafeBase64Encode
  932 + * @author :lyh
  933 + * @method :post
  934 + * @time :2024/8/19 14:21
  935 + */
  936 +function urlSafeBase64Encode($data = '') {
  937 + if(empty($data)){
  938 + return $data;
  939 + }
  940 + // 1. 使用标准的 BASE64 编码
  941 + $base64 = base64_encode($data);
  942 + // 2. 将加号(+)替换成连接号(-)
  943 + $base64 = str_replace('+', '-', $base64);
  944 + // 3. 将正斜线(/)替换成下划线(_)
  945 + $base64 = str_replace('/', '_', $base64);
  946 + // 4. 去掉末尾的等号(=)
  947 + $base64 = rtrim($base64, '=');
  948 + return $base64;
  949 +}
  950 +
929 951
930 952
931 953
@@ -47,7 +47,8 @@ class ExtensionModuleController extends BaseController @@ -47,7 +47,8 @@ class ExtensionModuleController extends BaseController
47 '3'=>'图片框', 47 '3'=>'图片框',
48 '4'=>'文件框', 48 '4'=>'文件框',
49 '5'=>'下拉框', 49 '5'=>'下拉框',
50 - '6'=>'自动生成订单框' 50 + '6'=>'自动生成订单框',
  51 + '7'=>'创建时间'
51 ]; 52 ];
52 $this->response('success',Code::SUCCESS,$data); 53 $this->response('success',Code::SUCCESS,$data);
53 } 54 }
@@ -328,4 +329,24 @@ class ExtensionModuleController extends BaseController @@ -328,4 +329,24 @@ class ExtensionModuleController extends BaseController
328 $moduleFieldModel->edit(['is_search'=>1],['id'=>['in',$this->param['id']]]); 329 $moduleFieldModel->edit(['is_search'=>1],['id'=>['in',$this->param['id']]]);
329 $this->response('success'); 330 $this->response('success');
330 } 331 }
  332 +
  333 + /**
  334 + * @remark :删除数据
  335 + * @name :delExtensionValue
  336 + * @author :lyh
  337 + * @method :post
  338 + * @time :2024/8/26 14:25
  339 + */
  340 + public function delExtensionValue(){
  341 + $this->request->validate([
  342 + 'module_id'=>'required',
  343 + 'uuid'=>'required',
  344 + ],[
  345 + 'module_id.required' => '模块id不能为空',
  346 + 'uuid.required' => '字段id不能为空',
  347 + ]);
  348 + $moduleValueModel = new ExtensionModuleValue();
  349 + $moduleValueModel->del(['module_id'=>$this->param['module_id'],'uuid'=>$this->param['uuid']]);
  350 + $this->response('success');
  351 + }
331 } 352 }
@@ -147,7 +147,14 @@ class FileController @@ -147,7 +147,14 @@ class FileController
147 */ 147 */
148 public function synchronizationFile($fileName,$location){ 148 public function synchronizationFile($fileName,$location){
149 //同步到大文件 149 //同步到大文件
150 - SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]); 150 + $file_path = $this->getUrl($this->path.'/'.$fileName, 0,$location);
  151 + $headers = get_headers($file_path, 1);
  152 + if (strpos($headers[0], '200') === false) {
  153 + $errorFileModel = new ErrorFile();
  154 + $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
  155 + }else{
  156 + SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
  157 + }
151 return true; 158 return true;
152 } 159 }
153 160
@@ -10,6 +10,7 @@ use App\Jobs\CopyProjectJob; @@ -10,6 +10,7 @@ use App\Jobs\CopyProjectJob;
10 use App\Jobs\SyncImageFileJob; 10 use App\Jobs\SyncImageFileJob;
11 use App\Models\File\ErrorFile; 11 use App\Models\File\ErrorFile;
12 use App\Models\File\Image as ImageModel; 12 use App\Models\File\Image as ImageModel;
  13 +use App\Models\File\ImageSetting;
13 use App\Models\File\WatermarkImage; 14 use App\Models\File\WatermarkImage;
14 use App\Models\Project\Project; 15 use App\Models\Project\Project;
15 use App\Services\AmazonS3Service; 16 use App\Services\AmazonS3Service;
@@ -339,8 +340,9 @@ class ImageController extends Controller @@ -339,8 +340,9 @@ class ImageController extends Controller
339 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); 340 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
340 //同步数据到cos 341 //同步数据到cos
341 if($this->upload_location == 0){ 342 if($this->upload_location == 0){
  343 + $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
342 $cosService = new CosService(); 344 $cosService = new CosService();
343 - $cosService->uploadFile($file,$this->path,$fileName); 345 + $cosService->uploadFile($file,$this->path,$fileName,$watermarkOptions);
344 }else{ 346 }else{
345 //TODO::上传亚马逊 347 //TODO::上传亚马逊
346 $amazonS3Service = new AmazonS3Service(); 348 $amazonS3Service = new AmazonS3Service();
@@ -356,6 +358,47 @@ class ImageController extends Controller @@ -356,6 +358,47 @@ class ImageController extends Controller
356 } 358 }
357 359
358 /** 360 /**
  361 + * @remark :获取图片配置
  362 + * @name :getProjectConfig
  363 + * @author :lyh
  364 + * @method :post
  365 + * @time :2024/8/24 11:03
  366 + */
  367 + public function getProjectConfig($project_id = 0){
  368 + $imageSettingModel = new ImageSetting();
  369 + $settingInfo = $imageSettingModel->read(['project_id'=>$project_id]);
  370 + if($settingInfo !== false){
  371 + if($settingInfo['status'] == 1 && !empty($settingInfo['image_data'])){
  372 + $image_data = json_decode($settingInfo['image_data'],true);
  373 + foreach ($image_data as $k => $v){
  374 + $arr = implode('/',$v);
  375 + if ($arr[0] == 'image') {
  376 + $arr[1] = urlSafeBase64Encode($arr[1]);
  377 + }
  378 + $image_data[$k] = $v;
  379 + }
  380 + }
  381 + if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){
  382 + $str_data = json_decode($settingInfo['str_data'],true);
  383 + foreach ($str_data as $k => $v){
  384 + $arr = implode('/',$v);
  385 + if ($arr[0] == 'text') {
  386 + $arr[1] = urlSafeBase64Encode($arr[1]);
  387 + }
  388 + if ($arr[0] == 'font') {
  389 + $arr[1] = urlSafeBase64Encode($arr[1]);
  390 + }
  391 + if ($arr[0] == 'fill') {
  392 + $arr[1] = urlSafeBase64Encode($arr[1]);
  393 + }
  394 + $str_data[$k] = $arr;
  395 + }
  396 + }
  397 + }
  398 + return null;
  399 + }
  400 +
  401 + /**
359 * @param $filename 402 * @param $filename
360 * @remark :下载 403 * @remark :下载
361 * @name :download 404 * @name :download
@@ -606,4 +649,111 @@ class ImageController extends Controller @@ -606,4 +649,111 @@ class ImageController extends Controller
606 ]; 649 ];
607 return $watermarkImageModel->addReturnId($data); 650 return $watermarkImageModel->addReturnId($data);
608 } 651 }
  652 +
  653 + /**
  654 + * @remark :设置请求参数
  655 + * @name :setInputParam
  656 + * @author :lyh
  657 + * @method :post
  658 + * @time :2024/8/24 10:31
  659 + */
  660 + public function saveInputParam(){
  661 + $this->request->validate([
  662 + 'data'=>['required'],
  663 + 'is_image'=>['required'],
  664 + ],[
  665 + 'data.required'=>'数据',
  666 + 'is_image.required'=>'请设置文本水印还是图片水印',
  667 + ]);
  668 + $data = $this->param['data'];
  669 + $is_image = $this->param['is_image'];
  670 + $imageSetting = new ImageSetting();
  671 + $info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
  672 + $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名
  673 + if($is_image){
  674 + $param = [
  675 + 'image/'.$domain.($data['image'] ?? ''),//图片
  676 + 'gravity/'.($data['gravity'] ?? 'SouthEast'),
  677 + 'dx/'.($data['dx'] ?? 0),
  678 + 'dy/'. ($data['dy'] ?? 0),
  679 + 'batch/'.($data['batch'] ?? 0),//平铺水印功能
  680 + 'dissolve/'.($data['dissolve'] ?? 50),//透明度
  681 + 'degree/'.($data['degree'] ?? 0),//旋转角度设置,取值范围为0 - 360,默认0
  682 + ];
  683 + if($info === false){
  684 + $imageSetting->add(['image_data'=>json_encode($param,true),'project_id'=>$this->cache['project_id']]);
  685 + }else{
  686 + $imageSetting->edit(['image_data'=>json_encode($param,true)],['project_id'=>$this->cache['project_id']]);
  687 + }
  688 + }else{
  689 + $param = [
  690 + 'text/'.($data['text'] ?? ''),//文字水印名称
  691 + 'gravity/'.($data['gravity'] ?? 'SouthEast'),
  692 + 'dx/'.($data['dx'] ?? 10),
  693 + 'dy/'. ($data['dy'] ?? 10),
  694 + 'font/'.($data['font'] ?? 'tahoma.ttf'),//默认宋体
  695 + 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13
  696 + 'fill/'.($data['fill'] ?? '#3D3D3D'),//颜色
  697 + 'dissolve/'.($data['dissolve'] ?? 50),//透明度
  698 + 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0
  699 + 'batch/'.($data['batch'] ?? 0),//平铺水印功能
  700 + 'shadow/'.($data['shadow'] ?? 0),//文字阴影效果,有效值为[0,100],默认为0,表示无阴影
  701 + ];
  702 + if($info === false){
  703 + $imageSetting->add(['str_data'=>json_encode($param,true),'project_id'=>$this->cache['project_id']]);
  704 + }else{
  705 + $imageSetting->edit(['str_data'=>json_encode($param,true)],['project_id'=>$this->cache['project_id']]);
  706 + }
  707 + }
  708 + $this->response('success');
  709 + }
  710 +
  711 + /**
  712 + * @remark :修改水印配置状态
  713 + * @name :editStatus
  714 + * @author :lyh
  715 + * @method :post
  716 + * @time :2024/8/24 11:14
  717 + */
  718 + public function editStatus(){
  719 + $this->request->validate([
  720 + 'status'=>'required',
  721 + ],[
  722 + 'status.required'=>'状态',
  723 + ]);
  724 + $imageSetting = new ImageSetting();
  725 + $info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
  726 + if($info === false){
  727 + $this->response('请先设置水印',Code::SYSTEM_ERROR);
  728 + }
  729 + if($info['status'] == 1 && !empty($info['image_data'])){
  730 + $this->response('请先设置水印',Code::SYSTEM_ERROR);
  731 + }
  732 + if($info['status'] == 2 && !empty($info['str_data'])){
  733 + $this->response('请先设置水印',Code::SYSTEM_ERROR);
  734 + }
  735 + $imageSetting->edit(['status'=>$this->param['status']],['project_id'=>$this->cache['project_id']]);
  736 + $this->response('success');
  737 + }
  738 +
  739 + /**
  740 + * @remark :获取配置
  741 + * @name :getImageSetting
  742 + * @author :lyh
  743 + * @method :post
  744 + * @time :2024/8/24 11:41
  745 + */
  746 + public function getImageSetting(){
  747 + $imageSetting = new ImageSetting();
  748 + $info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
  749 + if($info !== false){
  750 + if(!empty($info['image_data'])){
  751 + $info['image_data'] = json_decode($info['image_data'],true);
  752 + }
  753 + if(!empty($info['str_data'])){
  754 + $info['str_data'] = json_decode($info['str_data'],true);
  755 + }
  756 + }
  757 + $this->response('success',Code::SUCCESS,$info);
  758 + }
609 } 759 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ImageSetting.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/24 10:07
  8 + */
  9 +
  10 +namespace App\Models\File;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ImageSetting extends Base
  15 +{
  16 + protected $table = 'gl_image_setting';
  17 +}
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Services; 3 namespace App\Services;
4 4
5 use App\Exceptions\InquiryFilterException; 5 use App\Exceptions\InquiryFilterException;
  6 +use App\Models\File\ImageSetting;
6 use App\Utils\LogUtils; 7 use App\Utils\LogUtils;
7 use Qcloud\Cos\Client; 8 use Qcloud\Cos\Client;
8 /** 9 /**
@@ -46,7 +47,7 @@ class CosService @@ -46,7 +47,7 @@ class CosService
46 'rules' => [ 47 'rules' => [
47 [ 48 [
48 'fileid' => $filename, // 使用相同的文件名保存 49 'fileid' => $filename, // 使用相同的文件名保存
49 - 'rule' => $watermarkOptions, 50 + 'rule' => 'watermark/1/'.implode('/',$watermarkOptions),
50 ] 51 ]
51 ] 52 ]
52 ]); 53 ]);
@@ -187,7 +188,7 @@ class CosService @@ -187,7 +188,7 @@ class CosService
187 $url = $domain . $cdnUrl; 188 $url = $domain . $cdnUrl;
188 if($is_image){ 189 if($is_image){
189 $param = [ 190 $param = [
190 - 'image/'.$this->urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片 191 + 'image/'.urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片
191 'gravity/'.($data['gravity'] ?? 'SouthEast'), 192 'gravity/'.($data['gravity'] ?? 'SouthEast'),
192 'dx/'.($data['dx'] ?? 0), 193 'dx/'.($data['dx'] ?? 0),
193 'dy/'. ($data['dy'] ?? 0), 194 'dy/'. ($data['dy'] ?? 0),
@@ -198,13 +199,13 @@ class CosService @@ -198,13 +199,13 @@ class CosService
198 $url = $url.'?watermark/1/'.implode('/',$param); 199 $url = $url.'?watermark/1/'.implode('/',$param);
199 }else{ 200 }else{
200 $param = [ 201 $param = [
201 - 'text/'.$this->urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称 202 + 'text/'.urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称
202 'gravity/'.($data['gravity'] ?? 'SouthEast'), 203 'gravity/'.($data['gravity'] ?? 'SouthEast'),
203 'dx/'.($data['dx'] ?? 10), 204 'dx/'.($data['dx'] ?? 10),
204 'dy/'. ($data['dy'] ?? 10), 205 'dy/'. ($data['dy'] ?? 10),
205 - 'font/'.$this->urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体 206 + 'font/'.urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体
206 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13 207 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13
207 - 'fill/'.$this->urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色 208 + 'fill/'.urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色
208 'dissolve/'.($data['dissolve'] ?? 50),//透明度 209 'dissolve/'.($data['dissolve'] ?? 50),//透明度
209 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0 210 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0
210 'batch/'.($data['batch'] ?? 0),//平铺水印功能 211 'batch/'.($data['batch'] ?? 0),//平铺水印功能
@@ -215,6 +216,8 @@ class CosService @@ -215,6 +216,8 @@ class CosService
215 return $url; 216 return $url;
216 } 217 }
217 218
  219 +
  220 +
218 /** 221 /**
219 * @remark :添加水印后保存图片(覆盖/非覆盖的文件未存入数据库) 222 * @remark :添加水印后保存图片(覆盖/非覆盖的文件未存入数据库)
220 * @name :uploadImages 223 * @name :uploadImages
@@ -244,28 +247,6 @@ class CosService @@ -244,28 +247,6 @@ class CosService
244 } 247 }
245 248
246 /** 249 /**
247 - * @remark :腾讯云安全的base64  
248 - * @name :urlSafeBase64Encode  
249 - * @author :lyh  
250 - * @method :post  
251 - * @time :2024/8/19 14:21  
252 - */  
253 - public function urlSafeBase64Encode($data = '') {  
254 - if(empty($data)){  
255 - return $data;  
256 - }  
257 - // 1. 使用标准的 BASE64 编码  
258 - $base64 = base64_encode($data);  
259 - // 2. 将加号(+)替换成连接号(-)  
260 - $base64 = str_replace('+', '-', $base64);  
261 - // 3. 将正斜线(/)替换成下划线(_)  
262 - $base64 = str_replace('/', '_', $base64);  
263 - // 4. 去掉末尾的等号(=)  
264 - $base64 = rtrim($base64, '=');  
265 - return $base64;  
266 - }  
267 -  
268 - /**  
269 * @remark :处理9宫格数据 250 * @remark :处理9宫格数据
270 * @name :getPosition 251 * @name :getPosition
271 * @author :lyh 252 * @author :lyh
@@ -323,6 +323,9 @@ Route::middleware(['bloginauth'])->group(function () { @@ -323,6 +323,9 @@ Route::middleware(['bloginauth'])->group(function () {
323 Route::post('/setWatermark', [\App\Http\Controllers\File\ImageController::class, 'setWatermark'])->name('images_setWatermark'); 323 Route::post('/setWatermark', [\App\Http\Controllers\File\ImageController::class, 'setWatermark'])->name('images_setWatermark');
324 Route::post('/coverOriginalImage', [\App\Http\Controllers\File\ImageController::class, 'coverOriginalImage'])->name('images_coverOriginalImage'); 324 Route::post('/coverOriginalImage', [\App\Http\Controllers\File\ImageController::class, 'coverOriginalImage'])->name('images_coverOriginalImage');
325 Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList'); 325 Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList');
  326 + Route::any('/saveInputParam', [\App\Http\Controllers\File\ImageController::class, 'saveInputParam'])->name('image_saveInputParam');
  327 + Route::any('/editStatus', [\App\Http\Controllers\File\ImageController::class, 'editStatus'])->name('image_editStatus');
  328 + Route::any('/getImageSetting', [\App\Http\Controllers\File\ImageController::class, 'getImageSetting'])->name('image_getImageSetting');
326 }); 329 });
327 //文件操作 330 //文件操作
328 Route::prefix('files')->group(function () { 331 Route::prefix('files')->group(function () {
@@ -587,6 +590,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -587,6 +590,7 @@ Route::middleware(['bloginauth'])->group(function () {
587 Route::any('/getFieldType', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'getFieldType'])->name('extension_module_getFieldType'); 590 Route::any('/getFieldType', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'getFieldType'])->name('extension_module_getFieldType');
588 Route::any('/setSort', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'setSort'])->name('extension_module_setSort'); 591 Route::any('/setSort', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'setSort'])->name('extension_module_setSort');
589 Route::any('/setSearchParam', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'setSearchParam'])->name('extension_module_setSearchParam'); 592 Route::any('/setSearchParam', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'setSearchParam'])->name('extension_module_setSearchParam');
  593 + Route::any('/delExtensionValue', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'delExtensionValue'])->name('extension_module_delExtensionValue');
590 }); 594 });
591 595
592 //自定义小语种文本信息 596 //自定义小语种文本信息