Commit a53dbaaf authored by hujun's avatar hujun

图片删除

parent eec8f663
......@@ -125,10 +125,12 @@ class StoreFee extends Basic
return $this->response($code, '参数错误');
}
$result = $this->service_->delImg($this->params);
$result = $this->service_->delImg($this->params['id_string']);
if ($result['status'] != 'fail') {
$code = 200;
} else {
$msg = $result['msg'];
}
return $this->response($code, $msg);
......
......@@ -151,10 +151,9 @@ class StoreFeeService
public function delImg($id_string)
{
$image_array = explode(',', $id_string);
$result['status'] = 'fail';
$result['msg'] = '';
if (!is_array($image_array)) {
if (!is_array($image_array) && !is_numeric($id_string)) {
$result['msg'] = '参数错误';
return $result;
}
......@@ -163,12 +162,14 @@ class StoreFeeService
$num = 0;
$path = ROOT_PATH . 'public/';
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']);
}
if ($num) {
$result['status'] = 'successful';
} else {
$result['msg'] = '删除失败';
}
return $result;
}
......
......@@ -440,10 +440,12 @@ class StoreFee extends Basic
}
$service_ = new StoreFeeService();
$result = $service_->delImg($this->params);
$result = $service_->delImg($this->params['id_string']);
if ($result['status'] != 'fail') {
$code = 200;
} else {
$msg = $result['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