作者 刘锟

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

... ... @@ -55,13 +55,13 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[1535]]]);
$list = $projectModel->list(['id'=>['in',[1155]]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
// $this->getProduct();
$this->setProductKeyword();
$this->getProduct();
// $this->setProductKeyword();
// $this->getBlog();
DB::disconnect('custom_mysql');
}
... ...
... ... @@ -926,6 +926,28 @@ function base62_encode($num) {
return $result;
}
/**
* @remark :腾讯云安全的base64
* @name :urlSafeBase64Encode
* @author :lyh
* @method :post
* @time :2024/8/19 14:21
*/
function urlSafeBase64Encode($data = '') {
if(empty($data)){
return $data;
}
// 1. 使用标准的 BASE64 编码
$base64 = base64_encode($data);
// 2. 将加号(+)替换成连接号(-)
$base64 = str_replace('+', '-', $base64);
// 3. 将正斜线(/)替换成下划线(_)
$base64 = str_replace('/', '_', $base64);
// 4. 去掉末尾的等号(=)
$base64 = rtrim($base64, '=');
return $base64;
}
... ...
... ... @@ -47,7 +47,8 @@ class ExtensionModuleController extends BaseController
'3'=>'图片框',
'4'=>'文件框',
'5'=>'下拉框',
'6'=>'自动生成订单框'
'6'=>'自动生成订单框',
'7'=>'创建时间'
];
$this->response('success',Code::SUCCESS,$data);
}
... ... @@ -328,4 +329,24 @@ class ExtensionModuleController extends BaseController
$moduleFieldModel->edit(['is_search'=>1],['id'=>['in',$this->param['id']]]);
$this->response('success');
}
/**
* @remark :删除数据
* @name :delExtensionValue
* @author :lyh
* @method :post
* @time :2024/8/26 14:25
*/
public function delExtensionValue(){
$this->request->validate([
'module_id'=>'required',
'uuid'=>'required',
],[
'module_id.required' => '模块id不能为空',
'uuid.required' => '字段id不能为空',
]);
$moduleValueModel = new ExtensionModuleValue();
$moduleValueModel->del(['module_id'=>$this->param['module_id'],'uuid'=>$this->param['uuid']]);
$this->response('success');
}
}
... ...
... ... @@ -147,7 +147,14 @@ class FileController
*/
public function synchronizationFile($fileName,$location){
//同步到大文件
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
$file_path = $this->getUrl($this->path.'/'.$fileName, 0,$location);
$headers = get_headers($file_path, 1);
if (strpos($headers[0], '200') === false) {
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}else{
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
}
return true;
}
... ...
... ... @@ -10,6 +10,7 @@ use App\Jobs\CopyProjectJob;
use App\Jobs\SyncImageFileJob;
use App\Models\File\ErrorFile;
use App\Models\File\Image as ImageModel;
use App\Models\File\ImageSetting;
use App\Models\File\WatermarkImage;
use App\Models\Project\Project;
use App\Services\AmazonS3Service;
... ... @@ -339,8 +340,9 @@ class ImageController extends Controller
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
//同步数据到cos
if($this->upload_location == 0){
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
$cosService = new CosService();
$cosService->uploadFile($file,$this->path,$fileName);
$cosService->uploadFile($file,$this->path,$fileName,$watermarkOptions);
}else{
//TODO::上传亚马逊
$amazonS3Service = new AmazonS3Service();
... ... @@ -356,6 +358,47 @@ class ImageController extends Controller
}
/**
* @remark :获取图片配置
* @name :getProjectConfig
* @author :lyh
* @method :post
* @time :2024/8/24 11:03
*/
public function getProjectConfig($project_id = 0){
$imageSettingModel = new ImageSetting();
$settingInfo = $imageSettingModel->read(['project_id'=>$project_id]);
if($settingInfo !== false){
if($settingInfo['status'] == 1 && !empty($settingInfo['image_data'])){
$image_data = json_decode($settingInfo['image_data'],true);
foreach ($image_data as $k => $v){
$arr = implode('/',$v);
if ($arr[0] == 'image') {
$arr[1] = urlSafeBase64Encode($arr[1]);
}
$image_data[$k] = $v;
}
}
if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){
$str_data = json_decode($settingInfo['str_data'],true);
foreach ($str_data as $k => $v){
$arr = implode('/',$v);
if ($arr[0] == 'text') {
$arr[1] = urlSafeBase64Encode($arr[1]);
}
if ($arr[0] == 'font') {
$arr[1] = urlSafeBase64Encode($arr[1]);
}
if ($arr[0] == 'fill') {
$arr[1] = urlSafeBase64Encode($arr[1]);
}
$str_data[$k] = $arr;
}
}
}
return null;
}
/**
* @param $filename
* @remark :下载
* @name :download
... ... @@ -606,4 +649,111 @@ class ImageController extends Controller
];
return $watermarkImageModel->addReturnId($data);
}
/**
* @remark :设置请求参数
* @name :setInputParam
* @author :lyh
* @method :post
* @time :2024/8/24 10:31
*/
public function saveInputParam(){
$this->request->validate([
'data'=>['required'],
'is_image'=>['required'],
],[
'data.required'=>'数据',
'is_image.required'=>'请设置文本水印还是图片水印',
]);
$data = $this->param['data'];
$is_image = $this->param['is_image'];
$imageSetting = new ImageSetting();
$info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
$domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名
if($is_image){
$param = [
'image/'.$domain.($data['image'] ?? ''),//图片
'gravity/'.($data['gravity'] ?? 'SouthEast'),
'dx/'.($data['dx'] ?? 0),
'dy/'. ($data['dy'] ?? 0),
'batch/'.($data['batch'] ?? 0),//平铺水印功能
'dissolve/'.($data['dissolve'] ?? 50),//透明度
'degree/'.($data['degree'] ?? 0),//旋转角度设置,取值范围为0 - 360,默认0
];
if($info === false){
$imageSetting->add(['image_data'=>json_encode($param,true),'project_id'=>$this->cache['project_id']]);
}else{
$imageSetting->edit(['image_data'=>json_encode($param,true)],['project_id'=>$this->cache['project_id']]);
}
}else{
$param = [
'text/'.($data['text'] ?? ''),//文字水印名称
'gravity/'.($data['gravity'] ?? 'SouthEast'),
'dx/'.($data['dx'] ?? 10),
'dy/'. ($data['dy'] ?? 10),
'font/'.($data['font'] ?? 'tahoma.ttf'),//默认宋体
'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13
'fill/'.($data['fill'] ?? '#3D3D3D'),//颜色
'dissolve/'.($data['dissolve'] ?? 50),//透明度
'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0
'batch/'.($data['batch'] ?? 0),//平铺水印功能
'shadow/'.($data['shadow'] ?? 0),//文字阴影效果,有效值为[0,100],默认为0,表示无阴影
];
if($info === false){
$imageSetting->add(['str_data'=>json_encode($param,true),'project_id'=>$this->cache['project_id']]);
}else{
$imageSetting->edit(['str_data'=>json_encode($param,true)],['project_id'=>$this->cache['project_id']]);
}
}
$this->response('success');
}
/**
* @remark :修改水印配置状态
* @name :editStatus
* @author :lyh
* @method :post
* @time :2024/8/24 11:14
*/
public function editStatus(){
$this->request->validate([
'status'=>'required',
],[
'status.required'=>'状态',
]);
$imageSetting = new ImageSetting();
$info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
if($info === false){
$this->response('请先设置水印',Code::SYSTEM_ERROR);
}
if($info['status'] == 1 && !empty($info['image_data'])){
$this->response('请先设置水印',Code::SYSTEM_ERROR);
}
if($info['status'] == 2 && !empty($info['str_data'])){
$this->response('请先设置水印',Code::SYSTEM_ERROR);
}
$imageSetting->edit(['status'=>$this->param['status']],['project_id'=>$this->cache['project_id']]);
$this->response('success');
}
/**
* @remark :获取配置
* @name :getImageSetting
* @author :lyh
* @method :post
* @time :2024/8/24 11:41
*/
public function getImageSetting(){
$imageSetting = new ImageSetting();
$info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
if($info !== false){
if(!empty($info['image_data'])){
$info['image_data'] = json_decode($info['image_data'],true);
}
if(!empty($info['str_data'])){
$info['str_data'] = json_decode($info['str_data'],true);
}
}
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
<?php
/**
* @remark :
* @name :ImageSetting.php
* @author :lyh
* @method :post
* @time :2024/8/24 10:07
*/
namespace App\Models\File;
use App\Models\Base;
class ImageSetting extends Base
{
protected $table = 'gl_image_setting';
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Services;
use App\Exceptions\InquiryFilterException;
use App\Models\File\ImageSetting;
use App\Utils\LogUtils;
use Qcloud\Cos\Client;
/**
... ... @@ -46,7 +47,7 @@ class CosService
'rules' => [
[
'fileid' => $filename, // 使用相同的文件名保存
'rule' => $watermarkOptions,
'rule' => 'watermark/1/'.implode('/',$watermarkOptions),
]
]
]);
... ... @@ -187,7 +188,7 @@ class CosService
$url = $domain . $cdnUrl;
if($is_image){
$param = [
'image/'.$this->urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片
'image/'.urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片
'gravity/'.($data['gravity'] ?? 'SouthEast'),
'dx/'.($data['dx'] ?? 0),
'dy/'. ($data['dy'] ?? 0),
... ... @@ -198,13 +199,13 @@ class CosService
$url = $url.'?watermark/1/'.implode('/',$param);
}else{
$param = [
'text/'.$this->urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称
'text/'.urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称
'gravity/'.($data['gravity'] ?? 'SouthEast'),
'dx/'.($data['dx'] ?? 10),
'dy/'. ($data['dy'] ?? 10),
'font/'.$this->urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体
'font/'.urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体
'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13
'fill/'.$this->urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色
'fill/'.urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色
'dissolve/'.($data['dissolve'] ?? 50),//透明度
'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0
'batch/'.($data['batch'] ?? 0),//平铺水印功能
... ... @@ -215,6 +216,8 @@ class CosService
return $url;
}
/**
* @remark :添加水印后保存图片(覆盖/非覆盖的文件未存入数据库)
* @name :uploadImages
... ... @@ -244,28 +247,6 @@ class CosService
}
/**
* @remark :腾讯云安全的base64
* @name :urlSafeBase64Encode
* @author :lyh
* @method :post
* @time :2024/8/19 14:21
*/
public function urlSafeBase64Encode($data = '') {
if(empty($data)){
return $data;
}
// 1. 使用标准的 BASE64 编码
$base64 = base64_encode($data);
// 2. 将加号(+)替换成连接号(-)
$base64 = str_replace('+', '-', $base64);
// 3. 将正斜线(/)替换成下划线(_)
$base64 = str_replace('/', '_', $base64);
// 4. 去掉末尾的等号(=)
$base64 = rtrim($base64, '=');
return $base64;
}
/**
* @remark :处理9宫格数据
* @name :getPosition
* @author :lyh
... ...
... ... @@ -323,6 +323,9 @@ Route::middleware(['bloginauth'])->group(function () {
Route::post('/setWatermark', [\App\Http\Controllers\File\ImageController::class, 'setWatermark'])->name('images_setWatermark');
Route::post('/coverOriginalImage', [\App\Http\Controllers\File\ImageController::class, 'coverOriginalImage'])->name('images_coverOriginalImage');
Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList');
Route::any('/saveInputParam', [\App\Http\Controllers\File\ImageController::class, 'saveInputParam'])->name('image_saveInputParam');
Route::any('/editStatus', [\App\Http\Controllers\File\ImageController::class, 'editStatus'])->name('image_editStatus');
Route::any('/getImageSetting', [\App\Http\Controllers\File\ImageController::class, 'getImageSetting'])->name('image_getImageSetting');
});
//文件操作
Route::prefix('files')->group(function () {
... ... @@ -587,6 +590,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/getFieldType', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'getFieldType'])->name('extension_module_getFieldType');
Route::any('/setSort', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'setSort'])->name('extension_module_setSort');
Route::any('/setSearchParam', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'setSearchParam'])->name('extension_module_setSearchParam');
Route::any('/delExtensionValue', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'delExtensionValue'])->name('extension_module_delExtensionValue');
});
//自定义小语种文本信息
... ...