API 文档
API¶
LocalAPI:用于从服务器获取数据的 API 封装。
以下接口说明来自项目文档记录;当前参数和返回值应以客户端实现为准。
Kind: global class
- API
- init(server)
- checkNet()
- login(email, password)
- getUsers()
- getUserInfo(email)
- addUser(email, name, password)
- deleteUser(email)
- updateUserPassword(password, user)
- updateUserAvatar(avatar, user)
- addNovel(name, cover_photo, author, detail, price, brief)
- deleteNovel(id)
- getNovelList()
- getNovelDetail(id)
- searchNovelByName(novel)
- searchNovelByAuthor(author)
- searchNovelByPrice(price)
- searchNovel(novel, author, price)
init(server)¶
init api
Kind: instance method of LocalAPI
Returns: API object
| Param | Type | Description |
|---|---|---|
| server | object |
服务器配置;具体字段以实现为准 |
checkNet()¶
检查服务器是否可连接。
Kind: instance method of LocalAPI
Returns: string - pong
login(email, password)¶
user login
Kind: instance method of LocalAPI
Returns: object - response
| Param | Type |
|---|---|
string |
|
| password | string |
getUsers()¶
获取数据库中的用户列表。
Kind: instance method of LocalAPI
Returns: array - user list
getUserInfo(email)¶
根据邮箱获取用户信息。
Kind: instance method of LocalAPI
Returns: user object
| Param | Type |
|---|---|
string |
addUser(email, name, password)¶
新增用户。
Kind: instance method of LocalAPI
Returns: boolean
| Param | Type |
|---|---|
string |
|
| name | string |
| password | string |
deleteUser(email)¶
根据邮箱删除用户。
Kind: instance method of LocalAPI
Returns: boolean
| Param | Type |
|---|---|
string |
updateUserPassword(password, user)¶
修改用户密码。
Kind: instance method of LocalAPI
Returns: user object
| Param | Type | Description |
|---|---|---|
| password | string |
|
| user | string |
updateUserAvatar(avatar, user)¶
修改用户头像。
Kind: instance method of LocalAPI
Returns: user object
| Param | Type | Description |
|---|---|---|
| avatar | string |
image path |
| user | string |
addNovel(name, cover_photo, author, detail, price, brief)¶
向数据库新增小说。
Kind: instance method of LocalAPI
Returns: success
| Param | Type |
|---|---|
| name | string |
| cover_photo | string |
| author | string |
| detail | string |
| price | number |
| brief | string |
deleteNovel(id)¶
根据 ID 删除小说。
Kind: instance method of LocalAPI
Returns: boolean
| Param | Type |
|---|---|
| id | string |
getNovelList()¶
获取小说列表。
Kind: instance method of LocalAPI
Returns: novels
getNovelDetail(id)¶
根据 ID 获取小说详情。
Kind: instance method of LocalAPI
Returns: novel
| Param | Type |
|---|---|
| id | string |
searchNovelByName(novel)¶
根据小说名称搜索。
Kind: instance method of LocalAPI
Returns: array - 匹配的小说列表
| Param | Type | Description |
|---|---|---|
| novel | string |
小说名称 |
searchNovelByAuthor(author)¶
根据作者名称搜索。
Kind: instance method of LocalAPI
Returns: array - 匹配的小说列表
| Param | Type | Description |
|---|---|---|
| author | string |
作者名称 |
searchNovelByPrice(price)¶
根据价格搜索。
Kind: instance method of LocalAPI
Returns: array - 匹配的小说列表
| Param | Type | Description |
|---|---|---|
| price | number |
小说价格 |
searchNovel(novel, author, price)¶
按名称、作者和价格组合搜索小说。
Kind: instance method of LocalAPI
Returns: array - 匹配的小说列表
| Param | Type | Description |
|---|---|---|
| novel | string |
小说名称 |
| author | string |
作者名称 |
| price | number |
价格 |