作者 邓超

Merge branch 'develop' into dc

@@ -120,16 +120,11 @@ class TemplateController extends BaseController @@ -120,16 +120,11 @@ class TemplateController extends BaseController
120 public function get_html(){ 120 public function get_html(){
121 $source = $this->param['source']??''; 121 $source = $this->param['source']??'';
122 $source_id = $this->param['source_id']??0; 122 $source_id = $this->param['source_id']??0;
123 -  
124 -  
125 $data = TemplateLogic::instance()->first($source,$source_id); 123 $data = TemplateLogic::instance()->first($source,$source_id);
126 -  
127 $res = [ 124 $res = [
128 'html' => $data['html']??'', 125 'html' => $data['html']??'',
129 'name' => 'example' 126 'name' => 'example'
130 ]; 127 ];
131 -  
132 -  
133 return $this->response('',Code::SUCCESS,$res); 128 return $this->response('',Code::SUCCESS,$res);
134 129
135 } 130 }
@@ -142,20 +137,20 @@ class TemplateController extends BaseController @@ -142,20 +137,20 @@ class TemplateController extends BaseController
142 public function save_html(TemplateRequest $request){ 137 public function save_html(TemplateRequest $request){
143 138
144 $data = $request->validated(); 139 $data = $request->validated();
145 -  
146 $data['data_source'] = $data['source']; 140 $data['data_source'] = $data['source'];
147 $data['data_source_id'] = $data['source_id']; 141 $data['data_source_id'] = $data['source_id'];
  142 + unset($data['source']);
  143 + unset($data['source_id']);
  144 + TemplateLogic::instance()->save($data);
  145 + return $this->response('保存成功');
148 146
149 // 不需要数据id 147 // 不需要数据id
150 if(in_array($data['data_source'],['index'])){ 148 if(in_array($data['data_source'],['index'])){
151 $data['data_source_id'] = 0; 149 $data['data_source_id'] = 0;
152 } 150 }
153 -  
154 unset($data['source']); 151 unset($data['source']);
155 unset($data['source_id']); 152 unset($data['source_id']);
156 -  
157 $id = TemplateLogic::instance()->save($data); 153 $id = TemplateLogic::instance()->save($data);
158 -  
159 if($id){ 154 if($id){
160 $info = TemplateLogic::instance()->getInfo($id['id']); 155 $info = TemplateLogic::instance()->getInfo($id['id']);
161 $info['source'] = $info['data_source']; 156 $info['source'] = $info['data_source'];
@@ -141,7 +141,7 @@ class FileController @@ -141,7 +141,7 @@ class FileController
141 $fileModel = new File(); 141 $fileModel = new File();
142 $file_hash = $fileModel->read(['hash'=>$hash]); 142 $file_hash = $fileModel->read(['hash'=>$hash]);
143 if($file_hash !== false){ 143 if($file_hash !== false){
144 - return $hash; 144 + return $this->response('资源',Code::SUCCESS,['file'=>$hash]);
145 } 145 }
146 $url = $this->path; 146 $url = $this->path;
147 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); 147 $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
@@ -197,7 +197,7 @@ class FileController @@ -197,7 +197,7 @@ class FileController
197 $data[] = $hash; 197 $data[] = $hash;
198 } 198 }
199 $fileModel->insert($save_data); 199 $fileModel->insert($save_data);
200 - return $this->response('资源',Code::SUCCESS,['files'=>$data]); 200 + return $this->response('资源',Code::SUCCESS,['file'=>$data]);
201 } 201 }
202 /** 202 /**
203 * @name 统一返回参数 203 * @name 统一返回参数
@@ -175,7 +175,7 @@ class ImageController @@ -175,7 +175,7 @@ class ImageController
175 $hash = hash_file('md5', $file->getPathname()); 175 $hash = hash_file('md5', $file->getPathname());
176 $image_hash = $imageModel->read(['hash'=>$hash]); 176 $image_hash = $imageModel->read(['hash'=>$hash]);
177 if($image_hash !== false){ 177 if($image_hash !== false){
178 - $data[] = $hash; 178 + $data[] = ['image'=>$hash];
179 continue; 179 continue;
180 } 180 }
181 $url = $this->path; 181 $url = $this->path;
@@ -192,10 +192,10 @@ class ImageController @@ -192,10 +192,10 @@ class ImageController
192 'hash' => $hash, 192 'hash' => $hash,
193 'type'=>$file->getClientOriginalExtension(), 193 'type'=>$file->getClientOriginalExtension(),
194 ]; 194 ];
195 - $data[] = $hash; 195 + $data[] = ['image'=>$hash];
196 } 196 }
197 $imageModel->insert($save_data); 197 $imageModel->insert($save_data);
198 - return $this->response('图片资源',Code::SUCCESS,['image'=>$data]); 198 + return $this->response('图片资源',Code::SUCCESS,$data);
199 } 199 }
200 200
201 //下载 201 //下载
@@ -247,15 +247,6 @@ class ImageController @@ -247,15 +247,6 @@ class ImageController
247 case 'image': 247 case 'image':
248 $data['image_link'] = url('/b/image/' . $v); 248 $data['image_link'] = url('/b/image/' . $v);
249 break; 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 } 250 }
260 } 251 }
261 } 252 }