From 9a6b882a1b2966525cab72de580c9821acb168c9 Mon Sep 17 00:00:00 2001 From: zpc Date: Thu, 20 Mar 2025 06:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/User.php | 5 ++- app/admin/view/User/index.html | 19 ++++++++--- app/common/server/RedisHelper.php | 55 +++++++++++++++++++++++++++++++ app/config/redis.php | 8 +++++ 4 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 app/common/server/RedisHelper.php create mode 100644 app/config/redis.php diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index fd34d69..e7a7bfe 100755 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -19,6 +19,7 @@ use app\common\model\UserAccount; use app\common\model\UserLoginIp; use think\facade\Db; use think\helper\Str; +use app\common\server\RedisHelper; class User extends Base { /** @@ -207,9 +208,11 @@ class User extends Base */ public function usertest(Request $request) { + $redis = new RedisHelper(); + $redis->set('test', '123'); $id = request()->post('id/d', 0); $type = request()->post('type/d', 0); - if ($type != 1 && $type != 0) { + if ($type != 1 && $type != 0 && $type != 2) { return $this->renderError('请求参数错误'); } $user = UserModel::getInfo(['id' => $id]); diff --git a/app/admin/view/User/index.html b/app/admin/view/User/index.html index 2677d53..9f15548 100755 --- a/app/admin/view/User/index.html +++ b/app/admin/view/User/index.html @@ -141,11 +141,20 @@ 推广账号 - {else /} + 测试账号 + {/if} + {if condition="$vo['istest'] eq 1" /} 取消推广账号 {/if} + {if condition="$vo['istest'] eq 2" /} + 取消测试账号 + {/if} 查看下级 redis = new \Redis(); + $this->connect($host, $port); + } + + private function connect($host, $port) + { + $this->redis->connect($host, $port); + } + + public function get($key) + { + return $this->redis->get($key); + } + + public function set($key, $value, $timeout = 0) + { + if ($timeout > 0) { + return $this->redis->setex($key, $timeout, $value); + } + return $this->redis->set($key, $value); + } + + public function delete($key) + { + return $this->redis->del($key); + } + + public function exists($key) + { + return $this->redis->exists($key); + } + + public function expire($key, $timeout) + { + return $this->redis->expire($key, $timeout); + } + +} \ No newline at end of file diff --git a/app/config/redis.php b/app/config/redis.php new file mode 100644 index 0000000..4874658 --- /dev/null +++ b/app/config/redis.php @@ -0,0 +1,8 @@ + env('redis.host', '127.0.0.1'), + 'port' => env('redis.port', 6379), + 'password' => env('redis.password', ''), +];