Merge branch 'master-server' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
9 个修改的文件
包含
229 行增加
和
6 行删除
| @@ -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(){ |
| 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'])){ | ||
| 227 | $uniqueString = md5(time() . rand(1000, 9999)); | 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 | } |
| @@ -514,4 +514,50 @@ class ImageController extends Controller | @@ -514,4 +514,50 @@ class ImageController extends Controller | ||
| 514 | $data = ['image_download'=>url('a/download_images?path='.$info['path']), 'name' => $info['name']]; | 514 | $data = ['image_download'=>url('a/download_images?path='.$info['path']), 'name' => $info['name']]; |
| 515 | $this->response('success',Code::SUCCESS,$data); | 515 | $this->response('success',Code::SUCCESS,$data); |
| 516 | } | 516 | } |
| 517 | + | ||
| 518 | + /** | ||
| 519 | + * @remark :设置图片水印 | ||
| 520 | + * @name :setWatermark | ||
| 521 | + * @author :lyh | ||
| 522 | + * @method :post | ||
| 523 | + * @time :2024/8/21 9:15 | ||
| 524 | + */ | ||
| 525 | + public function setWatermark(){ | ||
| 526 | + $this->request->validate([ | ||
| 527 | + 'url'=>['required'], | ||
| 528 | + 'is_image'=>['required'], | ||
| 529 | + ],[ | ||
| 530 | + 'url.required'=>'请填写需要处理图片的相对路径', | ||
| 531 | + 'is_image.required'=>'请设置文本水印还是图片水印', | ||
| 532 | + ]); | ||
| 533 | + $cos = new CosService(); | ||
| 534 | + $url = $cos->setWatermark($this->param['url'], $this->param['data'],true); | ||
| 535 | + $this->response('success',Code::SUCCESS,['url'=>$url]); | ||
| 536 | + } | ||
| 537 | + | ||
| 538 | + /** | ||
| 539 | + * @remark :获取字体 | ||
| 540 | + * @name :getFont | ||
| 541 | + * @author :lyh | ||
| 542 | + * @method :post | ||
| 543 | + * @time :2024/8/21 9:47 | ||
| 544 | + */ | ||
| 545 | + public function getFont(){ | ||
| 546 | + $cos = new CosService(); | ||
| 547 | + $data = $cos->getFont(); | ||
| 548 | + $this->response('success',Code::SUCCESS,$data); | ||
| 549 | + } | ||
| 550 | + | ||
| 551 | + /** | ||
| 552 | + * @remark :处理9宫格数据 | ||
| 553 | + * @name :getPosition | ||
| 554 | + * @author :lyh | ||
| 555 | + * @method :post | ||
| 556 | + * @time :2024/8/21 9:47 | ||
| 557 | + */ | ||
| 558 | + public function getPosition(){ | ||
| 559 | + $cos = new CosService(); | ||
| 560 | + $data = $cos->getPosition(); | ||
| 561 | + $this->response('success',Code::SUCCESS,$data); | ||
| 562 | + } | ||
| 517 | } | 563 | } |
| @@ -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 | ||
| @@ -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,6 +39,9 @@ class ExtensionModuleFieldLogic extends BaseLogic | @@ -39,6 +39,9 @@ class ExtensionModuleFieldLogic extends BaseLogic | ||
| 39 | if($info !== false){ | 39 | if($info !== false){ |
| 40 | $this->fail('当前字段名已存在'); | 40 | $this->fail('当前字段名已存在'); |
| 41 | } | 41 | } |
| 42 | + if(isset($this->param['data']) && !empty($this->param['data'])){ | ||
| 43 | + $this->param['data'] = json_encode($this->param['data']); | ||
| 44 | + } | ||
| 42 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 45 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 43 | $id = $this->param['id']; | 46 | $id = $this->param['id']; |
| 44 | $this->model->edit($this->param,['id'=>$id]); | 47 | $this->model->edit($this->param,['id'=>$id]); |
| @@ -59,11 +62,11 @@ class ExtensionModuleFieldLogic extends BaseLogic | @@ -59,11 +62,11 @@ class ExtensionModuleFieldLogic extends BaseLogic | ||
| 59 | public function delModuleField(){ | 62 | public function delModuleField(){ |
| 60 | //查看当前字段是否在使用 | 63 | //查看当前字段是否在使用 |
| 61 | $moduleValueModel = new ExtensionModuleValue(); | 64 | $moduleValueModel = new ExtensionModuleValue(); |
| 62 | - $info = $moduleValueModel->read(['filed_id'=>$this->param['filed_id']]); | 65 | + $info = $moduleValueModel->read(['field_id'=>$this->param['field_id']]); |
| 63 | if($info !== false){ | 66 | if($info !== false){ |
| 64 | $this->fail('当前字段正在使用中,不允许删除'); | 67 | $this->fail('当前字段正在使用中,不允许删除'); |
| 65 | } | 68 | } |
| 66 | - $this->model->del(['id'=>$this->param['filed_id']]); | 69 | + $this->model->del(['id'=>$this->param['field_id']]); |
| 67 | return $this->success(); | 70 | return $this->success(); |
| 68 | } | 71 | } |
| 69 | } | 72 | } |
| @@ -182,7 +182,7 @@ class CosService | @@ -182,7 +182,7 @@ 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){ |
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,9 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -316,6 +316,9 @@ 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'); | ||
| 319 | Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList'); | 322 | Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList'); |
| 320 | }); | 323 | }); |
| 321 | //文件操作 | 324 | //文件操作 |
-
请 注册 或 登录 后发表评论