Przeglądaj źródła

测试一下 erp 使用一些东西 可以不

lvhao 11 godzin temu
rodzic
commit
9a1b63064d

+ 3 - 0
core/CoreApp/config/routes.php

@@ -4,5 +4,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
 $route['default_controller'] = 'start';
 $route['phone'] = "start/phone";
 $route['userlogin'] = "userlogin/login";
+
+$route['lyapi/(v[0-9]+)/(.+)$'] = 'lyerpapi//$1/$2';
+
 $route['404_override'] = '';
 $route['translate_uri_dashes'] = FALSE;

+ 33 - 0
core/CoreApp/controllers/Lyerpapi/v1/User.php

@@ -0,0 +1,33 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class User extends CI_Controller
+{
+    public function __construct()
+    {
+        parent::__construct();
+        $this->output->set_content_type('application/json');
+    }
+
+    // 访问:GET /api/v1/user/center
+    public function center()
+    {
+        $data = [
+            'code' => 200,
+            'version' => 'v1',
+            'data' => [
+                'username' => 'John Doe',
+                'email' => 'john@example.com'
+            ]
+        ];
+        $this->output->set_output(json_encode($data));
+    }
+
+    // 访问:POST /api/v1/user/login
+    public function login()
+    {
+        // 从输入流获取JSON数据
+        $input = json_decode(file_get_contents('php://input'), true);
+        // 业务逻辑...
+    }
+}