interfaceSettingInfo['delete_type'] ?? 0; if (2 === $delete_type) { // 真实删除单条数据 $result = $this->deleteTrueOne(); } elseif (3 === $delete_type) { // 批量伪删除 $result = $this->deleteFakeMulti(); } elseif (1 === $delete_type) { // 伪删除单条数据 $result = $this->deleteFakeOne(); } else { $result = $this->deleteFakeOne(); } return $result; } /** * 真实删除. * * @return bool */ public function deleteTrueOne() { $entityId = $this->requestData['id'] ?? ''; $entityMid = $this->requestData['mid'] ?? ''; if (empty($entityId) && empty($entityMid)) { abort(508, '参数错误'); } $find = DB::connection($this->getDbConnection())->table($this->table); if ($entityId) { $find->where('id', $entityId); } if ($entityMid) { $find->where('mid', $entityMid); } return $find->delete(); } /** * 伪删除. * * @return array|callable|false */ public function deleteFakeOne() { $entityId = $this->requestData['id'] ?? ''; $entityMid = $this->requestData['mid'] ?? ''; if (empty($entityId) && empty($entityMid)) { abort(508, '参数错误'); } $find = DB::connection($this->getDbConnection())->table($this->table); if ($entityId) { $find->where('id', $entityId); } if ($entityMid) { $find->where('mid', $entityMid); } $existInfo = $find->first('id'); if (empty($existInfo)) { abort(508, '参数错误2'); } return DB::table($this->table)->where('id', $existInfo->id)->update(['is_delete' => 1]); } /** * 批量伪删除. * * @return int */ public function deleteFakeMulti() { $idArr = $this->requestData['id'] ?? []; $midArr = $this->requestData['mid'] ?? []; if (empty($idArr) && empty($midArr)) { abort(508, '参数错误'); } // return DB::table($this->table)->where('id', $id)->orWhere('mid', $mid)->update(['is_delete' => 1]); } }