Files
shz-backend/docs/app-login-register-api.md
2026-01-11 20:44:27 +08:00

94 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# APP登录注册二合一接口文档
## 登录注册二合一
**接口地址:** `POST /app/loginOrRegister`
**接口说明:** 根据手机号查询用户,存在则登录,不存在则注册后登录
**请求参数Body JSON**
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| username | String | 是 | 手机号码 |
| name | String | 是 | 姓名 |
| idCard | String | 否 | 身份证号 |
**请求示例:**
```json
{
"username": "13800138000",
"name": "张三",
"idCard": "110101199001011234"
}
```
**响应参数:**
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Number | 状态码200 表示成功 |
| msg | String | 提示信息 |
| token | String | 登录令牌 |
| isNewUser | Boolean | 是否新用户true=新注册false=已存在) |
| idCard | String | 身份证号 |
**响应示例(新用户注册):**
```json
{
"code": 200,
"msg": "操作成功",
"token": "eyJhbGciOiJIUzUxMiJ9...",
"isNewUser": true,
"idCard": "110101199001011234"
}
```
**响应示例(老用户登录):**
```json
{
"code": 200,
"msg": "操作成功",
"token": "eyJhbGciOiJIUzUxMiJ9...",
"isNewUser": false,
"idCard": "110101199001011234"
}
```
**错误响应示例:**
```json
{
"code": 500,
"msg": "电话号码不能为空!"
}
```
```json
{
"code": 500,
"msg": "姓名不能为空!"
}
```
---
**cURL 测试示例:**
```bash
curl -X POST http://localhost:8080/app/loginOrRegister \
-H "Content-Type: application/json" \
-d '{"username":"13800138000","name":"张三","idCard":"110101199001011234"}'
```
不带身份证:
```bash
curl -X POST http://localhost:8080/app/loginOrRegister \
-H "Content-Type: application/json" \
-d '{"username":"13800138000","name":"张三"}'
```