diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..c5516b6b91a533ada96b49e05d5fcd170d7dbaa7 --- /dev/null +++ b/README.en.md @@ -0,0 +1,179 @@ +# SNMS Identifier Resolution Platform Interface Scripts + +The SNMS Identifier Resolution Platform is a comprehensive platform used for identifier registration, resolution, and management. This project provides API client implementations in both Java and Python languages, facilitating developers in quickly integrating identifier resolution functionality. + +## Project Introduction + +This project encapsulates the complete RESTful API of the SNMS platform, providing the following core functional modules: + +- **Authentication** - User registration, login authentication (supports ciphertext/plain text mode) +- **Enterprise Management** - Enterprise registration, information updates, file uploads +- **Prefix Management** - Prefix configuration, query, pagination retrieval +- **Identity Management** - Identity registration, query, update, batch operations +- **Template Management** - Template creation, query, update, deletion +- **Statistical Analysis** - Total statistics, prefix statistics, daily/monthly statistics + +## Tech Stack + +- **Java Version**: Java 1.8+, depends on HttpClient +- **Python Version**: Python 3.6+, depends on requests library + +## Quick Start + +### Java Edition + +1. **Environment Requirements** + - JDK 1.8 or higher version + - Maven or Gradle build tool + +2. **Add Dependencies** + Download the required jar packages (httpcomponents, json, etc.) and add them to the project classpath. + +3. **Compile and Run** + ```bash + # Compile all files + javac -cp ".:lib/*" *.java + + # Run example + java -cp ".:lib/*" SNMSClient + ``` + +4. **Basic Usage** + ```java + // Create client + SNMSClient client = new SNMSClient("http://your-api-server"); + + // Login to get token (ciphertext mode) + JSONObject loginResult = client.getAuth().getTokenCipher("username", "password"); + String token = loginResult.getString("token"); + + // Sync token to all modules + client.setToken(token); + + // Call various interfaces + JSONObject entList = client.getEnterprise().listEnterprises(null, null, null, 1, 10); + ``` + +### Python Edition + +1. **Environment Requirements** + - Python 3.6+ + - requests library + +2. **Install Dependencies** + ```bash + pip install requests + ``` + +3. **Basic Usage** + ```python + from client import SNMSClient + + # Create client + client = SNMSClient(base_url="http://your-api-server") + + # Login to get token (ciphertext mode) + result = client.auth.get_token_cipher("username", "password") + token = result.get("token") + + # Sync token to all modules + client.set_token(token) + + # Call various interfaces + ent_list = client.enterprise.list_enterprises() + ``` + +## API Documentation + +### Authentication Module (AuthAPI) + +| Method | Description | +|------|------| +| getTokenCipher(username, password) | Get Token in ciphertext mode (Recommended) | +| getTokenPlain(username, password) | Get Token in plain text mode | +| registerUser(username, password, email, mobile, ...) | Register new user | + +### Enterprise Module (EnterpriseAPI) + +| Method | Description | +|------|------| +| registerWithUser(sysUser, entBasicInfo, ...) | Register enterprise with user information | +| registerEnterprise(username, entBasicInfo, ...) | Register enterprise specifying user | +| uploadFile(filePath) | Upload file | +| updateEnterprise(orgInfo) | Update enterprise information | +| listEnterprises(orgName, startDate, endDate, page, size) | Get enterprise list | +| enterpriseDetail(entId) | Get enterprise details | + +### Prefix Module (PrefixAPI) + +| Method | Description | +|------|------| +| queryPrefix(prefix) | Query prefix information | +| prefixPage(entName, entPrefix, startDate, endDate, page, size) | Paginated query for prefixes | +| configHostedPrefix(proxyServerId, entPrefix) | Configure hosted prefix | +| configUnhostedPrefix(entPrefix, hdlType, ip, ipType, ...) | Configure unhosted prefix | + +### Identity Module (IdentityAPI) + +| Method | Description | +|------|------| +| queryIdentity(handle) | Query identity | +| registerIdentity(handle, templateVersion, values) | Register identity | +| batchRegisterIdentity(identityList) | Batch register identities | +| updateIdentity(handle, templateVersion, values) | Update identity | +| batchUpdateIdentity(identityList) | Batch update identities | +| deleteIdentity(handle) | Delete identity | +| batchDeleteIdentity(handleList) | Batch delete identities | + +### Template Module (TemplateAPI) + +| Method | Description | +|------|------| +| queryTemplate(prefix, version) | Query template | +| createTemplate(prefix, version, industryCategory, ...) | Create template | +| updateTemplate(prefix, version, industryCategory, ...) | Update template | +| deleteTemplate(prefix, version) | Delete template | + +### Statistics Module (StatisticsAPI) + +| Method | Description | +|------|------| +| totalStatistics(prefix) | Get total statistics | +| prefixStatistics(prefix, startDate, endDate) | Get prefix statistics | +| dailyStatistics(date, prefix) | Get daily statistics | +| monthlyStatistics(year, month, prefix) | Get monthly statistics | + +## File Description + +``` +. +├── java/ +│ ├── AuthAPI.java # Authentication interface implementation +│ ├── EnterpriseAPI.java # Enterprise management interface +│ ├── HttpClientUtil.java # HTTP client utility +│ ├── IdentityAPI.java # Identity management interface +│ ├── PrefixAPI.java # Prefix management interface +│ ├── SNMSClient.java # Main client class +│ ├── StatisticsAPI.java # Statistical analysis interface +│ └── TemplateAPI.java # Template management interface +├── python/ +│ ├── auth_api.py # Authentication interface +│ ├── client.py # Main client +│ ├── enterprise_api.py # Enterprise management interface +│ ├── identity_api.py # Identity management interface +│ ├── prefix_api.py # Prefix management interface +│ ├── statistics_api.py # Statistical analysis interface +│ └── template_api.py # Template management interface +└── LICENSE # License file +``` + +## Notes + +1. **Authentication Method**: It is recommended to use `getTokenCipher` ciphertext mode to obtain Token for higher security +2. **Token Management**: After obtaining the Token, you need to call `client.setToken()` to sync it to all API modules +3. **Error Handling**: API calls will return error messages upon failure; it is recommended to add exception handling logic +4. **Parameter Validation**: Before use, ensure required parameters are passed correctly and parameter formats comply with platform requirements + +## License + +This project follows the open source license agreement. For specific information, please refer to the LICENSE file. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..fd954afde133baf0a732528bc84a2c03835f37e3 --- /dev/null +++ b/README.md @@ -0,0 +1,181 @@ + + +# SNMS 标识解析平台接口脚本 + +SNMS 标识解析平台是一个用于标识注册、解析和管理的综合平台。本项目提供了 Java 和 Python 两种语言的 API 客户端实现,方便开发者快速集成标识解析功能。 + +## 项目简介 + +本项目封装了 SNMS 平台的完整 RESTful API,提供以下核心功能模块: + +- **身份认证** - 用户注册、登录认证(支持密文/明文模式) +- **企业管理** - 企业注册、信息更新、文件上传 +- **前缀管理** - 前缀配置、查询、分页检索 +- **标识管理** - 标识注册、查询、更新、批量操作 +- **模板管理** - 模板创建、查询、更新、删除 +- **统计分析** - 总量统计、前缀统计、日/月度统计 + +## 技术栈 + +- **Java 版本**:Java 1.8+,依赖 HttpClient +- **Python 版本**:Python 3.6+,依赖 requests 库 + +## 快速开始 + +### Java 版 + +1. **环境要求** + - JDK 1.8 或更高版本 + - Maven 或 Gradle 构建工具 + +2. **添加依赖** + 下载所需的 jar 包(httpcomponents、json 等),添加到项目 classpath 中。 + +3. **编译运行** + ```bash + # 编译所有文件 + javac -cp ".:lib/*" *.java + + # 运行示例 + java -cp ".:lib/*" SNMSClient + ``` + +4. **基本使用** + ```java + // 创建客户端 + SNMSClient client = new SNMSClient("http://your-api-server"); + + // 登录获取 token(密文模式) + JSONObject loginResult = client.getAuth().getTokenCipher("username", "password"); + String token = loginResult.getString("token"); + + // 同步 token 到所有模块 + client.setToken(token); + + // 调用各接口 + JSONObject entList = client.getEnterprise().listEnterprises(null, null, null, 1, 10); + ``` + +### Python 版 + +1. **环境要求** + - Python 3.6+ + - requests 库 + +2. **安装依赖** + ```bash + pip install requests + ``` + +3. **基本使用** + ```python + from client import SNMSClient + + # 创建客户端 + client = SNMSClient(base_url="http://your-api-server") + + # 登录获取 token(密文模式) + result = client.auth.get_token_cipher("username", "password") + token = result.get("token") + + # 同步 token 到所有模块 + client.set_token(token) + + # 调用各接口 + ent_list = client.enterprise.list_enterprises() + ``` + +## API 文档 + +### 认证模块 (AuthAPI) + +| 方法 | 说明 | +|------|------| +| getTokenCipher(username, password) | 密文模式获取 Token(推荐) | +| getTokenPlain(username, password) | 明文模式获取 Token | +| registerUser(username, password, email, mobile, ...) | 注册新用户 | + +### 企业模块 (EnterpriseAPI) + +| 方法 | 说明 | +|------|------| +| registerWithUser(sysUser, entBasicInfo, ...) | 带用户信息注册企业 | +| registerEnterprise(username, entBasicInfo, ...) | 指定用户注册企业 | +| uploadFile(filePath) | 上传文件 | +| updateEnterprise(orgInfo) | 更新企业信息 | +| listEnterprises(orgName, startDate, endDate, page, size) | 获取企业列表 | +| enterpriseDetail(entId) | 获取企业详情 | + +### 前缀模块 (PrefixAPI) + +| 方法 | 说明 | +|------|------| +| queryPrefix(prefix) | 查询前缀信息 | +| prefixPage(entName, entPrefix, startDate, endDate, page, size) | 分页查询前缀 | +| configHostedPrefix(proxyServerId, entPrefix) | 配置托管前缀 | +| configUnhostedPrefix(entPrefix, hdlType, ip, ipType, ...) | 配置非托管前缀 | + +### 标识模块 (IdentityAPI) + +| 方法 | 说明 | +|------|------| +| queryIdentity(handle) | 查询标识 | +| registerIdentity(handle, templateVersion, values) | 注册标识 | +| batchRegisterIdentity(identityList) | 批量注册标识 | +| updateIdentity(handle, templateVersion, values) | 更新标识 | +| batchUpdateIdentity(identityList) | 批量更新标识 | +| deleteIdentity(handle) | 删除标识 | +| batchDeleteIdentity(handleList) | 批量删除标识 | + +### 模板模块 (TemplateAPI) + +| 方法 | 说明 | +|------|------| +| queryTemplate(prefix, version) | 查询模板 | +| createTemplate(prefix, version, industryCategory, ...) | 创建模板 | +| updateTemplate(prefix, version, industryCategory, ...) | 更新模板 | +| deleteTemplate(prefix, version) | 删除模板 | + +### 统计模块 (StatisticsAPI) + +| 方法 | 说明 | +|------|------| +| totalStatistics(prefix) | 获取总量统计 | +| prefixStatistics(prefix, startDate, endDate) | 获取前缀统计 | +| dailyStatistics(date, prefix) | 获取日统计 | +| monthlyStatistics(year, month, prefix) | 获取月度统计 | + +## 文件说明 + +``` +. +├── java/ +│ ├── AuthAPI.java # 认证接口实现 +│ ├── EnterpriseAPI.java # 企业管理接口 +│ ├── HttpClientUtil.java # HTTP 客户端工具 +│ ├── IdentityAPI.java # 标识管理接口 +│ ├── PrefixAPI.java # 前缀管理接口 +│ ├── SNMSClient.java # 主客户端类 +│ ├── StatisticsAPI.java # 统计分析接口 +│ └── TemplateAPI.java # 模板管理接口 +├── python/ +│ ├── auth_api.py # 认证接口 +│ ├── client.py # 主客户端 +│ ├── enterprise_api.py # 企业管理接口 +│ ├── identity_api.py # 标识管理接口 +│ ├── prefix_api.py # 前缀管理接口 +│ ├── statistics_api.py # 统计分析接口 +│ └── template_api.py # 模板管理接口 +└── LICENSE # 许可证文件 +``` + +## 注意事项 + +1. **认证方式**:推荐使用 `getTokenCipher` 密文模式获取 Token,安全性更高 +2. **Token 管理**:获取 Token 后需要调用 `client.setToken()` 同步到所有 API 模块 +3. **错误处理**:API 调用失败时会返回错误信息,建议添加异常处理逻辑 +4. **参数验证**:使用前请确保必填参数正确传入,参数格式符合平台要求 + +## 许可证 + +本项目遵循开源许可证协议,具体信息请参阅 LICENSE 文件。 \ No newline at end of file