request->input('limit', 10); return $this->return->success(); } /** * 添加 * @return array * @throws Exception */ public function add(): array { $name = $this->request->input('chinese_name'); $account = $this->request->input('account'); $oldAccount = $this->adminUserModel->getAdminInfoByAccount($account); $oldName = $this->adminUserModel->getAdminInfoByName($name); if (!empty($oldName) && !empty($oldAccount)) throw new AdminException('账号或者员工已存在'); $salt = StringUtil::randStr(6); $defaultPassword = config('system.admin_default_password'); $model = new AdminUser(); $model->username = $account; $model->chinese_name = $name; $model->salt = $salt; $model->password = $this->cryptoFactory->cryptoClass('admin-password',$defaultPassword,$salt)->encrypt(); $model->status = $this->request->input('status', 1); $model->avatar = $this->request->input('avatar',0); $model->role_id = $this->request->input('role_id', 0); if (!$model->save()) throw new AdminException('账号添加失败'); return $this->return->success(); } public function edit() { return $this->return->success(); } /** * 删除 * @return array */ public function delete(): array { $id = (int)$this->request->input('id'); $info = $this->adminUserModel->getAdminInfoById($id); if (empty($info)) throw new AdminException('员工不存在'); $info->is_del = UserCode::DISABLE; if (!$info->save()) throw new AdminException('账号删除失败'); return $this->return->success(); } /** * 详情 * @return array */ public function get(): array { $id = (int)$this->request->input('id'); $info = $this->adminUserModel->getAdminInfoById($id); if (empty($info)) throw new AdminException('员工不存在'); return $this->return->success('success', ['info' => $info->toArray()]); } }