|
|
@@ -26,7 +26,7 @@
|
|
|
|
|
|
本文档旨在说明爱智居服务端的API接口,帮助开发人员如何使用smarthome api 进行开发,并详细介绍了各API的功能,调用方式,返回结果和错误码。
|
|
|
|
|
|
-## Codebase
|
|
|
+## 范围说明
|
|
|
|
|
|
此开发文档只针对智能家居控制app,小程序,以及相应的控制端app,面板app等的开发。
|
|
|
|
|
|
@@ -34,6 +34,27 @@
|
|
|
|
|
|
账户系统主要功能是用户注册,登录,修改密码,忘记密码,注销账号。用户信息维护和更新。用户权限控制。角色映射等和用户相关的功能。
|
|
|
|
|
|
+## HTTP返回状态码说明
|
|
|
+
|
|
|
+200-299 请求成功
|
|
|
+400-499 请求失败,客户端参数或信息错误
|
|
|
+500-599 请求失败,服务端错误
|
|
|
+
|
|
|
+| 状态码 | 说明 |
|
|
|
+| ------ | ------------------------ |
|
|
|
+| 200 | 请求成功 |
|
|
|
+| 201 | 新增成功 |
|
|
|
+| 204 | 删除成功/更新成功 |
|
|
|
+| 401 | 请求失败,无权限,没有登陆认证或认证token错误 |
|
|
|
+| 403 | 请求失败,无权限 |
|
|
|
+| 404 | 请求失败,资源不存在 |
|
|
|
+| 405 | 请求失败,请求方法不支持 |
|
|
|
+| 406 | 请求失败,参数错误 |
|
|
|
+| 400 | 请求失败,参数错误 |
|
|
|
+| 408 | 请求失败,请求超时 |
|
|
|
+| 415 | 请求失败,不支持的媒体类型 |
|
|
|
+| 500 | 请求失败,服务端内部错误 |
|
|
|
+
|
|
|
## 用户登陆认证
|
|
|
|
|
|
### 微信用户注册登陆接口
|
|
|
@@ -268,4 +289,118 @@ Authorization: Bearer {{token}}
|
|
|
]
|
|
|
}
|
|
|
```
|
|
|
-### 删除用户信息
|
|
|
+
|
|
|
+## 发送短信验证码
|
|
|
+ POST 请求URL:
|
|
|
+[https://account.izhiju.cn/realms/zhiju/sms/verification-code](https://account.izhiju.cn/realms/zhiju/sms/verification-code)
|
|
|
+请求头参数:
|
|
|
+Content-Type: application/x-www-form-urlencoded
|
|
|
+
|
|
|
+请求体参数:
|
|
|
+| 参数名 | 参数类型 | 默认值 | 说明 |
|
|
|
+| ------------- | -------- | -------------- | --------------------------------------------- |
|
|
|
+| areaCode | string | 86 | 手机号所属的区号,默认86 |
|
|
|
+| phoneNumber | string | | 手机号,11位数字 |
|
|
|
+
|
|
|
+1. 正确状态码200,返回结果:
|
|
|
+{
|
|
|
+ "expires_in": 1714988276153,
|
|
|
+ "resend_expires": 1714988036153,
|
|
|
+ "status": 1
|
|
|
+}
|
|
|
+
|
|
|
+1. 错误返回结果:
|
|
|
+{
|
|
|
+ "error": "sms_verification_code_error",
|
|
|
+ "error_description": "sms verification code error"
|
|
|
+}
|
|
|
+
|
|
|
+## 通过短信验证码修改手机号码
|
|
|
+ POST 请求URL:https://account.izhiju.cn/realms/zhiju/sms/update-profile
|
|
|
+
|
|
|
+ 请求头参数:
|
|
|
+ Authorization: Bearer {{token}}
|
|
|
+ Content-Type: application/x-www-form-urlencoded
|
|
|
+请求体参数:
|
|
|
+| 参数名 | 参数类型 | 默认值 | 说明 |
|
|
|
+| ------------- | -------- | -------------- | --------------------------------------------- |
|
|
|
+| areaCode | string | 86 | 手机号所属的区号,默认86 |
|
|
|
+| phoneNumber | string | | 手机号,11位数字 |
|
|
|
+| smsCode | string | | 短信验证码,6位数字 |
|
|
|
+
|
|
|
+## 用户头像管理
|
|
|
+
|
|
|
+### 头像配置 spi-avatar-provider-config-
|
|
|
+| 参数名 | 参数类型 | 默认值 | 说明 |
|
|
|
+| -------------- | ------------- | ------------------------------------------ | ----------- |
|
|
|
+| defaultAvatar | ```string``` | ```/``` | URL for default avatar |
|
|
|
+| alwaysRedirect | ```boolean``` | ```false``` | Should always redirect to static image url |
|
|
|
+| defaultSize | ```string``` | ```lg``` | Default avatar size |
|
|
|
+| storageService | ```string``` | ```file``` | Provider to store avatar files |
|
|
|
+
|
|
|
+### 头像存储配置 spi-avatar-storage-file-
|
|
|
+| 参数名 | 参数类型 | 默认值 |说明 |
|
|
|
+| root | ```string``` |```/``` | FS storage root path |
|
|
|
+| route | ```string``` |```/{realm}/avatar/{avatar_id}/avatar-{size}.png``` | URL and path to avatar file (Not need change) |
|
|
|
+| baseurl | ```string``` | ```/realms/```| Keycloak base url |
|
|
|
+| default-avatar | ```string``` | ```/{realm}/avatar/default.png```| Path to default avatar|
|
|
|
+
|
|
|
+
|
|
|
+### 接口基本参数
|
|
|
+| 参数名 | 参数类型 |默认值 | 说明 |
|
|
|
+| size | ```enum<String>("xs", "sm", "md", "lg", "xl", "xxl")``` | ```{Config.defaultSize}``` |Avatar file size |
|
|
|
+| format | ```enum<String>("raw", "json")``` |```raw```| Response format |
|
|
|
+
|
|
|
+### 通过用户ID获取头像
|
|
|
+Request:
|
|
|
+```
|
|
|
+GET /realms/{realm}/avatar/by-userid/{user_id}
|
|
|
+```
|
|
|
+没有size参数时,返回默认lg大头像,没有format参数时,默认format为raw,返回原始图片
|
|
|
+
|
|
|
+请求参数中指定format参数为json时,返回json格式数据:
|
|
|
+```js
|
|
|
+{
|
|
|
+ status: 1,
|
|
|
+ avatar: "", // avatar url for lg
|
|
|
+ avatar_tpl: "", // avatar url template, placeholder: %s
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+### 通过用户名获取头像
|
|
|
+Request:
|
|
|
+```
|
|
|
+GET /realms/{realm}/avatar/by-username/{username}
|
|
|
+```
|
|
|
+
|
|
|
+Respose (While format=json):
|
|
|
+```js
|
|
|
+{
|
|
|
+ status: 1,
|
|
|
+ avatar: "", // avatar url for lg
|
|
|
+ avatar_tpl: "", // avatar url template, placeholder: %s
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+### 获取默认头像
|
|
|
+Request:
|
|
|
+```
|
|
|
+GET /realms/{realm}/avatar/default
|
|
|
+```
|
|
|
+
|
|
|
+Respose (While format=json):
|
|
|
+```js
|
|
|
+{
|
|
|
+ status: 1,
|
|
|
+ avatar: "", // avatar url for lg
|
|
|
+ avatar_tpl: "", // avatar url template, placeholder: %s
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+### 上传头像
|
|
|
+Request:
|
|
|
+```
|
|
|
+POST /realms/{realm}/avatar
|
|
|
+
|
|
|
+image=<image file>
|
|
|
+```
|