Browse Source

初始化

程旭源 4 years ago
parent
commit
56904eb05e

+ 27 - 1
application/api/controller/User.php

@@ -13,7 +13,7 @@ use think\Validate;
  */
 class User extends Api
 {
-    protected $noNeedLogin = ['login', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third'];
+    protected $noNeedLogin = ['login', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third', 'apiRegister'];
     protected $noNeedRight = '*';
 
     public function _initialize()
@@ -127,6 +127,32 @@ class User extends Api
         }
     }
 
+    public function apiRegister()
+    {
+        $username = '';
+        while (true) {
+            // 随机生成一个8位数字作为账号
+            $username = Random::numeric(8);
+            // 判断数据库是否存在当前账号, 存在就重新生成
+            if (\app\common\model\User::where('username', $username)->find()) {
+                continue;
+            }
+            break;
+        }
+
+        $password = Random::alnum(6);
+        $email = "test@qq.com";
+        $mobile = "18888888888";
+
+        if ($ret = $this->auth->register($username, $password, $email, $mobile, [])) {
+            var_dump($username);
+            var_dump($password);
+            var_dump($ret);
+            die;
+        }
+        print_r("创建失败");
+    }
+
     /**
      * 注销登录
      */

+ 16 - 0
application/common/behavior/Common.php

@@ -73,4 +73,20 @@ class Common
         ]);
         $this->moduleInit($request);
     }
+
+    static public function getRedis()
+    {
+        $options = [
+            'host'       => '127.0.0.1',
+            'port'       => 6379,
+            'password'   => 'Z159357p',
+            'select'     => 1,
+            'timeout'    => 0,
+            'expire'     => 0,
+            'persistent' => true,
+            'prefix'     => '',
+        ];
+
+
+    }
 }

+ 1 - 1
application/config.php

@@ -96,7 +96,7 @@ return [
     // 域名部署
     'url_domain_deploy'      => false,
     // 域名根,如thinkphp.cn
-    'url_domain_root'        => '',
+    'url_domain_root'        => 'switch.7vbc.com',
     // 是否自动转换URL中的控制器和操作名
     'url_convert'            => true,
     // 默认的访问控制器层