_valid([ "page.default" => 1, "size.default" => 10 ]); if (!is_array($param)) return error($param); $param['open_id'] = $request->user['open_id']; $list = (new AddressService)->getDataListMini($param); return successTrans(100010,pageFormat($list)); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * 新增/编辑代理 * @param Request $request * @return Response */ #[Route(path: "save",methods: "post")] public function save(Request $request): Response { try { $param = $request->post(); $param['uuid'] = $request->user['id']; $param['open_id'] = $request->user['open_id']; if (!$this->validate->check($param)) return error($this->validate->getError()); $state = $this->mode->setAutoData($param); if (!$state) return errorTrans("error.data"); return successTrans("success.data"); } catch (\Throwable $throwable) { echo $throwable->getMessage()."\n"; echo $throwable->getFile()."\n"; echo $throwable->getLine()."\n"; return error($throwable->getMessage()); } } /** * 删除 * @param Request $request * @return Response */ #[Route(path: "del",methods: "post")] public function delUser(Request $request): Response { try { $param = $this->_valid([ "id.require" => trans("empty.require") ],"post"); if (!is_array($param)) return error($param); $data = $this->mode->where("id",$param['id'])->findOrEmpty(); if ($data->isEmpty()) return errorTrans("empty.data"); // 删除其他相关数据 $state = $data->delete(); if (!$state) return errorTrans("error.data"); return successTrans("success.data"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } }