get(); $list = $this->service->getList($param); return successTrans("success.data",pageFormat($list),200); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * 设置path * @param Request $request * @return Response */ #[Route(path: "auth",methods: "post")] public function setAuth(Request $request): Response { try { $param = $this->_valid([ "id.require" => trans("empty.require"), "val.default" => 2, "type.default" => 1, // 1 设置path 2 关闭二维码 ],"post"); if (!is_array($param)) return error($param); $store = $this->model->where("id",$param['id'])->findOrEmpty(); if ($store->isEmpty()) return errorTrans("empty.data"); if ($param['type'] == 1) { // 设置path $resp = (new Client)->config($this->getDyConfig())->token()->setMiniPath($store['store_id']); if ($resp['err_no'] <> 0) return error($resp['err_msg']); $resp = (new Account)->config($this->getDyConfig())->token()->setWhiteSetting($store['store_id'],1,true); if ($resp['err_no'] <> 0) return error($resp['err_msg']); } else { if ($store['is_hide'] == 1) { $store->is_hide = 0; } else { $store->is_hide = 1; } $store->save(); $resp = (new Client)->config($this->getDyConfig())->token()->setBtnText($store['store_id'],$param['val']); if ($resp['err_no'] <> 0) return error($resp['err_msg']); } return successTrans("success.data"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * @param Request $request * @return Response */ #[Route(path: "hook",methods: "get")] public function getHookUri(Request $request): Response { try { $param = $request->get(); return successTrans(100010,['url' => "https://miniapi.jsshuita.com.cn/"]); } 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(); if (!isset($param['id'])) { $this->scene = "add"; $param['user_id'] = CodeExtend::random(16,1,date("md")); if (!empty($param['username'])) { $userName = (new SystemUser)->where("username",$param['username'])->findOrEmpty(); if (!$userName->isEmpty()) return errorTrans("error.user-exist"); } } if (!$this->validate->check($param)) return error($this->validate->getError()); $state = $this->model->setAutoData($param); if (!$state) return errorTrans("error.data"); // $this->sceneUser($param,3,"id"); 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: "edit",methods: "post")] public function edit(Request $request): Response { try { $param = $request->post(); if (!$this->validate->check($request->post())) return error($this->validate->getError()); $state = $this->model->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: "batch",methods: "post")] public function setBatchData(Request $request): Response { try { $param = $this->_valid([ "id.require" => trans("empty.require"), "value.require" => trans("empty.require"), "field.require" => trans("empty.require"), "type.require" => trans("empty.require"), ],"post"); if (!is_array($param)) return error($param); if ($param['type'] == "batch") { $state = $this->model->where("id","in",$param['id'])->save([$param['field'] => $param['value']]); } else { $state = $this->model->where("id",$param['id'])->save([$param['field'] => $param['value']]); } if (!$state) return errorTrans("error.data"); return successTrans("success.data"); } catch (\Throwable $throwable) { 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"), "type.default" => "one", ],"post"); if (!is_array($param)) return error($param); if ($param['type'] == "batch") { $state = $this->model->where("id","in",$param['id'])->delete(); } else { $data = $this->model->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()); } } /** * @param Request $request * @return Response */ #[Route(path: "scene",methods: "get")] public function getSmsScene(Request $request): Response { try { $param = $request->get(); $scene = (new SaasSmsScene)->where("store_id",$param['store'])->findOrEmpty(); if ($scene->isEmpty()) return errorTrans("error.data"); return successTrans("success.data",$scene->toArray()); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * @param Request $request * @return Response */ #[Route(path: "sms",methods: "post")] public function setSmsScene(Request $request): Response { try { $param = $request->post(); if (empty($param['store_id'])) return errorTrans("error.data"); $scene = (new SaasSmsScene)->where("store_id",$param['store_id'])->findOrEmpty(); if ($scene->isEmpty()) { $state = $scene->insertGetId($param); } else { $state = $scene->save($param); } if (!$state) return errorTrans("error.data"); return successTrans("success.data"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } }