作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\type; 6 use App\Http\Controllers\type;
7 use App\Http\Controllers\统一返回参数; 7 use App\Http\Controllers\统一返回参数;
8 use App\Models\File\Image as ImageModel; 8 use App\Models\File\Image as ImageModel;
  9 +use App\Models\User\User as UserModel;
9 use Illuminate\Http\Exceptions\HttpResponseException; 10 use Illuminate\Http\Exceptions\HttpResponseException;
10 use Illuminate\Http\JsonResponse; 11 use Illuminate\Http\JsonResponse;
11 use Illuminate\Support\Facades\Storage; 12 use Illuminate\Support\Facades\Storage;
@@ -24,6 +25,8 @@ class ImageController @@ -24,6 +25,8 @@ class ImageController
24 'Content-Description' => 'File Transfer', 25 'Content-Description' => 'File Transfer',
25 ], 26 ],
26 ]; 27 ];
  28 + const TYPE = 1;
  29 +
27 public $path = ''; 30 public $path = '';
28 31
29 public $config = ''; 32 public $config = '';
@@ -39,7 +42,7 @@ class ImageController @@ -39,7 +42,7 @@ class ImageController
39 $this->path = $this->config['root']; 42 $this->path = $this->config['root'];
40 } 43 }
41 44
42 - public function index($hash = '', $w = 0 ,$h = 0){ 45 + public function index($hash = '',$type = self::TYPE, $w = 0 ,$h = 0 ){
43 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { 46 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
44 header("HTTP/1.1 304 Not Modified"); 47 header("HTTP/1.1 304 Not Modified");
45 exit; 48 exit;
@@ -50,6 +53,7 @@ class ImageController @@ -50,6 +53,7 @@ class ImageController
50 $this->response('指定图片不存在!', Code::USER_ERROR); 53 $this->response('指定图片不存在!', Code::USER_ERROR);
51 } 54 }
52 //查看缩略图是否存在 55 //查看缩略图是否存在
  56 +// $header['Content-Type'] = 'image/'.$info['type'];
53 $filename = $this->path . $info['hash'] . $w . '_' . $h; 57 $filename = $this->path . $info['hash'] . $w . '_' . $h;
54 if(is_file($filename)){ 58 if(is_file($filename)){
55 $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; 59 $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
@@ -78,7 +82,12 @@ class ImageController @@ -78,7 +82,12 @@ class ImageController
78 $img_type = $info['type']; 82 $img_type = $info['type'];
79 $content = base64_encode($content); 83 $content = base64_encode($content);
80 $img_base64 = 'data:image/' . $img_type . ';base64,' . $content; 84 $img_base64 = 'data:image/' . $img_type . ';base64,' . $content;
81 - return response($img_base64, 200, $header); 85 + if($type != self::TYPE){
  86 + header('Content-Type: image/' . $img_type);
  87 + echo base64_decode($content);
  88 + exit;
  89 + }
  90 + return response($img_base64,200,$header);
82 } 91 }
83 92
84 /** 93 /**
@@ -114,7 +123,7 @@ class ImageController @@ -114,7 +123,7 @@ class ImageController
114 $imageModel = new ImageModel(); 123 $imageModel = new ImageModel();
115 $image_hash = $imageModel->read(['hash'=>$hash]); 124 $image_hash = $imageModel->read(['hash'=>$hash]);
116 if($image_hash !== false){ 125 if($image_hash !== false){
117 - return $hash; 126 + return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
118 } 127 }
119 $url = $this->path; 128 $url = $this->path;
120 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); 129 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
@@ -133,7 +142,7 @@ class ImageController @@ -133,7 +142,7 @@ class ImageController
133 if ($rs === false) { 142 if ($rs === false) {
134 return $this->response('添加失败', Code::USER_ERROR); 143 return $this->response('添加失败', Code::USER_ERROR);
135 } 144 }
136 - return $hash; 145 + return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
137 } 146 }
138 /** 147 /**
139 * 生成缩略图缓存 148 * 生成缩略图缓存
@@ -186,7 +195,7 @@ class ImageController @@ -186,7 +195,7 @@ class ImageController
186 $data[] = $hash; 195 $data[] = $hash;
187 } 196 }
188 $imageModel->insert($save_data); 197 $imageModel->insert($save_data);
189 - return $data; 198 + return $this->response('图片资源',Code::SUCCESS,['image'=>$data]);
190 } 199 }
191 200
192 //下载 201 //下载
@@ -206,10 +215,50 @@ class ImageController @@ -206,10 +215,50 @@ class ImageController
206 $result = [ 215 $result = [
207 'msg' => $msg == ' ' ? $code->description : $msg, 216 'msg' => $msg == ' ' ? $code->description : $msg,
208 'code' => $code->value, 217 'code' => $code->value,
209 - 'data' => $data, 218 + 'data' => $this->_extents($data),
210 ]; 219 ];
211 $this->header['Content-Type'] = $type; 220 $this->header['Content-Type'] = $type;
212 $response = response($result,$result_code,$this->header); 221 $response = response($result,$result_code,$this->header);
213 throw new HttpResponseException($response); 222 throw new HttpResponseException($response);
214 } 223 }
  224 +
  225 + /**
  226 + * @param $data
  227 + * @name :返回参数处理
  228 + * @return array|string
  229 + * @author :liyuhang
  230 + * @method
  231 + */
  232 + protected function _extents($data) {
  233 +
  234 + if (empty($data) || !is_array($data)) {
  235 + return empty($data) ? is_array($data) ? [] : '' : $data;
  236 + }
  237 + foreach ($data as $k => $v) {
  238 + if (is_array($v)) {
  239 + $data[$k] = $this->_extents($v);
  240 + } else {
  241 + if (is_null($v)) {
  242 + $data[$k] = '';
  243 + continue;
  244 + }
  245 + //获取操作人
  246 + switch ((string) $k) {
  247 + case 'image':
  248 + $data['image_link'] = url('/b/image/' . $v);
  249 + break;
  250 + case 'images':
  251 + $v = explode(',',$v);
  252 + foreach ($v as $k1=>$v1){
  253 + $data['images_link'][$k1] = url('/b/image/' . $v1);
  254 + }
  255 + break;
  256 + case 'file':
  257 + $data['file_link'] = url('/b/file_hash/' . $v);
  258 + break;
  259 + }
  260 + }
  261 + }
  262 + return $data;
  263 + }
215 } 264 }
@@ -47,7 +47,7 @@ class WebSettingFromLogic extends BaseLogic @@ -47,7 +47,7 @@ class WebSettingFromLogic extends BaseLogic
47 $this->param['data'][$k] = $v; 47 $this->param['data'][$k] = $v;
48 } 48 }
49 //新增 49 //新增
50 - $this->model->add_all($this->param['data']); 50 + $this->model->insert($this->param['data']);
51 }catch (\Exception $e){ 51 }catch (\Exception $e){
52 $this->fail('error'); 52 $this->fail('error');
53 } 53 }
@@ -41,7 +41,7 @@ class WebSettingReceivingLogic extends BaseLogic @@ -41,7 +41,7 @@ class WebSettingReceivingLogic extends BaseLogic
41 $v['updated_at'] = date('Y-m-d H:i:s'); 41 $v['updated_at'] = date('Y-m-d H:i:s');
42 $this->param['data'][$k] = $v; 42 $this->param['data'][$k] = $v;
43 } 43 }
44 - $this->model->add_all($this->param['data']); 44 + $this->model->insert($this->param['data']);
45 }catch (\Exception $e){ 45 }catch (\Exception $e){
46 $this->fail('error'); 46 $this->fail('error');
47 } 47 }
@@ -36,7 +36,8 @@ class WebSettingServiceLogic extends BaseLogic @@ -36,7 +36,8 @@ class WebSettingServiceLogic extends BaseLogic
36 * @time :2023/5/4 11:10 36 * @time :2023/5/4 11:10
37 */ 37 */
38 public function setting_service_save(){ 38 public function setting_service_save(){
39 -// try { 39 + DB::beginTransaction();
  40 + try {
40 $this->param['data'] = Common::uniqueMultiArray($this->param['data']); 41 $this->param['data'] = Common::uniqueMultiArray($this->param['data']);
41 //删除以前的数据 42 //删除以前的数据
42 $this->model->del(['project_id'=>$this->user['project_id']]); 43 $this->model->del(['project_id'=>$this->user['project_id']]);
@@ -46,10 +47,12 @@ class WebSettingServiceLogic extends BaseLogic @@ -46,10 +47,12 @@ class WebSettingServiceLogic extends BaseLogic
46 $v['updated_at'] = date('Y-m-d H:i:s'); 47 $v['updated_at'] = date('Y-m-d H:i:s');
47 $this->param['data'][$k] = $v; 48 $this->param['data'][$k] = $v;
48 } 49 }
49 - $this->model->add_all($this->param['data']);  
50 -// }catch (\Exception $e){  
51 -// $this->fail('error');  
52 -// } 50 + $this->model->insert($this->param['data']);
  51 + DB::commit();
  52 + }catch (\Exception $e){
  53 + DB::rollBack();
  54 + $this->fail('error');
  55 + }
