作者 lyh

Merge branch 'dev' into develop

@@ -41,6 +41,15 @@ class ImageController @@ -41,6 +41,15 @@ class ImageController
41 $this->path = $this->config['root'].$this->uploads['path'].'/'; 41 $this->path = $this->config['root'].$this->uploads['path'].'/';
42 } 42 }
43 43
  44 + /**
  45 + * @param $hash
  46 + * @param $w
  47 + * @param $h
  48 + * @name :index
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2023/5/11 17:19
  52 + */
44 public function index($hash = '', $w = 0 ,$h = 0 ){ 53 public function index($hash = '', $w = 0 ,$h = 0 ){
45 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { 54 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
46 header("HTTP/1.1 304 Not Modified"); 55 header("HTTP/1.1 304 Not Modified");
@@ -58,7 +67,7 @@ class ImageController @@ -58,7 +67,7 @@ class ImageController
58 $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], 67 $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],
59 [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']); 68 [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']);
60 $content = file_get_contents($filename); 69 $content = file_get_contents($filename);
61 - $header['Content-Length'] = $info['size']; 70 + $header['Content-Length'] = strlen($content);
62 }else{ 71 }else{
63 $path = $info['path']; 72 $path = $info['path'];
64 if (!is_file($path)) { 73 if (!is_file($path)) {
@@ -78,10 +87,7 @@ class ImageController @@ -78,10 +87,7 @@ class ImageController
78 } 87 }
79 } 88 }
80 $header['Content-Type'] = 'image/'.$info['type']; 89 $header['Content-Type'] = 'image/'.$info['type'];
81 - $img_type = $info['type'];  
82 - $content = base64_encode($content);  
83 - $img_base64 = 'data:image/' . $img_type . ';base64,' . $content;  
84 - return response($img_base64,200,$header); 90 + return response($content,200,$header);
85 } 91 }
86 92
87 /** 93 /**
@@ -59,19 +59,19 @@ class NewsLogic extends BaseLogic @@ -59,19 +59,19 @@ class NewsLogic extends BaseLogic
59 $this->param['project_id'] = $this->user['project_id']; 59 $this->param['project_id'] = $this->user['project_id'];
60 $this->param['created_at'] = date('Y-m-d H:i:s',time()); 60 $this->param['created_at'] = date('Y-m-d H:i:s',time());
61 $this->param['updated_at'] = date('Y-m-d H:i:s',time()); 61 $this->param['updated_at'] = date('Y-m-d H:i:s',time());
62 -// DB::beginTransaction();  
63 -// try { 62 + DB::beginTransaction();
  63 + try {
64 if(isset($this->param['image'])){ 64 if(isset($this->param['image'])){
65 $data = $this->upload(); 65 $data = $this->upload();
66 $this->param['image'] = $data; 66 $this->param['image'] = $data;
67 } 67 }
68 $rs = $this->model->insertGetId($this->param); 68 $rs = $this->model->insertGetId($this->param);
69 RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); 69 RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
70 -// DB::commit();  
71 -// }catch (\Exception $e){  
72 -// DB::rollBack();  
73 -// $this->fail('添加失败');  
74 -// } 70 + DB::commit();
  71 + }catch (\Exception $e){
  72 + DB::rollBack();
  73 + $this->fail('添加失败');
  74 + }
75 return $this->success(); 75 return $this->success();
76 } 76 }
77 77