合并分支 'lyh-server' 到 'master'
gx 查看合并请求 !1944
正在显示
1 个修改的文件
包含
42 行增加
和
2 行删除
| @@ -52,6 +52,7 @@ class CropImage extends Command | @@ -52,6 +52,7 @@ class CropImage extends Command | ||
| 52 | * @time :2025/5/8 9:21 | 52 | * @time :2025/5/8 9:21 |
| 53 | */ | 53 | */ |
| 54 | public function _keywordAction($project_id){ | 54 | public function _keywordAction($project_id){ |
| 55 | + $resData = []; | ||
| 55 | //聚合页裁剪 | 56 | //聚合页裁剪 |
| 56 | $data = $this->getKeywordImage($project_id); | 57 | $data = $this->getKeywordImage($project_id); |
| 57 | $cosService = new CosService(); | 58 | $cosService = new CosService(); |
| @@ -70,11 +71,15 @@ class CropImage extends Command | @@ -70,11 +71,15 @@ class CropImage extends Command | ||
| 70 | if(empty($result)){ | 71 | if(empty($result)){ |
| 71 | continue; | 72 | continue; |
| 72 | } | 73 | } |
| 74 | + $resData[] = $result['path']; | ||
| 73 | $this->saveMysql($project_id,$result['size'],$result['type'],$result['path'],$result['mime']); | 75 | $this->saveMysql($project_id,$result['size'],$result['type'],$result['path'],$result['mime']); |
| 76 | + }else{ | ||
| 77 | + $resData[] = $image; | ||
| 74 | } | 78 | } |
| 75 | } | 79 | } |
| 76 | } | 80 | } |
| 77 | - return $data; | 81 | + $this->saveAggregationSetting($project_id,$resData); |
| 82 | + return $resData; | ||
| 78 | } | 83 | } |
| 79 | 84 | ||
| 80 | /** | 85 | /** |
| @@ -104,9 +109,38 @@ class CropImage extends Command | @@ -104,9 +109,38 @@ class CropImage extends Command | ||
| 104 | return true; | 109 | return true; |
| 105 | } | 110 | } |
| 106 | $this->saveMysql($project_id,$result['size'],$result['type'],$result['path'],$result['mime']); | 111 | $this->saveMysql($project_id,$result['size'],$result['type'],$result['path'],$result['mime']); |
| 112 | + $webSettingImageModel = new WebSettingImage(); | ||
| 113 | + $webSettingImageModel->edit(['image'=>$result['path']],['project_id' => $project_id, 'type' => 4]); | ||
| 114 | + } | ||
| 115 | + return true; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + /** | ||
| 119 | + * @remark :保存数据 | ||
| 120 | + * @name :saveAggregationSetting | ||
| 121 | + * @author :lyh | ||
| 122 | + * @method :post | ||
| 123 | + * @time :2025/5/8 16:24 | ||
| 124 | + */ | ||
| 125 | + public function saveAggregationSetting($project_id,$data){ | ||
| 126 | + if(empty($data)){ | ||
| 127 | + return true; | ||
| 128 | + } | ||
| 129 | + //存全路径 | ||
| 130 | + foreach ($data as $key => $val){ | ||
| 131 | + $val = getImageUrl($val); | ||
| 132 | + $data[$key] = $val; | ||
| 133 | + } | ||
| 134 | + $webSettingImageModel = new WebSettingImage(); | ||
| 135 | + $info = $webSettingImageModel->read(['project_id'=>$project_id]); | ||
| 136 | + if($info === false){ | ||
| 137 | + $webSettingImageModel->addReturnId(['project_id'=>$project_id,'top_banner'=>json_encode($data,true)]); | ||
| 138 | + }else{ | ||
| 139 | + $webSettingImageModel->edit(['top_banner'=>json_encode($data,true)],['id'=>$info['id']]); | ||
| 107 | } | 140 | } |
| 108 | return true; | 141 | return true; |
| 109 | } | 142 | } |
| 143 | + | ||
| 110 | /** | 144 | /** |
| 111 | * @remark :获取aiBlog图片 | 145 | * @remark :获取aiBlog图片 |
| 112 | * @name :getAiBlogImage | 146 | * @name :getAiBlogImage |
| @@ -192,7 +226,9 @@ class CropImage extends Command | @@ -192,7 +226,9 @@ class CropImage extends Command | ||
| 192 | * @time :2025/5/8 14:59 | 226 | * @time :2025/5/8 14:59 |
| 193 | */ | 227 | */ |
| 194 | public function saveMysql($project_id,$size,$image_type,$path,$mime = ''){ | 228 | public function saveMysql($project_id,$size,$image_type,$path,$mime = ''){ |
| 229 | + $hash = hash_file('sha256', $path); | ||
| 195 | $imageModel = new Image(); | 230 | $imageModel = new Image(); |
| 231 | + $info = $imageModel->read(['hash'=>$hash,'project_id'=>$project_id]); | ||
| 196 | $data = [ | 232 | $data = [ |
| 197 | 'path' => $path, | 233 | 'path' => $path, |
| 198 | 'size' => $size, | 234 | 'size' => $size, |
| @@ -204,7 +240,11 @@ class CropImage extends Command | @@ -204,7 +240,11 @@ class CropImage extends Command | ||
| 204 | 'name'=>basename($path), | 240 | 'name'=>basename($path), |
| 205 | 'en_name'=>basename($path) | 241 | 'en_name'=>basename($path) |
| 206 | ]; | 242 | ]; |
| 207 | - $imageModel->addReturnId($data); | 243 | + if($info === false){ |
| 244 | + $imageModel->addReturnId($data); | ||
| 245 | + }else{ | ||
| 246 | + $imageModel->edit($data,['id'=>$info['id']]); | ||
| 247 | + } | ||
| 208 | return true; | 248 | return true; |
| 209 | } | 249 | } |
| 210 | 250 |
-
请 注册 或 登录 后发表评论