53 return $this->success(); 56 return $this->success();
54 } 57 }
55 } 58 }
@@ -66,10 +66,12 @@ class WebSettingTextLogic extends BaseLogic @@ -66,10 +66,12 @@ class WebSettingTextLogic extends BaseLogic
66 $web_setting->edit($data,['project_id'=>$this->user['project_id']]); 66 $web_setting->edit($data,['project_id'=>$this->user['project_id']]);
67 $this->model->del(['project_id'=>$this->user['project_id']]); 67 $this->model->del(['project_id'=>$this->user['project_id']]);
68 foreach ($this->param['data'] as $k => $v){ 68 foreach ($this->param['data'] as $k => $v){
  69 + $v['created_at'] = date('Y-m-d H:i:s');
  70 + $v['updated_at'] = date('Y-m-d H:i:s');
69 $v['project_id'] = $this->user['project_id']; 71 $v['project_id'] = $this->user['project_id'];
70 $this->param['data'][$k] = $v; 72 $this->param['data'][$k] = $v;
71 } 73 }
72 - $this->model->add_all($this->param['data']); 74 + $this->model->insert($this->param['data']);
73 DB::commit(); 75 DB::commit();
74 }catch (\Exception $e){ 76 }catch (\Exception $e){
75 DB::rollBack(); 77 DB::rollBack();
@@ -114,16 +114,6 @@ class Base extends Model @@ -114,16 +114,6 @@ class Base extends Model
114 } 114 }
115 115
116 /** 116 /**
117 - * @name :(获取数据条数)count  
118 - * @author :lyh  
119 - * @method :post  
120 - * @time :2023/5/8 15:51  
121 - */  
122 - public function get_count($condition){  
123 - $query = $this->formatQuery($condition);  
124 - $query->count();  
125 - }  
126 - /**  
127 * @name :新增 117 * @name :新增
128 * @return void 118 * @return void
129 * @author :liyuhang 119 * @author :liyuhang
@@ -136,15 +126,6 @@ class Base extends Model @@ -136,15 +126,6 @@ class Base extends Model
136 } 126 }
137 127
138 /** 128 /**
139 - * @name :(批量插入(data二维数组))add_all  
140 - * @author :lyh  
141 - * @method :post  
142 - * @time :2023/5/8 17:41  
143 - */  
144 - public function add_all($data){  
145 - return $this->insert($data);  
146 - }  
147 - /**  
148 * @name :编辑 129 * @name :编辑
149 * @return void 130 * @return void
150 * @author :liyuhang 131 * @author :liyuhang
@@ -252,6 +252,6 @@ Route::group([], function () { @@ -252,6 +252,6 @@ Route::group([], function () {
252 Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); 252 Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login');
253 // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); 253 // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
254 Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); 254 Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
255 - Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show'); 255 + Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
256 Route::any('/file_hash/{hash}', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show'); 256 Route::any('/file_hash/{hash}', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
257 }); 257 });