EMPTY_OWNER_TYPE]; } if ($ownerId < 1) { return ["code" => EMPTY_OWNER_ID]; } // 删除所有ownerType 和 ownerId $this->where("owner_type", $ownerType)->where("owner_id", $ownerId)->where("is_del", false) ->update(["is_del" => true]); // 重新添加ownerType 和 ownerId的数据 if (count($barIds) < 1) { return ["code" => SUCCESS, "data" => []]; } $data = []; foreach ($barIds as $barId) { array_push($data, array("owner_type" => $ownerType, "owner_id" => $ownerId, "bar_id" => $barId, "is_del" => false)); } $this->insert($data); // 查出批量插入的数据,并返回给前端 $new_data = $this->select("id", "owner_type", "owner_id", "bar_id", "status") ->where("owner_type", $ownerType)->where("owner_id", $ownerId)->where("is_del", false)->get(); return ["code" => SUCCESS, "data" => $new_data]; } private function checkActionBar($barId) { return SUCCESS; } private function checkOwner($ownerType, $ownerId) { return SUCCESS; } public function RemoveUserActionBar($id) { if ($id < 1) { return INVALID_U_A_ID; } // check the data if exist in system. // $item = $this->where("id", $id)->where("is_del", false)->first(); // if (!$item) { // return INVALID_U_A_ID; // } $row = $this->where("id", $id)->where("is_del", false)->update(["is_del" => true]); if ($row == 0) { return INVALID_GROUP_ID; } return SUCCESS; } /** * @param $ownerType * @param $ownerId * @return array */ public function ListActionBarIds($ownerType, $ownerId) { $opera = $this->select("bar_id"); if ($ownerType != "") { $opera = $opera->where("owner_type", $ownerType); } $bars = $opera->where("owner_id", $ownerId)->where("status", "normal")->where("is_del", false)->get(); if (count($bars) == 0) { return []; } $bar_ids = []; foreach ($bars as $bar) { array_push($bar_ids, $bar["bar_id"]); } Log::debug("========" . json_encode($bar_ids)); return $bar_ids; } }