Merge remote-tracking branch 'origin/master' into akun
正在显示
12 个修改的文件
包含
302 行增加
和
21 行删除
| @@ -12,6 +12,7 @@ use App\Models\Nav\BNav; | @@ -12,6 +12,7 @@ use App\Models\Nav\BNav; | ||
| 12 | use App\Models\Nav\BNavGroup; | 12 | use App\Models\Nav\BNavGroup; |
| 13 | use App\Models\Project\OnlineCheck; | 13 | use App\Models\Project\OnlineCheck; |
| 14 | use App\Models\Project\Project; | 14 | use App\Models\Project\Project; |
| 15 | +use App\Models\Project\ProjectUpdateTdk; | ||
| 15 | use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; | 16 | use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; |
| 16 | use App\Models\WebSetting\Translate as TranslateModel; | 17 | use App\Models\WebSetting\Translate as TranslateModel; |
| 17 | use App\Models\WebSetting\WebLanguage; | 18 | use App\Models\WebSetting\WebLanguage; |
| @@ -58,6 +59,13 @@ class Test extends Command | @@ -58,6 +59,13 @@ class Test extends Command | ||
| 58 | */ | 59 | */ |
| 59 | public function handle() | 60 | public function handle() |
| 60 | { | 61 | { |
| 62 | + | ||
| 63 | + $ids = '295,792,1788,968,1678,1408,1780,104,1720,160,1337,1382,1773,1787,1261,1872,185,1889,1823,1572,696,1632,1504,1042,1252,491,1867,1277,1712,1939,1577,499,1812,1852,235,732,388,1848,1880,1885,1920,826,1368,1535,1679,1584,1665,773,1841,1303,1442,13,1591,1894,2066,1887,1888,1817,1778,1673,1391,1751,1607,2010,1483,2062,2000,2019,2091,1602,1985,1514,1768,1703,1596,1955,1989,1900,1373,1779,1619,1824,404,1869,1891,1215,1589,1686,1322,1681,1378,1487,1431,1133,1415,1876,1911,1672,1992,1715,1929,1171,1997,1816,1842,2017,2107,1644,2104,2201,1468,2092,211,2097,1993,829,2124,1241'; | ||
| 64 | + $ids = explode(',' ,$ids); | ||
| 65 | + foreach ($ids as $id){ | ||
| 66 | + ProjectUpdateTdk::add_task($id); | ||
| 67 | + } | ||
| 68 | + exit; | ||
| 61 | $date = '2024-05-16'; | 69 | $date = '2024-05-16'; |
| 62 | $list = $this->getProjectList(); | 70 | $list = $this->getProjectList(); |
| 63 | foreach ($list as $item){ | 71 | foreach ($list as $item){ |
| @@ -76,6 +76,9 @@ class ExtensionModuleController extends BaseController | @@ -76,6 +76,9 @@ class ExtensionModuleController extends BaseController | ||
| 76 | $v['is_use'] = 1; | 76 | $v['is_use'] = 1; |
| 77 | } | 77 | } |
| 78 | $list[$k] = $v; | 78 | $list[$k] = $v; |
| 79 | + if(!empty($v['data'])){ | ||
| 80 | + $v['data'] = json_decode($v['data'],true); | ||
| 81 | + } | ||
| 79 | } | 82 | } |
| 80 | $this->response('success',Code::SUCCESS,$list); | 83 | $this->response('success',Code::SUCCESS,$list); |
| 81 | } | 84 | } |
| @@ -224,7 +227,34 @@ class ExtensionModuleController extends BaseController | @@ -224,7 +227,34 @@ class ExtensionModuleController extends BaseController | ||
| 224 | * @time :2024/8/20 10:31 | 227 | * @time :2024/8/20 10:31 |
| 225 | */ | 228 | */ |
| 226 | public function sendUniqueStr(){ | 229 | public function sendUniqueStr(){ |
| 227 | - $uniqueString = md5(time() . rand(1000, 9999)); | 230 | + $this->request->validate([ |
| 231 | + 'id'=>'required', | ||
| 232 | + ],[ | ||
| 233 | + 'id.required' => '字段id不能为空', | ||
| 234 | + ]); | ||
| 235 | + $uniqueString = ''; | ||
| 236 | + //查看当前字段id的data | ||
| 237 | + $moduleFieldModel = new ExtensionModuleField(); | ||
| 238 | + $info = $moduleFieldModel->read(['id'=>$this->param['id']]); | ||
| 239 | + if(empty($info['data'])){ | ||
| 240 | + $uniqueString = md5(time() . rand(1000, 9999)); | ||
| 241 | + }else{ | ||
| 242 | + $data = json_decode($info['data']); | ||
| 243 | + foreach ($data as $v){ | ||
| 244 | + foreach ($v as $k => $sonV){ | ||
| 245 | + if($k == 1){ | ||
| 246 | + $uniqueString .= $sonV; | ||
| 247 | + }elseif ($k == 2){ | ||
| 248 | + $uniqueString .= date('YmdHis'); | ||
| 249 | + }elseif ($k == 3){ | ||
| 250 | + $uniqueString .= uniqid(); | ||
| 251 | + }else{ | ||
| 252 | + $randomString = md5(uniqid(mt_rand(), true)); | ||
| 253 | + $uniqueString .= substr($randomString, 0, (int)$sonV); | ||
| 254 | + } | ||
| 255 | + } | ||
| 256 | + } | ||
| 257 | + } | ||
| 228 | $this->response('success',Code::SUCCESS,['str'=>$uniqueString]); | 258 | $this->response('success',Code::SUCCESS,['str'=>$uniqueString]); |
| 229 | } | 259 | } |
| 230 | } | 260 | } |
| @@ -14,6 +14,7 @@ use App\Models\Project\Project; | @@ -14,6 +14,7 @@ use App\Models\Project\Project; | ||
| 14 | use App\Services\AmazonS3Service; | 14 | use App\Services\AmazonS3Service; |
| 15 | use App\Services\CosService; | 15 | use App\Services\CosService; |
| 16 | use App\Services\TencentCosService; | 16 | use App\Services\TencentCosService; |
| 17 | +use App\Services\UpyunService; | ||
| 17 | use Illuminate\Http\Exceptions\HttpResponseException; | 18 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 18 | use Illuminate\Http\JsonResponse; | 19 | use Illuminate\Http\JsonResponse; |
| 19 | use Illuminate\Support\Facades\Cache; | 20 | use Illuminate\Support\Facades\Cache; |
| @@ -514,4 +515,72 @@ class ImageController extends Controller | @@ -514,4 +515,72 @@ class ImageController extends Controller | ||
| 514 | $data = ['image_download'=>url('a/download_images?path='.$info['path']), 'name' => $info['name']]; | 515 | $data = ['image_download'=>url('a/download_images?path='.$info['path']), 'name' => $info['name']]; |
| 515 | $this->response('success',Code::SUCCESS,$data); | 516 | $this->response('success',Code::SUCCESS,$data); |
| 516 | } | 517 | } |
| 518 | + | ||
| 519 | + /** | ||
| 520 | + * @remark :覆盖原图 | ||
| 521 | + * @name :coverOriginalImage | ||
| 522 | + * @author :lyh | ||
| 523 | + * @method :post | ||
| 524 | + * @time :2024/8/21 11:45 | ||
| 525 | + */ | ||
| 526 | + public function coverOriginalImage(){ | ||
| 527 | + $this->request->validate([ | ||
| 528 | + 'url'=>['required'], | ||
| 529 | + 'saveUrl'=>['required'], | ||
| 530 | + ],[ | ||
| 531 | + 'url.required'=>'请填写预览的链接', | ||
| 532 | + 'saveUrl.required'=>'保存的路径', | ||
| 533 | + ]); | ||
| 534 | + $cos = new CosService(); | ||
| 535 | + $url = $cos->coverOriginalImage($this->param['url'],$this->param['saveUrl']); | ||
| 536 | + $upYun = new UpyunService(); | ||
| 537 | + $upYun->purgePush($url); | ||
| 538 | + $this->response('success',Code::SUCCESS,['url'=>$url]); | ||
| 539 | + } | ||
| 540 | + | ||
| 541 | + /** | ||
| 542 | + * @remark :设置图片水印 | ||
| 543 | + * @name :setWatermark | ||
| 544 | + * @author :lyh | ||
| 545 | + * @method :post | ||
| 546 | + * @time :2024/8/21 9:15 | ||
| 547 | + */ | ||
| 548 | + public function setWatermark(){ | ||
| 549 | + $this->request->validate([ | ||
| 550 | + 'url'=>['required'], | ||
| 551 | + 'is_image'=>['required'], | ||
| 552 | + ],[ | ||
| 553 | + 'url.required'=>'请填写需要处理图片的相对路径', | ||
| 554 | + 'is_image.required'=>'请设置文本水印还是图片水印', | ||
| 555 | + ]); | ||
| 556 | + $cos = new CosService(); | ||
| 557 | + $url = $cos->setWatermark($this->param['url'], $this->param['data'],$this->param['is_image']); | ||
| 558 | + $this->response('success',Code::SUCCESS,['url'=>$url]); | ||
| 559 | + } | ||
| 560 | + | ||
| 561 | + /** | ||
| 562 | + * @remark :获取字体 | ||
| 563 | + * @name :getFont | ||
| 564 | + * @author :lyh | ||
| 565 | + * @method :post | ||
| 566 | + * @time :2024/8/21 9:47 | ||
| 567 | + */ | ||
| 568 | + public function getFont(){ | ||
| 569 | + $cos = new CosService(); | ||
| 570 | + $data = $cos->getFont(); | ||
| 571 | + $this->response('success',Code::SUCCESS,$data); | ||
| 572 | + } | ||
| 573 | + | ||
| 574 | + /** | ||
| 575 | + * @remark :处理9宫格数据 | ||
| 576 | + * @name :getPosition | ||
| 577 | + * @author :lyh | ||
| 578 | + * @method :post | ||
| 579 | + * @time :2024/8/21 9:47 | ||
| 580 | + */ | ||
| 581 | + public function getPosition(){ | ||
| 582 | + $cos = new CosService(); | ||
| 583 | + $data = $cos->getPosition(); | ||
| 584 | + $this->response('success',Code::SUCCESS,$data); | ||
| 585 | + } | ||
| 517 | } | 586 | } |
| @@ -114,7 +114,7 @@ class BTemplateLogic extends BaseLogic | @@ -114,7 +114,7 @@ class BTemplateLogic extends BaseLogic | ||
| 114 | $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id]; | 114 | $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id]; |
| 115 | $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id); | 115 | $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id); |
| 116 | $bTemplateComModel = new BTemplateCom(); | 116 | $bTemplateComModel = new BTemplateCom(); |
| 117 | - $otherInfo = $bTemplateComModel->read(['source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom']]); | 117 | + $otherInfo = $bTemplateComModel->read(['source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom'],'template_id'=>$template_id]); |
| 118 | if($otherInfo === false){ | 118 | if($otherInfo === false){ |
| 119 | $this->fail('获取失败,请联系管理员222'); | 119 | $this->fail('获取失败,请联系管理员222'); |
| 120 | } | 120 | } |
| @@ -139,7 +139,7 @@ class BTemplateLogic extends BaseLogic | @@ -139,7 +139,7 @@ class BTemplateLogic extends BaseLogic | ||
| 139 | $headComInfo = $bTemplateComModel->read($condition); | 139 | $headComInfo = $bTemplateComModel->read($condition); |
| 140 | if($headComInfo === false){ | 140 | if($headComInfo === false){ |
| 141 | //取默认公共的 | 141 | //取默认公共的 |
| 142 | - $headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD]); | 142 | + $headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD,'template_id'=>$template_id]); |
| 143 | if($headComInfo === false){ | 143 | if($headComInfo === false){ |
| 144 | $this->fail('获取失败,请联系管理员111'); | 144 | $this->fail('获取失败,请联系管理员111'); |
| 145 | } | 145 | } |
| @@ -160,7 +160,7 @@ class BTemplateLogic extends BaseLogic | @@ -160,7 +160,7 @@ class BTemplateLogic extends BaseLogic | ||
| 160 | $footerComInfo = $bTemplateComModel->read($condition); | 160 | $footerComInfo = $bTemplateComModel->read($condition); |
| 161 | if($footerComInfo === false){ | 161 | if($footerComInfo === false){ |
| 162 | //取默认首页的 | 162 | //取默认首页的 |
| 163 | - $footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER]); | 163 | + $footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER,'template_id'=>$template_id]); |
| 164 | if($footerComInfo === false){ | 164 | if($footerComInfo === false){ |
| 165 | $this->fail('获取失败,请联系管理员'); | 165 | $this->fail('获取失败,请联系管理员'); |
| 166 | } | 166 | } |
| @@ -51,33 +51,50 @@ class CustomTemplateLogic extends BaseLogic | @@ -51,33 +51,50 @@ class CustomTemplateLogic extends BaseLogic | ||
| 51 | $this->fail('当前数据不存在'); | 51 | $this->fail('当前数据不存在'); |
| 52 | } | 52 | } |
| 53 | if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ | 53 | if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ |
| 54 | - $html = $this->getTemplateComHtml($info['html'],$info['html_style']); | 54 | + $template_id = $this->getTemplateId(); |
| 55 | + $html = $this->getTemplateComHtml($info['html'],$info['html_style'],$template_id); | ||
| 55 | $info['html'] = $this->getHeadFooter($html); | 56 | $info['html'] = $this->getHeadFooter($html); |
| 56 | } | 57 | } |
| 57 | return $this->success($info); | 58 | return $this->success($info); |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | /** | 61 | /** |
| 62 | + * @remark :获取模版id | ||
| 63 | + * @name :getTemplateId | ||
| 64 | + * @author :lyh | ||
| 65 | + * @method :post | ||
| 66 | + * @time :2023/12/27 10:51 | ||
| 67 | + */ | ||
| 68 | + public function getTemplateId(){ | ||
| 69 | + $bSettingModel = new Setting(); | ||
| 70 | + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']],['id','template_id']); | ||
| 71 | + if($bSettingInfo === false){ | ||
| 72 | + $this->fail('请先设置模板'); | ||
| 73 | + } | ||
| 74 | + return $this->success($bSettingInfo['template_id']); | ||
| 75 | + } | ||
| 76 | + /** | ||
| 61 | * @remark :非定制获取头部+底部 | 77 | * @remark :非定制获取头部+底部 |
| 62 | * @name :getTemplateComHtml | 78 | * @name :getTemplateComHtml |
| 63 | * @author :lyh | 79 | * @author :lyh |
| 64 | * @method :post | 80 | * @method :post |
| 65 | * @time :2024/4/29 16:53 | 81 | * @time :2024/4/29 16:53 |
| 66 | */ | 82 | */ |
| 67 | - public function getTemplateComHtml($html,$html_style){ | 83 | + public function getTemplateComHtml($html,$html_style,$template_id){ |
| 68 | if(empty($html)){ | 84 | if(empty($html)){ |
| 69 | $html = "<main></main>"; | 85 | $html = "<main></main>"; |
| 70 | $html_style = "<style id='globalsojs-styles'></style>"; | 86 | $html_style = "<style id='globalsojs-styles'></style>"; |
| 71 | } | 87 | } |
| 72 | - $headComInfo = $this->getHeadComHtml(['common_type'=>BTemplate::COMMON_HEAD]); | 88 | + $headComInfo = $this->getHeadComHtml(['common_type'=>BTemplate::COMMON_HEAD,'template_id'=>$template_id]); |
| 73 | $bTemplateComModel = new BTemplateCom(); | 89 | $bTemplateComModel = new BTemplateCom(); |
| 74 | $condition['common_type'] = BTemplate::COMMON_OTHER; | 90 | $condition['common_type'] = BTemplate::COMMON_OTHER; |
| 75 | $condition['source'] = $headComInfo['source']; | 91 | $condition['source'] = $headComInfo['source']; |
| 92 | + $condition['template_id'] = $template_id; | ||
| 76 | $otherInfo = $bTemplateComModel->read($condition); | 93 | $otherInfo = $bTemplateComModel->read($condition); |
| 77 | if($otherInfo === false){ | 94 | if($otherInfo === false){ |
| 78 | $this->fail('获取失败,请联系管理员'); | 95 | $this->fail('获取失败,请联系管理员'); |
| 79 | } | 96 | } |
| 80 | - $footerComInfo = $this->getFooterComHtml(); | 97 | + $footerComInfo = $this->getFooterComHtml($template_id); |
| 81 | $commonInfo = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '', | 98 | $commonInfo = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '', |
| 82 | 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? '']; | 99 | 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? '']; |
| 83 | $html = $commonInfo['head_style'].$html_style.$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$html.$commonInfo['footer_html']; | 100 | $html = $commonInfo['head_style'].$html_style.$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$html.$commonInfo['footer_html']; |
| @@ -98,6 +115,7 @@ class CustomTemplateLogic extends BaseLogic | @@ -98,6 +115,7 @@ class CustomTemplateLogic extends BaseLogic | ||
| 98 | $headComInfo = $bTemplateComModel->read($condition); | 115 | $headComInfo = $bTemplateComModel->read($condition); |
| 99 | if($headComInfo === false){ | 116 | if($headComInfo === false){ |
| 100 | //取默认公共的 | 117 | //取默认公共的 |
| 118 | + $template_id = $this->getTemplateId(); | ||
| 101 | $condition['source'] = BTemplate::SOURCE_COM; | 119 | $condition['source'] = BTemplate::SOURCE_COM; |
| 102 | $headComInfo = $bTemplateComModel->read($condition); | 120 | $headComInfo = $bTemplateComModel->read($condition); |
| 103 | if($headComInfo === false){ | 121 | if($headComInfo === false){ |
| @@ -113,12 +131,14 @@ class CustomTemplateLogic extends BaseLogic | @@ -113,12 +131,14 @@ class CustomTemplateLogic extends BaseLogic | ||
| 113 | * @method :post | 131 | * @method :post |
| 114 | * @time :2024/4/29 17:18 | 132 | * @time :2024/4/29 17:18 |
| 115 | */ | 133 | */ |
| 116 | - public function getFooterComHtml(){ | 134 | + public function getFooterComHtml($template_id){ |
| 117 | $bTemplateComModel = new BTemplateCom(); | 135 | $bTemplateComModel = new BTemplateCom(); |
| 136 | + $condition['template_id'] = $template_id; | ||
| 118 | $condition['common_type'] = BTemplate::COMMON_FOOTER; | 137 | $condition['common_type'] = BTemplate::COMMON_FOOTER; |
| 119 | $condition['source'] = $this->getType(BTemplate::COMMON_FOOTER); | 138 | $condition['source'] = $this->getType(BTemplate::COMMON_FOOTER); |
| 120 | $footerComInfo = $bTemplateComModel->read($condition); | 139 | $footerComInfo = $bTemplateComModel->read($condition); |
| 121 | if($footerComInfo === false){ | 140 | if($footerComInfo === false){ |
| 141 | + $template_id = $this->getTemplateId(); | ||
| 122 | //取默认首页的 | 142 | //取默认首页的 |
| 123 | $condition['source'] = BTemplate::SOURCE_COM; | 143 | $condition['source'] = BTemplate::SOURCE_COM; |
| 124 | $footerComInfo = $bTemplateComModel->read($condition); | 144 | $footerComInfo = $bTemplateComModel->read($condition); |
| @@ -57,6 +57,7 @@ class InitHtmlLogic extends BaseLogic | @@ -57,6 +57,7 @@ class InitHtmlLogic extends BaseLogic | ||
| 57 | $html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html']; | 57 | $html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html']; |
| 58 | $html = $this->getHeadFooter($html);//组装数据 | 58 | $html = $this->getHeadFooter($html);//组装数据 |
| 59 | $data['html'] = $html; | 59 | $data['html'] = $html; |
| 60 | + $data['template_id'] = $template_id; | ||
| 60 | return $this->success($data); | 61 | return $this->success($data); |
| 61 | } | 62 | } |
| 62 | 63 | ||
| @@ -71,7 +72,7 @@ class InitHtmlLogic extends BaseLogic | @@ -71,7 +72,7 @@ class InitHtmlLogic extends BaseLogic | ||
| 71 | $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id]; | 72 | $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id]; |
| 72 | $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id); | 73 | $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id); |
| 73 | $bTemplateComModel = new BTemplateCom(); | 74 | $bTemplateComModel = new BTemplateCom(); |
| 74 | - $otherInfo = $bTemplateComModel->read(['source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom']]); | 75 | + $otherInfo = $bTemplateComModel->read(['template_id'=>$template_id,'source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom']]); |
| 75 | if($otherInfo === false){ | 76 | if($otherInfo === false){ |
| 76 | $this->fail('获取失败,请联系管理员2'); | 77 | $this->fail('获取失败,请联系管理员2'); |
| 77 | } | 78 | } |
| @@ -96,7 +97,7 @@ class InitHtmlLogic extends BaseLogic | @@ -96,7 +97,7 @@ class InitHtmlLogic extends BaseLogic | ||
| 96 | $headComInfo = $bTemplateComModel->read($condition); | 97 | $headComInfo = $bTemplateComModel->read($condition); |
| 97 | if($headComInfo === false){ | 98 | if($headComInfo === false){ |
| 98 | //取默认公共的 | 99 | //取默认公共的 |
| 99 | - $headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD]); | 100 | + $headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD,'template_id'=>$template_id]); |
| 100 | if($headComInfo === false){ | 101 | if($headComInfo === false){ |
| 101 | $this->fail('获取失败,请联系管理员1'); | 102 | $this->fail('获取失败,请联系管理员1'); |
| 102 | } | 103 | } |
| @@ -117,7 +118,7 @@ class InitHtmlLogic extends BaseLogic | @@ -117,7 +118,7 @@ class InitHtmlLogic extends BaseLogic | ||
| 117 | $footerComInfo = $bTemplateComModel->read($condition); | 118 | $footerComInfo = $bTemplateComModel->read($condition); |
| 118 | if($footerComInfo === false){ | 119 | if($footerComInfo === false){ |
| 119 | //取默认首页的 | 120 | //取默认首页的 |
| 120 | - $footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER]); | 121 | + $footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER,'template_id'=>$template_id]); |
| 121 | if($footerComInfo === false){ | 122 | if($footerComInfo === false){ |
| 122 | $this->fail('获取失败,请联系管理员3'); | 123 | $this->fail('获取失败,请联系管理员3'); |
| 123 | } | 124 | } |
| @@ -39,7 +39,16 @@ class ExtensionModuleFieldLogic extends BaseLogic | @@ -39,7 +39,16 @@ class ExtensionModuleFieldLogic extends BaseLogic | ||
| 39 | if($info !== false){ | 39 | if($info !== false){ |
| 40 | $this->fail('当前字段名已存在'); | 40 | $this->fail('当前字段名已存在'); |
| 41 | } | 41 | } |
| 42 | - $id = $this->model->addReturnId($this->param); | 42 | + if(isset($this->param['data']) && !empty($this->param['data'])){ |
| 43 | + $this->param['data'] = json_encode($this->param['data']); | ||
| 44 | + } | ||
| 45 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 46 | + $id = $this->param['id']; | ||
| 47 | + $this->model->edit($this->param,['id'=>$id]); | ||
| 48 | + }else{ | ||
| 49 | + $id = $this->model->addReturnId($this->param); | ||
| 50 | + } | ||
| 51 | + | ||
| 43 | return $this->success(['id'=>$id]); | 52 | return $this->success(['id'=>$id]); |
| 44 | } | 53 | } |
| 45 | 54 | ||
| @@ -53,11 +62,11 @@ class ExtensionModuleFieldLogic extends BaseLogic | @@ -53,11 +62,11 @@ class ExtensionModuleFieldLogic extends BaseLogic | ||
| 53 | public function delModuleField(){ | 62 | public function delModuleField(){ |
| 54 | //查看当前字段是否在使用 | 63 | //查看当前字段是否在使用 |
| 55 | $moduleValueModel = new ExtensionModuleValue(); | 64 | $moduleValueModel = new ExtensionModuleValue(); |
| 56 | - $info = $moduleValueModel->read(['filed_id'=>$this->param['filed_id']]); | 65 | + $info = $moduleValueModel->read(['field_id'=>$this->param['field_id']]); |
| 57 | if($info !== false){ | 66 | if($info !== false){ |
| 58 | $this->fail('当前字段正在使用中,不允许删除'); | 67 | $this->fail('当前字段正在使用中,不允许删除'); |
| 59 | } | 68 | } |
| 60 | - $this->model->del(['id'=>$this->param['filed_id']]); | 69 | + $this->model->del(['id'=>$this->param['field_id']]); |
| 61 | return $this->success(); | 70 | return $this->success(); |
| 62 | } | 71 | } |
| 63 | } | 72 | } |
| @@ -182,18 +182,18 @@ class CosService | @@ -182,18 +182,18 @@ class CosService | ||
| 182 | South:底部中间 | 182 | South:底部中间 |
| 183 | SouthEast:右下角 | 183 | SouthEast:右下角 |
| 184 | */ | 184 | */ |
| 185 | - public function addFieldImage($cdnUrl = '',$data = [],$is_image = false){ | 185 | + public function setWatermark($cdnUrl = '',$data = [],$is_image = false){ |
| 186 | $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名 | 186 | $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名 |
| 187 | $url = $domain . $cdnUrl; | 187 | $url = $domain . $cdnUrl; |
| 188 | if($is_image){ | 188 | if($is_image){ |
| 189 | $param = [ | 189 | $param = [ |
| 190 | - 'image/'.$this->urlSafeBase64Encode($domain.$data['image'] ?? ''),//文字水印名称 | 190 | + 'image/'.$this->urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片 |
| 191 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), | 191 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), |
| 192 | 'dx/'.($data['dx'] ?? 0), | 192 | 'dx/'.($data['dx'] ?? 0), |
| 193 | 'dy/'. ($data['dy'] ?? 0), | 193 | 'dy/'. ($data['dy'] ?? 0), |
| 194 | 'batch/'.($data['batch'] ?? 0),//平铺水印功能 | 194 | 'batch/'.($data['batch'] ?? 0),//平铺水印功能 |
| 195 | 'dissolve/'.($data['dissolve'] ?? 50),//透明度 | 195 | 'dissolve/'.($data['dissolve'] ?? 50),//透明度 |
| 196 | - 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0 | 196 | + 'degree/'.($data['degree'] ?? 0),//旋转角度设置,取值范围为0 - 360,默认0 |
| 197 | ]; | 197 | ]; |
| 198 | $url = $url.'?watermark/1/'.implode('/',$param); | 198 | $url = $url.'?watermark/1/'.implode('/',$param); |
| 199 | }else{ | 199 | }else{ |
| @@ -216,13 +216,13 @@ class CosService | @@ -216,13 +216,13 @@ class CosService | ||
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | /** | 218 | /** |
| 219 | - * @remark :添加水印后保存图片(覆盖) | 219 | + * @remark :添加水印后保存图片(覆盖/非覆盖的文件未存入数据库) |
| 220 | * @name :uploadImages | 220 | * @name :uploadImages |
| 221 | * @author :lyh | 221 | * @author :lyh |
| 222 | * @method :post | 222 | * @method :post |
| 223 | * @time :2024/8/19 17:06 | 223 | * @time :2024/8/19 17:06 |
| 224 | */ | 224 | */ |
| 225 | - public function uploadImages($url,$cdnUrl){ | 225 | + public function coverOriginalImage($url,$cdnUrl){ |
| 226 | // 获取水印后的图片内容 | 226 | // 获取水印后的图片内容 |
| 227 | $imageContent = file_get_contents($url); | 227 | $imageContent = file_get_contents($url); |
| 228 | // 使用 COS SDK 将图片重新上传并覆盖原图 | 228 | // 使用 COS SDK 将图片重新上传并覆盖原图 |
app/Services/UpyunService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2024/8/20 | ||
| 6 | + * Time: 11:01 | ||
| 7 | + */ | ||
| 8 | +namespace App\Services; | ||
| 9 | + | ||
| 10 | +class UpyunService | ||
| 11 | +{ | ||
| 12 | + /** | ||
| 13 | + * 刷新进度查询 | ||
| 14 | + * @param $task_id | ||
| 15 | + * @return mixed | ||
| 16 | + */ | ||
| 17 | + public function purgePull($task_id) | ||
| 18 | + { | ||
| 19 | + $action = '/purge'; | ||
| 20 | + if (FALSE == is_array($task_id)) | ||
| 21 | + $task_id = [$task_id]; | ||
| 22 | + $task_ids = implode(',', $task_id); | ||
| 23 | + $param = [ | ||
| 24 | + 'task_ids' => $task_ids, // 需要查询进度的 task_id | ||
| 25 | + ]; | ||
| 26 | + list($status, $result) = $this->curlRequest($action, $param, 'GET', $this->getHeader()); | ||
| 27 | + return $result; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * URL 刷新 | ||
| 32 | + * @param $url | ||
| 33 | + * @return mixed | ||
| 34 | + */ | ||
| 35 | + public function purgePush($url) | ||
| 36 | + { | ||
| 37 | + $action = '/purge'; | ||
| 38 | + if (FALSE == is_array($url)) | ||
| 39 | + $url = [$url]; | ||
| 40 | + $urls = implode(PHP_EOL, $url); | ||
| 41 | + $param = [ | ||
| 42 | + 'bucket' => '', | ||
| 43 | + 'urls' => $urls, // 需要批量刷新的文件 URL,多个 URL 通过换行符分隔 | ||
| 44 | + ]; | ||
| 45 | + list($status, $result) = $this->curlRequest($action, $param, 'POST', $this->getHeader()); | ||
| 46 | + return $result; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * URL 预热 | ||
| 51 | + * @param $url | ||
| 52 | + * @return mixed | ||
| 53 | + */ | ||
| 54 | + public function preheatPush($url) | ||
| 55 | + { | ||
| 56 | + $action = '/preheat'; | ||
| 57 | + if (FALSE == is_array($url)) | ||
| 58 | + $url = [$url]; | ||
| 59 | + $urls = implode(PHP_EOL, $url); | ||
| 60 | + $param = [ | ||
| 61 | + 'bucket' => '', | ||
| 62 | + 'urls' => $urls, // 需要批量刷新的文件 URL,多个 URL 通过换行符分隔 | ||
| 63 | + 'range_bytes' => '' | ||
| 64 | + ]; | ||
| 65 | + list($status, $result) = $this->curlRequest($action, $param, 'POST', $this->getHeader()); | ||
| 66 | + return $result; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 头信息需要携带授权token | ||
| 71 | + * @return array | ||
| 72 | + */ | ||
| 73 | + public function getHeader() | ||
| 74 | + { | ||
| 75 | + return [ | ||
| 76 | + 'Authorization: Bearer ' . config('custom.upyun.token'), | ||
| 77 | + ]; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * @param $url | ||
| 82 | + * @param $data | ||
| 83 | + * @param string $method | ||
| 84 | + * @param array $header | ||
| 85 | + * @param int $time_out | ||
| 86 | + * @return array | ||
| 87 | + */ | ||
| 88 | + public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60) | ||
| 89 | + { | ||
| 90 | + $url = config('custom.upyun.api_url') . $url; | ||
| 91 | + $ch = curl_init(); | ||
| 92 | + curl_setopt($ch, CURLOPT_TIMEOUT, $time_out); | ||
| 93 | + curl_setopt($ch, CURLOPT_URL, $url); | ||
| 94 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
| 95 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | ||
| 96 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); | ||
| 97 | + if ($data) | ||
| 98 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); | ||
| 99 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([ | ||
| 100 | + 'Expect:', | ||
| 101 | + 'Content-type: application/json', | ||
| 102 | + 'Accept: application/json', | ||
| 103 | + ], $header) | ||
| 104 | + ); | ||
| 105 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); | ||
| 106 | + $response = curl_exec($ch); | ||
| 107 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
| 108 | + curl_close($ch); | ||
| 109 | + return [$code, $response]; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * 创建token | ||
| 114 | + * 该功能请不要重复使用 | ||
| 115 | + * 注意:出于安全考虑,token 只有在调用该接口创建时返回一次,后续无法再通过其他接口查询token值,调用该接口后,请务必记录token值 | ||
| 116 | + * {"access_token":"fe64817b-1f32-46f3-9ac3-a2993725708a","name":"v6-66c4333f60644","scope":"global","services":[],"created_at":1724134209,"expired_at":9999999999} | ||
| 117 | + * @return mixed | ||
| 118 | + */ | ||
| 119 | + public function createToken() | ||
| 120 | + { | ||
| 121 | + $action = '/oauth/tokens'; | ||
| 122 | + $param = [ | ||
| 123 | + 'username' => '', // 用户名 | ||
| 124 | + 'password' => '', // 密码 | ||
| 125 | + 'code' => md5(uniqid()), // 20-32位随机字符串,每次请求不能重复。只能包含数字、字母和中划线 | ||
| 126 | + 'name' => 'v6-' . uniqid(), // token 备注名,长度 20 的字符串,不能和其他 token 重复 | ||
| 127 | + 'scope' => 'global', // 权限 Valid Values:'global''bucket''operator''domain''cache''log''stats''oauth''security''srs' | ||
| 128 | +// 'expired_at' => '', // integer token 过期时间的秒级时间戳,当该参数不设置时,表示永不过期 | ||
| 129 | + ]; | ||
| 130 | + list($status, $result) = $this->curlRequest($action, $param); | ||
| 131 | + return $result; | ||
| 132 | + } | ||
| 133 | +} |
| @@ -24,5 +24,10 @@ return [ | @@ -24,5 +24,10 @@ return [ | ||
| 24 | ["69.172.229.12","69.172.229.13","69.172.229.14","69.172.229.15","69.172.229.16","69.172.229.36","69.172.229.59","69.172.229.60","69.172.229.61","69.172.229.62","69.172.229.63","69.172.229.64","69.172.229.65"], | 24 | ["69.172.229.12","69.172.229.13","69.172.229.14","69.172.229.15","69.172.229.16","69.172.229.36","69.172.229.59","69.172.229.60","69.172.229.61","69.172.229.62","69.172.229.63","69.172.229.64","69.172.229.65"], |
| 25 | ["69.172.233.75","69.172.233.76","69.172.233.77","69.172.233.78","69.172.233.79","69.172.233.80","69.172.233.81","69.172.233.82","69.172.233.83","69.172.233.84","69.172.233.85","69.172.233.86","69.172.233.87"], | 25 | ["69.172.233.75","69.172.233.76","69.172.233.77","69.172.233.78","69.172.233.79","69.172.233.80","69.172.233.81","69.172.233.82","69.172.233.83","69.172.233.84","69.172.233.85","69.172.233.86","69.172.233.87"], |
| 26 | ["76.74.220.18","76.74.220.19","76.74.220.20","76.74.220.21","76.74.220.22","76.74.220.23","76.74.220.24","76.74.220.25","76.74.220.26","76.74.220.27","76.74.220.28","76.74.220.29","76.74.220.30"], | 26 | ["76.74.220.18","76.74.220.19","76.74.220.20","76.74.220.21","76.74.220.22","76.74.220.23","76.74.220.24","76.74.220.25","76.74.220.26","76.74.220.27","76.74.220.28","76.74.220.29","76.74.220.30"], |
| 27 | - ["64.34.205.152","64.34.205.170","64.34.205.171","64.34.205.172","64.34.205.173","64.34.205.174","64.34.205.210","64.34.205.211","64.34.205.212","64.34.205.213","64.34.205.214","64.34.205.215","64.34.205.216"]] | 27 | + ["64.34.205.152","64.34.205.170","64.34.205.171","64.34.205.172","64.34.205.173","64.34.205.174","64.34.205.210","64.34.205.211","64.34.205.212","64.34.205.213","64.34.205.214","64.34.205.215","64.34.205.216"]], |
| 28 | + | ||
| 29 | + 'upyun' => [ | ||
| 30 | + 'api_url' => 'https://api.upyun.com', | ||
| 31 | + 'token' => 'fe64817b-1f32-46f3-9ac3-a2993725708a', | ||
| 32 | + ], | ||
| 28 | ]; | 33 | ]; |
| @@ -253,6 +253,8 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -253,6 +253,8 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 253 | //图片操作 | 253 | //图片操作 |
| 254 | Route::prefix('images')->group(function () { | 254 | Route::prefix('images')->group(function () { |
| 255 | Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('images_upload'); | 255 | Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('images_upload'); |
| 256 | + Route::post('/getFont', [\App\Http\Controllers\File\ImageController::class, 'getFont'])->name('images_getFont'); | ||
| 257 | + Route::post('/getPosition', [\App\Http\Controllers\File\ImageController::class, 'getPosition'])->name('images_getPosition'); | ||
| 256 | Route::post('/getDownloadUrl', [\App\Http\Controllers\File\ImageController::class, 'getDownloadUrl'])->name('images_getDownloadUrl'); | 258 | Route::post('/getDownloadUrl', [\App\Http\Controllers\File\ImageController::class, 'getDownloadUrl'])->name('images_getDownloadUrl'); |
| 257 | }); | 259 | }); |
| 258 | //文件操作 | 260 | //文件操作 |
| @@ -316,6 +316,10 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -316,6 +316,10 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 316 | //图片操作 | 316 | //图片操作 |
| 317 | Route::prefix('images')->group(function () { | 317 | Route::prefix('images')->group(function () { |
| 318 | Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('image_upload'); | 318 | Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('image_upload'); |
| 319 | + Route::post('/getFont', [\App\Http\Controllers\File\ImageController::class, 'getFont'])->name('images_getFont'); | ||
| 320 | + Route::post('/getPosition', [\App\Http\Controllers\File\ImageController::class, 'getPosition'])->name('images_getPosition'); | ||
| 321 | + Route::post('/setWatermark', [\App\Http\Controllers\File\ImageController::class, 'setWatermark'])->name('images_setWatermark'); | ||
| 322 | + Route::post('/coverOriginalImage', [\App\Http\Controllers\File\ImageController::class, 'coverOriginalImage'])->name('images_coverOriginalImage'); | ||
| 319 | Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList'); | 323 | Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList'); |
| 320 | }); | 324 | }); |
| 321 | //文件操作 | 325 | //文件操作 |
-
请 注册 或 登录 后发表评论