Commit a53dbaaf authored by hujun's avatar hujun

图片删除

parent eec8f663
...@@ -125,10 +125,12 @@ class StoreFee extends Basic ...@@ -125,10 +125,12 @@ class StoreFee extends Basic
return $this->response($code, '参数错误'); return $this->response($code, '参数错误');
} }
$result = $this->service_->delImg($this->params); $result = $this->service_->delImg($this->params['id_string']);
if ($result['status'] != 'fail') { if ($result['status'] != 'fail') {
$code = 200; $code = 200;
} else {
$msg = $result['msg'];
} }
return $this->response($code, $msg); return $this->response($code, $msg);
......
...@@ -151,10 +151,9 @@ class StoreFeeService ...@@ -151,10 +151,9 @@ class StoreFeeService
public function delImg($id_string) public function delImg($id_string)
{ {
$image_array = explode(',', $id_string); $image_array = explode(',', $id_string);
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = ''; $result['msg'] = '';
if (!is_array($image_array)) { if (!is_array($image_array) && !is_numeric($id_string)) {
$result['msg'] = '参数错误'; $result['msg'] = '参数错误';
return $result; return $result;
} }
...@@ -163,12 +162,14 @@ class StoreFeeService ...@@ -163,12 +162,14 @@ class StoreFeeService
$num = 0; $num = 0;
$path = ROOT_PATH . 'public/'; $path = ROOT_PATH . 'public/';
foreach($img_data as $v) { foreach($img_data as $v) {
$num += $this->imgModel->editData(['is_del'=>1], $v['id']); $num += $this->imgModel->editData(['img_status'=>1], $v['id']);
@unlink($path.'static/chat_image/'.$v['img_name']); @unlink($path.'static/chat_image/'.$v['img_name']);
} }
if ($num) { if ($num) {
$result['status'] = 'successful'; $result['status'] = 'successful';
} else {
$result['msg'] = '删除失败';
} }
return $result; return $result;
} }
......
...@@ -440,10 +440,12 @@ class StoreFee extends Basic ...@@ -440,10 +440,12 @@ class StoreFee extends Basic
} }
$service_ = new StoreFeeService(); $service_ = new StoreFeeService();
$result = $service_->delImg($this->params); $result = $service_->delImg($this->params['id_string']);
if ($result['status'] != 'fail') { if ($result['status'] != 'fail') {
$code = 200; $code = 200;
} else {
$msg = $result['msg'];
} }
return $this->response($code, $msg); return $this->response($code, $msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment