py-wisharetec-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_wisharetec_sdk-0.1.0/.env.example +5 -0
- py_wisharetec_sdk-0.1.0/.gitee/ISSUE_TEMPLATE.zh-CN.md +13 -0
- py_wisharetec_sdk-0.1.0/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +12 -0
- py_wisharetec_sdk-0.1.0/.gitignore +143 -0
- py_wisharetec_sdk-0.1.0/LICENSE +21 -0
- py_wisharetec_sdk-0.1.0/PKG-INFO +264 -0
- py_wisharetec_sdk-0.1.0/README.md +215 -0
- py_wisharetec_sdk-0.1.0/pyproject.toml +191 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/__init__.py +14 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/_version.py +16 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/__init__.py +7 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/__init__.py +7 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/base/__init__.py +7 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/base/api.py +177 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/base/cache.py +128 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/base/config.py +86 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/base/models.py +111 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/base_archive/__init__.py +7 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/base_archive/api.py +267 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/core/shangshu/workflow_center/api.py +210 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/provider.py +82 -0
- py_wisharetec_sdk-0.1.0/src/py_wisharetec_sdk/utils/__init__.py +1 -0
- py_wisharetec_sdk-0.1.0/tests/conftest.py +22 -0
- py_wisharetec_sdk-0.1.0/tests/test_base_archive.py +254 -0
- py_wisharetec_sdk-0.1.0/tests/test_workflow_center.py +102 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
98
|
+
__pypackages__/
|
|
99
|
+
|
|
100
|
+
# Celery stuff
|
|
101
|
+
celerybeat-schedule
|
|
102
|
+
celerybeat.pid
|
|
103
|
+
|
|
104
|
+
# SageMath parsed files
|
|
105
|
+
*.sage.py
|
|
106
|
+
|
|
107
|
+
# Environments
|
|
108
|
+
.env
|
|
109
|
+
.venv
|
|
110
|
+
env/
|
|
111
|
+
venv/
|
|
112
|
+
ENV/
|
|
113
|
+
env.bak/
|
|
114
|
+
venv.bak/
|
|
115
|
+
|
|
116
|
+
# Spyder project settings
|
|
117
|
+
.spyderproject
|
|
118
|
+
.spyproject
|
|
119
|
+
|
|
120
|
+
# Rope project settings
|
|
121
|
+
.ropeproject
|
|
122
|
+
|
|
123
|
+
# mkdocs documentation
|
|
124
|
+
/site
|
|
125
|
+
|
|
126
|
+
# mypy
|
|
127
|
+
.mypy_cache/
|
|
128
|
+
.dmypy.json
|
|
129
|
+
dmypy.json
|
|
130
|
+
|
|
131
|
+
# Pyre type checker
|
|
132
|
+
.pyre/
|
|
133
|
+
|
|
134
|
+
# pytype static type analyzer
|
|
135
|
+
.pytype/
|
|
136
|
+
|
|
137
|
+
# Cython debug symbols
|
|
138
|
+
cython_debug/
|
|
139
|
+
.DS_Store
|
|
140
|
+
.trae/
|
|
141
|
+
.ruff_cache/
|
|
142
|
+
uv.lock
|
|
143
|
+
_local/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 郭磊
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: py-wisharetec-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 善数(Wisharetec)物业平台开放接口 Python SDK — 基于 httpx + pydantic v2。
|
|
5
|
+
Project-URL: Homepage, https://gitee.com/guolei19850528/py-shangshu-sdk
|
|
6
|
+
Project-URL: Repository, https://gitee.com/guolei19850528/py-shangshu-sdk.git
|
|
7
|
+
Project-URL: Issues, https://gitee.com/guolei19850528/py-shangshu-sdk/issues
|
|
8
|
+
Author-email: guolei <174000902@qq.com>
|
|
9
|
+
Maintainer-email: guolei <174000902@qq.com>
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 郭磊
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: httpx,pydantic,sdk,shangshu,wisharetec,善数,物业
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
|
+
Classifier: Typing :: Typed
|
|
44
|
+
Requires-Python: >=3.10
|
|
45
|
+
Requires-Dist: diskcache>=5.6.3
|
|
46
|
+
Requires-Dist: httpx[http2]>=0.27
|
|
47
|
+
Requires-Dist: pydantic>=2.14.3
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
# py-wisharetec-sdk
|
|
51
|
+
|
|
52
|
+
善数(Wisharetec)物业平台开放接口 Python SDK — 基于 httpx + pydantic v2。
|
|
53
|
+
|
|
54
|
+
## 特性
|
|
55
|
+
|
|
56
|
+
- 🔑 **自动登录鉴权** — SDK 内部自动 MD5 密码 + 登录 + 刷新 authorization
|
|
57
|
+
- 💾 **可选缓存后端** — 默认 diskcache 本地文件缓存 authorization,可选 Redis 分布式缓存
|
|
58
|
+
- 🧩 **Facade 统一入口** — `ShanshuProvider` 挂载所有业务 API,一行调用
|
|
59
|
+
- 📦 **响应兼容** — dict / list / str / int / float / bool / null 全类型自动解析
|
|
60
|
+
- ⚡ **HTTP/2** — httpx `[http2]` 支持,连接池复用
|
|
61
|
+
- 🧪 **真实网络集成测试** — pytest + .env,一键跑通 23 个查询接口
|
|
62
|
+
|
|
63
|
+
## 安装
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 推荐(uv)
|
|
67
|
+
uv add py-wisharetec-sdk
|
|
68
|
+
|
|
69
|
+
# pip
|
|
70
|
+
pip install py-wisharetec-sdk
|
|
71
|
+
|
|
72
|
+
# 需要 Redis 缓存
|
|
73
|
+
pip install py-wisharetec-sdk[redis]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 快速开始
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from py_wisharetec_sdk.provider import ShanshuProvider
|
|
80
|
+
|
|
81
|
+
# 方式一:最简(账号密码即可)
|
|
82
|
+
provider = ShanshuProvider(
|
|
83
|
+
account="18910415280",
|
|
84
|
+
password="your_password",
|
|
85
|
+
)
|
|
86
|
+
provider.refresh_authorization()
|
|
87
|
+
|
|
88
|
+
# 方式二:自定义配置
|
|
89
|
+
from py_wisharetec_sdk.core.shangshu.base.config import ShanshuAPIConfig
|
|
90
|
+
|
|
91
|
+
config = ShanshuAPIConfig(
|
|
92
|
+
account="18910415280",
|
|
93
|
+
password="your_password",
|
|
94
|
+
base_url="https://saas.wisharetec.com",
|
|
95
|
+
timeout=60.0,
|
|
96
|
+
)
|
|
97
|
+
provider = ShanshuProvider(config=config)
|
|
98
|
+
|
|
99
|
+
# ===== 基础档案 =====
|
|
100
|
+
# 园区分页
|
|
101
|
+
resp = provider.base_archive_api.park_with_paginator()
|
|
102
|
+
for park in resp.data["records"]:
|
|
103
|
+
print(park["name"], park["city"], park["area"])
|
|
104
|
+
|
|
105
|
+
# 园区详情
|
|
106
|
+
detail = provider.base_archive_api.park_with_detail("7653f011-4d9d-11ec-aa56-005056b13afd")
|
|
107
|
+
print(detail.data["name"], detail.data["street"])
|
|
108
|
+
|
|
109
|
+
# ===== 工作台 / 流程中心 =====
|
|
110
|
+
# 审批待办
|
|
111
|
+
todos = provider.workflow_center_api.approval_todo_with_paginator()
|
|
112
|
+
for item in todos.data["records"]:
|
|
113
|
+
print(item["title"], item["nodeName"])
|
|
114
|
+
|
|
115
|
+
# 消息通知
|
|
116
|
+
notices = provider.workflow_center_api.notice_with_paginator()
|
|
117
|
+
for n in notices.data["records"]:
|
|
118
|
+
print(n["title"], n["createTime"])
|
|
119
|
+
|
|
120
|
+
provider.close()
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 响应模型
|
|
124
|
+
|
|
125
|
+
所有 API 返回 :class:`ShanshuCommonResponse`,提供三个便捷访问:
|
|
126
|
+
|
|
127
|
+
| 属性 | 说明 |
|
|
128
|
+
|------|------|
|
|
129
|
+
| `resp.ok()` | `bool` — 是否成功(失败响应特征:同时有 code + msg 且无业务字段) |
|
|
130
|
+
| `resp.data` | `dict` — dict 响应的业务字段集合 |
|
|
131
|
+
| `resp.raw` | `Any` — 非 dict 响应的原始值(list / str / int / float / bool / null) |
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
resp = provider.workflow_center_api.wbs_message_with_detail()
|
|
135
|
+
if resp.raw is not None:
|
|
136
|
+
print("WBS 告警:", resp.raw) # resp.raw 是 list
|
|
137
|
+
else:
|
|
138
|
+
print(resp.data.get("msg")) # resp.data 是 dict
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## 项目结构
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
py_wisharetec_sdk/
|
|
145
|
+
├── src/py_wisharetec_sdk/
|
|
146
|
+
│ ├── __init__.py
|
|
147
|
+
│ ├── _version.py # 版本号(hatchling 动态读取)
|
|
148
|
+
│ ├── provider.py # Facade 主入口:ShanshuProvider
|
|
149
|
+
│ ├── core/shangshu/
|
|
150
|
+
│ │ ├── base/
|
|
151
|
+
│ │ │ ├── __init__.py
|
|
152
|
+
│ │ │ ├── api.py # ShanshuBaseAPI(登录/鉴权/HTTP)
|
|
153
|
+
│ │ │ ├── config.py # ShanshuAPIConfig(Pydantic)
|
|
154
|
+
│ │ │ ├── cache.py # ShanshuAuthorizationDiskcache / Redis
|
|
155
|
+
│ │ │ └── models.py # ShanshuCommonResponse / QueryPaginatorPayload
|
|
156
|
+
│ │ ├── base_archive/api.py # 基础档案(园区/房产/车场/楼幢/用户/业主/车辆/车位)
|
|
157
|
+
│ │ └── workflow_center/api.py # 工作台(审批/消息/WBS)
|
|
158
|
+
│ └── utils/
|
|
159
|
+
├── tests/
|
|
160
|
+
│ ├── conftest.py # pytest 选项注册(--run-modify)
|
|
161
|
+
│ ├── test_base_archive.py # 16 查询 + 3 写操作(默认 skip)
|
|
162
|
+
│ └── test_workflow_center.py # 7 查询
|
|
163
|
+
├── pyproject.toml # hatchling + ruff + mypy + pytest 配置
|
|
164
|
+
├── .env.example # 集成测试账号密码模板
|
|
165
|
+
└── LICENSE
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## API 速查表
|
|
169
|
+
|
|
170
|
+
### base_archive(基础档案)— 16 个查询
|
|
171
|
+
|
|
172
|
+
| # | 方法 | 类型 | HTTP | API 路径 |
|
|
173
|
+
|---|------|------|------|----------|
|
|
174
|
+
| 1 | `park_with_paginator(payload)` | 分页 | POST | `/api/space/community/v2/frontPage` |
|
|
175
|
+
| 2 | `park_with_detail(id)` | 详情 | GET | `/api/space/community/v2/getDetail` |
|
|
176
|
+
| 3 | `house_with_paginator(payload)` | 分页 | POST | `/api/space/property/propertyPage` |
|
|
177
|
+
| 4 | `house_with_detail(id)` | 详情 | GET | `/api/space/property/getProperty` |
|
|
178
|
+
| 5 | `parking_lot_with_paginator(payload)` | 分页 | POST | `/api/space/space/yardArchivePage` |
|
|
179
|
+
| 6 | `parking_lot_with_detail(id)` | 详情 | GET | `/api/space/space/getYardArchivePage` |
|
|
180
|
+
| 7 | `building_with_paginator(payload)` | 分页 | POST | `/api/space/property/getSpaceBuildingPage` |
|
|
181
|
+
| 8 | `building_with_detail(building_id)` | 详情 | GET | `/api/space/property/getSpaceBuildingDetail` |
|
|
182
|
+
| 9 | `user_with_paginator(payload)` | 分页 | POST | `/api/user/residentInfo/getResidentPage` |
|
|
183
|
+
| 10 | `user_with_detail(user_id)` | 详情 | GET | `/api/user/residentInfo/getResidentInfo` |
|
|
184
|
+
| 11 | `owner_with_paginator(payload)` | 分页 | POST | `/api/space/archive/examine/page` |
|
|
185
|
+
| 12 | `owner_with_detail(user_id, community_id, space_id)` | 详情 | GET | `/api/space/archive/archive/detailSensitive` |
|
|
186
|
+
| 13 | `car_with_paginator(payload)` | 分页 | POST | `/api/space/carManage/pageCarManage` |
|
|
187
|
+
| 14 | `car_with_detail(id)` | 详情 | GET | `/api/space/carManage/detail` |
|
|
188
|
+
| 15 | `parking_space_with_paginator(payload)` | 分页 | POST | `/api/space/parking/parkingPage` |
|
|
189
|
+
| 16 | `parking_space_with_detail(id)` | 详情 | GET | `/api/space/parking/getParking` |
|
|
190
|
+
|
|
191
|
+
### workflow_center(工作台 / 流程中心)— 7 个查询
|
|
192
|
+
|
|
193
|
+
| # | 方法 | 说明 | API 路径 |
|
|
194
|
+
|---|------|------|----------|
|
|
195
|
+
| 1 | `approval_todo_with_paginator(payload)` | 我待办(审批中) | `/api/bpm/process/approval` |
|
|
196
|
+
| 2 | `approval_done_with_paginator(payload)` | 我已通过 | 同上 |
|
|
197
|
+
| 3 | `approval_rejected_with_paginator(payload)` | 我已拒绝 | 同上 |
|
|
198
|
+
| 4 | `approval_with_paginator(payload)` | 审批数据(自由筛选) | 同上 |
|
|
199
|
+
| 5 | `approval_with_detail(instance_id, node_id)` | 审批详情 / 进度 | `/api/bpm/process/progress` |
|
|
200
|
+
| 6 | `notice_with_paginator(payload)` | 消息通知列表 | `/api/msg/noticeBusiness/page` |
|
|
201
|
+
| 7 | `wbs_message_with_detail()` | WBS 告警弹窗 | `/api/alert/alertWbsMessage/getAlertWbsMessage` |
|
|
202
|
+
|
|
203
|
+
## 缓存机制
|
|
204
|
+
|
|
205
|
+
SDK 自动缓存 authorization,避免每次请求都登录。默认使用 diskcache 本地文件缓存。
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
# 默认:diskcache 本地文件缓存
|
|
209
|
+
config = ShanshuAPIConfig(account="...", password="...")
|
|
210
|
+
config.authorization_cache.directory # .cache/py_wisharetec_sdk/shanshu
|
|
211
|
+
|
|
212
|
+
# 切换 Redis 分布式缓存
|
|
213
|
+
from py_wisharetec_sdk.core.shangshu.base.cache import ShanshuAuthorizationRedis
|
|
214
|
+
|
|
215
|
+
config = ShanshuAPIConfig(
|
|
216
|
+
account="...",
|
|
217
|
+
password="...",
|
|
218
|
+
authorization_cache=ShanshuAuthorizationRedis("redis://localhost:6379/0"),
|
|
219
|
+
)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## 配置说明
|
|
223
|
+
|
|
224
|
+
| 字段 | 默认值 | 说明 |
|
|
225
|
+
|------|--------|------|
|
|
226
|
+
| `account` | 必填 | 善数平台账号(手机号) |
|
|
227
|
+
| `password` | 必填 | 明文密码,SDK 内部自动 MD5 |
|
|
228
|
+
| `base_url` | `https://saas.wisharetec.com` | API 基础 URL |
|
|
229
|
+
| `timeout` | `60.0` | HTTP 请求超时(秒) |
|
|
230
|
+
| `authorization_cache` | `ShanshuAuthorizationDiskcache()` | 缓存后端实例 |
|
|
231
|
+
| `authorization_cache_key_prefix` | `py_wisharetec_sdk:shanshu:account:` | 缓存 key 前缀 |
|
|
232
|
+
| `http_default_headers` | `{"client": "co-pc"}` | 所有请求携带的默认头 |
|
|
233
|
+
|
|
234
|
+
## 运行测试
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# 1. 复制并填写 .env
|
|
238
|
+
cp .env.example .env
|
|
239
|
+
# SHANSHU_ACCOUNT=18910415280
|
|
240
|
+
# SHANSHU_PASSWORD=your_password
|
|
241
|
+
|
|
242
|
+
# 2. 只跑查询(23 passed)
|
|
243
|
+
pytest tests/ -v -s
|
|
244
|
+
|
|
245
|
+
# 3. 包含写操作(会真实改动善数数据)
|
|
246
|
+
pytest tests/ -v -s --run-modify
|
|
247
|
+
|
|
248
|
+
# 4. 指定测试
|
|
249
|
+
pytest tests/test_base_archive.py -k "park"
|
|
250
|
+
pytest tests/test_workflow_center.py -k "approval"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## 依赖
|
|
254
|
+
|
|
255
|
+
| 依赖 | 版本 | 说明 |
|
|
256
|
+
|------|------|------|
|
|
257
|
+
| `httpx[http2]` | `>=0.27` | HTTP 客户端 |
|
|
258
|
+
| `pydantic` | `>=2.14.3` | 数据模型 / 校验 |
|
|
259
|
+
| `diskcache` | `>=5.6.3` | 默认 authorization 缓存后端 |
|
|
260
|
+
| `redis`(可选) | `>=5.0.0` | 分布式缓存后端 |
|
|
261
|
+
|
|
262
|
+
## 许可证
|
|
263
|
+
|
|
264
|
+
MIT © guolei
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# py-wisharetec-sdk
|
|
2
|
+
|
|
3
|
+
善数(Wisharetec)物业平台开放接口 Python SDK — 基于 httpx + pydantic v2。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🔑 **自动登录鉴权** — SDK 内部自动 MD5 密码 + 登录 + 刷新 authorization
|
|
8
|
+
- 💾 **可选缓存后端** — 默认 diskcache 本地文件缓存 authorization,可选 Redis 分布式缓存
|
|
9
|
+
- 🧩 **Facade 统一入口** — `ShanshuProvider` 挂载所有业务 API,一行调用
|
|
10
|
+
- 📦 **响应兼容** — dict / list / str / int / float / bool / null 全类型自动解析
|
|
11
|
+
- ⚡ **HTTP/2** — httpx `[http2]` 支持,连接池复用
|
|
12
|
+
- 🧪 **真实网络集成测试** — pytest + .env,一键跑通 23 个查询接口
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# 推荐(uv)
|
|
18
|
+
uv add py-wisharetec-sdk
|
|
19
|
+
|
|
20
|
+
# pip
|
|
21
|
+
pip install py-wisharetec-sdk
|
|
22
|
+
|
|
23
|
+
# 需要 Redis 缓存
|
|
24
|
+
pip install py-wisharetec-sdk[redis]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 快速开始
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from py_wisharetec_sdk.provider import ShanshuProvider
|
|
31
|
+
|
|
32
|
+
# 方式一:最简(账号密码即可)
|
|
33
|
+
provider = ShanshuProvider(
|
|
34
|
+
account="18910415280",
|
|
35
|
+
password="your_password",
|
|
36
|
+
)
|
|
37
|
+
provider.refresh_authorization()
|
|
38
|
+
|
|
39
|
+
# 方式二:自定义配置
|
|
40
|
+
from py_wisharetec_sdk.core.shangshu.base.config import ShanshuAPIConfig
|
|
41
|
+
|
|
42
|
+
config = ShanshuAPIConfig(
|
|
43
|
+
account="18910415280",
|
|
44
|
+
password="your_password",
|
|
45
|
+
base_url="https://saas.wisharetec.com",
|
|
46
|
+
timeout=60.0,
|
|
47
|
+
)
|
|
48
|
+
provider = ShanshuProvider(config=config)
|
|
49
|
+
|
|
50
|
+
# ===== 基础档案 =====
|
|
51
|
+
# 园区分页
|
|
52
|
+
resp = provider.base_archive_api.park_with_paginator()
|
|
53
|
+
for park in resp.data["records"]:
|
|
54
|
+
print(park["name"], park["city"], park["area"])
|
|
55
|
+
|
|
56
|
+
# 园区详情
|
|
57
|
+
detail = provider.base_archive_api.park_with_detail("7653f011-4d9d-11ec-aa56-005056b13afd")
|
|
58
|
+
print(detail.data["name"], detail.data["street"])
|
|
59
|
+
|
|
60
|
+
# ===== 工作台 / 流程中心 =====
|
|
61
|
+
# 审批待办
|
|
62
|
+
todos = provider.workflow_center_api.approval_todo_with_paginator()
|
|
63
|
+
for item in todos.data["records"]:
|
|
64
|
+
print(item["title"], item["nodeName"])
|
|
65
|
+
|
|
66
|
+
# 消息通知
|
|
67
|
+
notices = provider.workflow_center_api.notice_with_paginator()
|
|
68
|
+
for n in notices.data["records"]:
|
|
69
|
+
print(n["title"], n["createTime"])
|
|
70
|
+
|
|
71
|
+
provider.close()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 响应模型
|
|
75
|
+
|
|
76
|
+
所有 API 返回 :class:`ShanshuCommonResponse`,提供三个便捷访问:
|
|
77
|
+
|
|
78
|
+
| 属性 | 说明 |
|
|
79
|
+
|------|------|
|
|
80
|
+
| `resp.ok()` | `bool` — 是否成功(失败响应特征:同时有 code + msg 且无业务字段) |
|
|
81
|
+
| `resp.data` | `dict` — dict 响应的业务字段集合 |
|
|
82
|
+
| `resp.raw` | `Any` — 非 dict 响应的原始值(list / str / int / float / bool / null) |
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
resp = provider.workflow_center_api.wbs_message_with_detail()
|
|
86
|
+
if resp.raw is not None:
|
|
87
|
+
print("WBS 告警:", resp.raw) # resp.raw 是 list
|
|
88
|
+
else:
|
|
89
|
+
print(resp.data.get("msg")) # resp.data 是 dict
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 项目结构
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
py_wisharetec_sdk/
|
|
96
|
+
├── src/py_wisharetec_sdk/
|
|
97
|
+
│ ├── __init__.py
|
|
98
|
+
│ ├── _version.py # 版本号(hatchling 动态读取)
|
|
99
|
+
│ ├── provider.py # Facade 主入口:ShanshuProvider
|
|
100
|
+
│ ├── core/shangshu/
|
|
101
|
+
│ │ ├── base/
|
|
102
|
+
│ │ │ ├── __init__.py
|
|
103
|
+
│ │ │ ├── api.py # ShanshuBaseAPI(登录/鉴权/HTTP)
|
|
104
|
+
│ │ │ ├── config.py # ShanshuAPIConfig(Pydantic)
|
|
105
|
+
│ │ │ ├── cache.py # ShanshuAuthorizationDiskcache / Redis
|
|
106
|
+
│ │ │ └── models.py # ShanshuCommonResponse / QueryPaginatorPayload
|
|
107
|
+
│ │ ├── base_archive/api.py # 基础档案(园区/房产/车场/楼幢/用户/业主/车辆/车位)
|
|
108
|
+
│ │ └── workflow_center/api.py # 工作台(审批/消息/WBS)
|
|
109
|
+
│ └── utils/
|
|
110
|
+
├── tests/
|
|
111
|
+
│ ├── conftest.py # pytest 选项注册(--run-modify)
|
|
112
|
+
│ ├── test_base_archive.py # 16 查询 + 3 写操作(默认 skip)
|
|
113
|
+
│ └── test_workflow_center.py # 7 查询
|
|
114
|
+
├── pyproject.toml # hatchling + ruff + mypy + pytest 配置
|
|
115
|
+
├── .env.example # 集成测试账号密码模板
|
|
116
|
+
└── LICENSE
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## API 速查表
|
|
120
|
+
|
|
121
|
+
### base_archive(基础档案)— 16 个查询
|
|
122
|
+
|
|
123
|
+
| # | 方法 | 类型 | HTTP | API 路径 |
|
|
124
|
+
|---|------|------|------|----------|
|
|
125
|
+
| 1 | `park_with_paginator(payload)` | 分页 | POST | `/api/space/community/v2/frontPage` |
|
|
126
|
+
| 2 | `park_with_detail(id)` | 详情 | GET | `/api/space/community/v2/getDetail` |
|
|
127
|
+
| 3 | `house_with_paginator(payload)` | 分页 | POST | `/api/space/property/propertyPage` |
|
|
128
|
+
| 4 | `house_with_detail(id)` | 详情 | GET | `/api/space/property/getProperty` |
|
|
129
|
+
| 5 | `parking_lot_with_paginator(payload)` | 分页 | POST | `/api/space/space/yardArchivePage` |
|
|
130
|
+
| 6 | `parking_lot_with_detail(id)` | 详情 | GET | `/api/space/space/getYardArchivePage` |
|
|
131
|
+
| 7 | `building_with_paginator(payload)` | 分页 | POST | `/api/space/property/getSpaceBuildingPage` |
|
|
132
|
+
| 8 | `building_with_detail(building_id)` | 详情 | GET | `/api/space/property/getSpaceBuildingDetail` |
|
|
133
|
+
| 9 | `user_with_paginator(payload)` | 分页 | POST | `/api/user/residentInfo/getResidentPage` |
|
|
134
|
+
| 10 | `user_with_detail(user_id)` | 详情 | GET | `/api/user/residentInfo/getResidentInfo` |
|
|
135
|
+
| 11 | `owner_with_paginator(payload)` | 分页 | POST | `/api/space/archive/examine/page` |
|
|
136
|
+
| 12 | `owner_with_detail(user_id, community_id, space_id)` | 详情 | GET | `/api/space/archive/archive/detailSensitive` |
|
|
137
|
+
| 13 | `car_with_paginator(payload)` | 分页 | POST | `/api/space/carManage/pageCarManage` |
|
|
138
|
+
| 14 | `car_with_detail(id)` | 详情 | GET | `/api/space/carManage/detail` |
|
|
139
|
+
| 15 | `parking_space_with_paginator(payload)` | 分页 | POST | `/api/space/parking/parkingPage` |
|
|
140
|
+
| 16 | `parking_space_with_detail(id)` | 详情 | GET | `/api/space/parking/getParking` |
|
|
141
|
+
|
|
142
|
+
### workflow_center(工作台 / 流程中心)— 7 个查询
|
|
143
|
+
|
|
144
|
+
| # | 方法 | 说明 | API 路径 |
|
|
145
|
+
|---|------|------|----------|
|
|
146
|
+
| 1 | `approval_todo_with_paginator(payload)` | 我待办(审批中) | `/api/bpm/process/approval` |
|
|
147
|
+
| 2 | `approval_done_with_paginator(payload)` | 我已通过 | 同上 |
|
|
148
|
+
| 3 | `approval_rejected_with_paginator(payload)` | 我已拒绝 | 同上 |
|
|
149
|
+
| 4 | `approval_with_paginator(payload)` | 审批数据(自由筛选) | 同上 |
|
|
150
|
+
| 5 | `approval_with_detail(instance_id, node_id)` | 审批详情 / 进度 | `/api/bpm/process/progress` |
|
|
151
|
+
| 6 | `notice_with_paginator(payload)` | 消息通知列表 | `/api/msg/noticeBusiness/page` |
|
|
152
|
+
| 7 | `wbs_message_with_detail()` | WBS 告警弹窗 | `/api/alert/alertWbsMessage/getAlertWbsMessage` |
|
|
153
|
+
|
|
154
|
+
## 缓存机制
|
|
155
|
+
|
|
156
|
+
SDK 自动缓存 authorization,避免每次请求都登录。默认使用 diskcache 本地文件缓存。
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
# 默认:diskcache 本地文件缓存
|
|
160
|
+
config = ShanshuAPIConfig(account="...", password="...")
|
|
161
|
+
config.authorization_cache.directory # .cache/py_wisharetec_sdk/shanshu
|
|
162
|
+
|
|
163
|
+
# 切换 Redis 分布式缓存
|
|
164
|
+
from py_wisharetec_sdk.core.shangshu.base.cache import ShanshuAuthorizationRedis
|
|
165
|
+
|
|
166
|
+
config = ShanshuAPIConfig(
|
|
167
|
+
account="...",
|
|
168
|
+
password="...",
|
|
169
|
+
authorization_cache=ShanshuAuthorizationRedis("redis://localhost:6379/0"),
|
|
170
|
+
)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 配置说明
|
|
174
|
+
|
|
175
|
+
| 字段 | 默认值 | 说明 |
|
|
176
|
+
|------|--------|------|
|
|
177
|
+
| `account` | 必填 | 善数平台账号(手机号) |
|
|
178
|
+
| `password` | 必填 | 明文密码,SDK 内部自动 MD5 |
|
|
179
|
+
| `base_url` | `https://saas.wisharetec.com` | API 基础 URL |
|
|
180
|
+
| `timeout` | `60.0` | HTTP 请求超时(秒) |
|
|
181
|
+
| `authorization_cache` | `ShanshuAuthorizationDiskcache()` | 缓存后端实例 |
|
|
182
|
+
| `authorization_cache_key_prefix` | `py_wisharetec_sdk:shanshu:account:` | 缓存 key 前缀 |
|
|
183
|
+
| `http_default_headers` | `{"client": "co-pc"}` | 所有请求携带的默认头 |
|
|
184
|
+
|
|
185
|
+
## 运行测试
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# 1. 复制并填写 .env
|
|
189
|
+
cp .env.example .env
|
|
190
|
+
# SHANSHU_ACCOUNT=18910415280
|
|
191
|
+
# SHANSHU_PASSWORD=your_password
|
|
192
|
+
|
|
193
|
+
# 2. 只跑查询(23 passed)
|
|
194
|
+
pytest tests/ -v -s
|
|
195
|
+
|
|
196
|
+
# 3. 包含写操作(会真实改动善数数据)
|
|
197
|
+
pytest tests/ -v -s --run-modify
|
|
198
|
+
|
|
199
|
+
# 4. 指定测试
|
|
200
|
+
pytest tests/test_base_archive.py -k "park"
|
|
201
|
+
pytest tests/test_workflow_center.py -k "approval"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## 依赖
|
|
205
|
+
|
|
206
|
+
| 依赖 | 版本 | 说明 |
|
|
207
|
+
|------|------|------|
|
|
208
|
+
| `httpx[http2]` | `>=0.27` | HTTP 客户端 |
|
|
209
|
+
| `pydantic` | `>=2.14.3` | 数据模型 / 校验 |
|
|
210
|
+
| `diskcache` | `>=5.6.3` | 默认 authorization 缓存后端 |
|
|
211
|
+
| `redis`(可选) | `>=5.0.0` | 分布式缓存后端 |
|
|
212
|
+
|
|
213
|
+
## 许可证
|
|
214
|
+
|
|
215
|
+
MIT © guolei
|