Commit 1f27bee3 authored by hujun's avatar hujun

删除商铺文件

parent 88e01278
......@@ -299,4 +299,39 @@ class Shop extends Basic
return $this->response($data['status'], $data['msg'], $data['data']);
}
/**
* 删除图片
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function delHouseFile() {
$data['status'] = 101;
$data['msg'] = '';
$data['data'] = '';
if(empty($this->params['file_name']) || empty($this->params['house_id'])){
$data['msg'] = 'File_name or id house_id null';
} else {
$img = new GHousesImgs();
$id = $img->getHouseImagesInfo('id',[
'house_id' => $this->params['house_id'],
'img_name' => $this->params['file_name']
]);
if (empty($id['id'])) {
$data['msg'] = '没有该文件';
} else {
$path = ROOT_PATH . 'public' . DS . 'resource'. DS . 'lib'. DS .'Attachments'. DS .'Images/';
@unlink($path.$this->params['file_name']);
$img->editData(['img_status'=>1],$this->params['house_id'], 'id');
$data['status'] = 200;
}
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
}
......@@ -72,6 +72,7 @@ class GHouses extends BaseModel
$data['city_code'] = $area['1'];
$data['disc_code'] = $area['2'];
foreach ($img_data as $k => $v) {
$v->img_name = CK_IMG_URL.'images'.$v->img_name;
switch ($v->img_type) {
case 1 :
$data['cover'] = $v->img_name;
......
......@@ -179,12 +179,15 @@ class GHousesImgs extends BaseModel
}
/****** zw start *******/
/**
* 查询图片
*
* @param $param
* @param $limit_
* @return mixed
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseImages($param,$limit_)
{
......@@ -196,4 +199,18 @@ class GHousesImgs extends BaseModel
->select();
}
/****** zw end *******/
/**
* 获取图片信息
*
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseImagesInfo($field, $where) {
return $this->field($field)->where($where)->find();
}
}
\ No newline at end of file
......@@ -326,6 +326,7 @@ Route::group('broker', [
'houseEdit' => ['api_broker/shop/edit', ['method' => 'get|post']], //编辑商铺
'getLabelsShopList' => ['api_broker/label/getLabelsShopList', ['method' => 'get']], //编辑商铺
'uploadHouseFile' => ['api_broker/shop/uploadHouseFile', ['method' => 'post']], //商铺上传文件
'delHouseFile' => ['api_broker/shop/delHouseFile', ['method' => 'post']], //商铺文件删除
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
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