init code
This commit is contained in:
54
doc/easycode/EasyCodeConfig.json
Normal file
54
doc/easycode/EasyCodeConfig.json
Normal file
File diff suppressed because one or more lines are too long
623
doc/sql/database-info.md
Normal file
623
doc/sql/database-info.md
Normal file
@@ -0,0 +1,623 @@
|
|||||||
|
Table: blade_attach(附件表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| link | VARCHAR(1000) | YES | | | 附件地址 |
|
||||||
|
| domain_url | VARCHAR(500) | YES | | | 附件域名 |
|
||||||
|
| name | VARCHAR(500) | YES | | | 附件名称 |
|
||||||
|
| original_name | VARCHAR(500) | YES | | | 附件原名 |
|
||||||
|
| extension | VARCHAR(12) | YES | | | 附件拓展名 |
|
||||||
|
| attach_size | BIGINT(20) | YES | | | 附件大小 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_client(客户端表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------------------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| client_id | VARCHAR(48) | NO | | | 客户端id |
|
||||||
|
| client_secret | VARCHAR(256) | NO | | | 客户端密钥 |
|
||||||
|
| resource_ids | VARCHAR(256) | YES | | | 资源集合 |
|
||||||
|
| scope | VARCHAR(256) | NO | | | 授权范围 |
|
||||||
|
| authorized_grant_types | VARCHAR(256) | NO | | | 授权类型 |
|
||||||
|
| web_server_redirect_uri | VARCHAR(256) | YES | | | 回调地址 |
|
||||||
|
| authorities | VARCHAR(256) | YES | | | 权限 |
|
||||||
|
| access_token_validity | INT(10) | NO | | | 令牌过期秒数 |
|
||||||
|
| refresh_token_validity | INT(10) | NO | | | 刷新令牌过期秒数|
|
||||||
|
| additional_information | VARCHAR(4096) | YES | | | 附加说明 |
|
||||||
|
| autoapprove | VARCHAR(256) | YES | | | 自动授权 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | NO | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | NO | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_code(代码生成表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| model_id | BIGINT(20) | YES | | | 数据模型主键 |
|
||||||
|
| service_name | VARCHAR(64) | YES | | | 服务名称 |
|
||||||
|
| code_name | VARCHAR(64) | YES | | | 模块名称 |
|
||||||
|
| table_name | VARCHAR(64) | YES | | | 表名 |
|
||||||
|
| table_prefix | VARCHAR(64) | YES | | | 表前缀 |
|
||||||
|
| pk_name | VARCHAR(32) | YES | | | 主键名 |
|
||||||
|
| package_name | VARCHAR(500) | YES | | | 后端包名 |
|
||||||
|
| template_type | VARCHAR(32) | YES | | | 模版类型 |
|
||||||
|
| author | VARCHAR(32) | YES | | | 作者信息 |
|
||||||
|
| sub_model_id | VARCHAR(32) | YES | | | 子表模型主键 |
|
||||||
|
| sub_fk_id | VARCHAR(32) | YES | | | 子表绑定外键 |
|
||||||
|
| tree_id | VARCHAR(32) | YES | | | 树主键字段 |
|
||||||
|
| tree_pid | VARCHAR(32) | YES | | | 树父主键字段 |
|
||||||
|
| tree_name | VARCHAR(64) | YES | | | 树名称字段 |
|
||||||
|
| base_mode | INT(10) | YES | | | 基础业务模式 |
|
||||||
|
| wrap_mode | INT(10) | YES | | | 包装器模式 |
|
||||||
|
| feign_mode | INT(10) | YES | | | 远程调用模式 |
|
||||||
|
| code_style | VARCHAR(32) | YES | | | 代码风格 |
|
||||||
|
| api_path | VARCHAR(2000) | YES | | | 后端路径 |
|
||||||
|
| web_path | VARCHAR(2000) | YES | | | 前端路径 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_datasource(数据源配置表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------ | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| name | VARCHAR(100) | YES | | | 名称 |
|
||||||
|
| driver_class | VARCHAR(100) | YES | | | 驱动类 |
|
||||||
|
| url | VARCHAR(500) | YES | | | 连接地址 |
|
||||||
|
| username | VARCHAR(50) | YES | | | 用户名 |
|
||||||
|
| password | VARCHAR(50) | YES | | | 密码 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 备注 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_dept(机构表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| parent_id | BIGINT(20) | YES | | 0 | 父主键 |
|
||||||
|
| ancestors | VARCHAR(2000) | YES | | | 祖级列表 |
|
||||||
|
| dept_category | INT(10) | YES | | | 部门类型 |
|
||||||
|
| dept_name | VARCHAR(45) | YES | | | 部门名 |
|
||||||
|
| full_name | VARCHAR(45) | YES | | | 部门全称 |
|
||||||
|
| sort | INT(10) | YES | | | 排序 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 备注 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_dict(字典表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ---------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| parent_id | BIGINT(20) | YES | | 0 | 父主键 |
|
||||||
|
| code | VARCHAR(255) | YES | | | 字典码 |
|
||||||
|
| dict_key | VARCHAR(255) | YES | | | 字典值 |
|
||||||
|
| dict_value | VARCHAR(255) | YES | | | 字典名称 |
|
||||||
|
| sort | INT(10) | YES | | | 排序 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 字典备注 |
|
||||||
|
| is_sealed | INT(10) | YES | | 0 | 是否已封存 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_dict_biz(业务字典表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ---------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | | 租户ID |
|
||||||
|
| parent_id | BIGINT(20) | YES | | 0 | 父主键 |
|
||||||
|
| code | VARCHAR(255) | YES | | | 字典码 |
|
||||||
|
| dict_key | VARCHAR(255) | YES | | | 字典值 |
|
||||||
|
| dict_value | VARCHAR(255) | YES | | | 字典名称 |
|
||||||
|
| sort | INT(10) | YES | | | 排序 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 字典备注 |
|
||||||
|
| is_sealed | INT(10) | YES | | 0 | 是否已封存 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_log_api(接口日志表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------ | ------------- | ---- | --- | ----------------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 编号 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| service_id | VARCHAR(32) | YES | | | 服务ID |
|
||||||
|
| server_host | VARCHAR(255) | YES | | | 服务器名 |
|
||||||
|
| server_ip | VARCHAR(255) | YES | | | 服务器IP地址 |
|
||||||
|
| env | VARCHAR(255) | YES | | | 服务器环境 |
|
||||||
|
| type | CHAR(1) | YES | | 1 | 日志类型 |
|
||||||
|
| title | VARCHAR(255) | YES | | | 日志标题 |
|
||||||
|
| method | VARCHAR(10) | YES | | | 操作方式 |
|
||||||
|
| request_uri | VARCHAR(255) | YES | | | 请求URI |
|
||||||
|
| user_agent | VARCHAR(1000) | YES | | | 用户代理 |
|
||||||
|
| remote_ip | VARCHAR(255) | YES | | | 操作IP地址 |
|
||||||
|
| method_class | VARCHAR(255) | YES | | | 方法类 |
|
||||||
|
| method_name | VARCHAR(255) | YES | | | 方法名 |
|
||||||
|
| params | TEXT(65535) | YES | | | 操作提交的数据 |
|
||||||
|
| time | VARCHAR(64) | YES | | | 执行时间 |
|
||||||
|
| create_by | VARCHAR(64) | YES | | | 创建者 |
|
||||||
|
| create_time | DATETIME(19) | YES | | CURRENT_TIMESTAMP | 创建时间 |
|
||||||
|
|
||||||
|
Table: blade_log_error(错误日志表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| -------------- | ------------- | ---- | --- | ----------------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 编号 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| service_id | VARCHAR(32) | YES | | | 服务ID |
|
||||||
|
| server_host | VARCHAR(255) | YES | | | 服务器名 |
|
||||||
|
| server_ip | VARCHAR(255) | YES | | | 服务器IP地址 |
|
||||||
|
| env | VARCHAR(255) | YES | | | 系统环境 |
|
||||||
|
| method | VARCHAR(10) | YES | | | 操作方式 |
|
||||||
|
| request_uri | VARCHAR(255) | YES | | | 请求URI |
|
||||||
|
| user_agent | VARCHAR(1000) | YES | | | 用户代理 |
|
||||||
|
| stack_trace | TEXT(65535) | YES | | | 堆栈 |
|
||||||
|
| exception_name | VARCHAR(255) | YES | | | 异常名 |
|
||||||
|
| message | TEXT(65535) | YES | | | 异常信息 |
|
||||||
|
| line_number | INT(10) | YES | | | 错误行数 |
|
||||||
|
| remote_ip | VARCHAR(255) | YES | | | 操作IP地址 |
|
||||||
|
| method_class | VARCHAR(255) | YES | | | 方法类 |
|
||||||
|
| file_name | VARCHAR(1000) | YES | | | 文件名 |
|
||||||
|
| method_name | VARCHAR(255) | YES | | | 方法名 |
|
||||||
|
| params | TEXT(65535) | YES | | | 操作提交的数据 |
|
||||||
|
| create_by | VARCHAR(64) | YES | | | 创建者 |
|
||||||
|
| create_time | DATETIME(19) | YES | | CURRENT_TIMESTAMP | 创建时间 |
|
||||||
|
|
||||||
|
Table: blade_log_usual(通用日志表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------ | ------------- | ---- | --- | ----------------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 编号 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| service_id | VARCHAR(32) | YES | | | 服务ID |
|
||||||
|
| server_host | VARCHAR(255) | YES | | | 服务器名 |
|
||||||
|
| server_ip | VARCHAR(255) | YES | | | 服务器IP地址 |
|
||||||
|
| env | VARCHAR(255) | YES | | | 系统环境 |
|
||||||
|
| log_level | VARCHAR(10) | YES | | | 日志级别 |
|
||||||
|
| log_id | VARCHAR(100) | YES | | | 日志业务id |
|
||||||
|
| log_data | TEXT(65535) | YES | | | 日志数据 |
|
||||||
|
| method | VARCHAR(10) | YES | | | 操作方式 |
|
||||||
|
| request_uri | VARCHAR(255) | YES | | | 请求URI |
|
||||||
|
| remote_ip | VARCHAR(255) | YES | | | 操作IP地址 |
|
||||||
|
| method_class | VARCHAR(255) | YES | | | 方法类 |
|
||||||
|
| method_name | VARCHAR(255) | YES | | | 方法名 |
|
||||||
|
| user_agent | VARCHAR(1000) | YES | | | 用户代理 |
|
||||||
|
| params | TEXT(65535) | YES | | | 操作提交的数据 |
|
||||||
|
| create_by | VARCHAR(64) | YES | | | 创建者 |
|
||||||
|
| create_time | DATETIME(19) | YES | | CURRENT_TIMESTAMP | 创建时间 |
|
||||||
|
|
||||||
|
Table: blade_menu(菜单表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ---------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| parent_id | BIGINT(20) | YES | | 0 | 父级菜单 |
|
||||||
|
| code | VARCHAR(255) | YES | | | 菜单编号 |
|
||||||
|
| name | VARCHAR(255) | YES | | | 菜单名称 |
|
||||||
|
| alias | VARCHAR(255) | YES | | | 菜单别名 |
|
||||||
|
| path | VARCHAR(255) | YES | | | 请求地址 |
|
||||||
|
| source | VARCHAR(255) | YES | | | 菜单资源 |
|
||||||
|
| sort | INT(10) | YES | | | 排序 |
|
||||||
|
| category | INT(10) | YES | | | 菜单类型 |
|
||||||
|
| action | INT(10) | YES | | 0 | 操作按钮类型 |
|
||||||
|
| is_open | INT(10) | YES | | 1 | 是否打开新页面 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 备注 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
|
||||||
|
Table: blade_model(数据模型表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| datasource_id | BIGINT(20) | YES | | | 数据源主键 |
|
||||||
|
| model_name | VARCHAR(50) | YES | | | 模型名称 |
|
||||||
|
| model_code | VARCHAR(50) | YES | | | 模型编号 |
|
||||||
|
| model_table | VARCHAR(100) | YES | | | 物理表名 |
|
||||||
|
| model_class | VARCHAR(100) | YES | | | 模型类名 |
|
||||||
|
| model_remark | VARCHAR(500) | YES | | | 模型备注 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
|
||||||
|
Table: blade_model_prototype(数据原型表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| -------------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| model_id | BIGINT(20) | YES | | | 模型主键 |
|
||||||
|
| jdbc_name | VARCHAR(50) | YES | | | 物理列名 |
|
||||||
|
| jdbc_type | VARCHAR(20) | YES | | | 物理类型 |
|
||||||
|
| comment | VARCHAR(500) | YES | | | 注释说明 |
|
||||||
|
| property_type | VARCHAR(20) | YES | | | 实体类型 |
|
||||||
|
| property_entity| VARCHAR(500) | YES | | | 实体类型引用|
|
||||||
|
| property_name | VARCHAR(50) | YES | | | 实体列名 |
|
||||||
|
| is_list | INT(10) | YES | | | 列表显示 |
|
||||||
|
| is_form | INT(10) | YES | | | 表单显示 |
|
||||||
|
| is_row | INT(10) | YES | | | 独占一行 |
|
||||||
|
| component_type | VARCHAR(50) | YES | | | 组件类型 |
|
||||||
|
| dict_code | VARCHAR(50) | YES | | | 字典编码 |
|
||||||
|
| is_required | INT(10) | YES | | | 是否必填 |
|
||||||
|
| is_query | INT(10) | YES | | | 查询配置 |
|
||||||
|
| query_type | VARCHAR(50) | YES | | | 查询配置 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
|
||||||
|
Table: blade_notice(通知公告表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------ | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| title | VARCHAR(255) | YES | | | 标题 |
|
||||||
|
| category | INT(10) | YES | | | 类型 |
|
||||||
|
| release_time | DATETIME(19) | YES | | | 发布时间 |
|
||||||
|
| content | VARCHAR(2000) | YES | | | 内容 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_oss(对象存储表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| category | INT(10) | YES | | | 分类 |
|
||||||
|
| oss_code | VARCHAR(32) | YES | | | 资源编号 |
|
||||||
|
| endpoint | VARCHAR(255) | YES | | | 资源地址 |
|
||||||
|
| access_key | VARCHAR(255) | YES | | | accessKey|
|
||||||
|
| secret_key | VARCHAR(255) | YES | | | secretKey|
|
||||||
|
| bucket_name | VARCHAR(255) | YES | | | 空间名 |
|
||||||
|
| app_id | VARCHAR(255) | YES | | | 应用ID |
|
||||||
|
| region | VARCHAR(255) | YES | | | 地域简称 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 备注 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_param(参数表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| param_name | VARCHAR(255) | YES | | | 参数名 |
|
||||||
|
| param_key | VARCHAR(255) | YES | | | 参数键 |
|
||||||
|
| param_value | VARCHAR(255) | YES | | | 参数值 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 备注 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_post(岗位表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| category | INT(10) | YES | | | 岗位类型 |
|
||||||
|
| post_code | VARCHAR(12) | YES | | | 岗位编号 |
|
||||||
|
| post_name | VARCHAR(64) | YES | | | 岗位名称 |
|
||||||
|
| sort | INT(10) | YES | | | 岗位排序 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 岗位描述 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_process_leave(流程请假业务表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| --------------------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 编号 |
|
||||||
|
| process_definition_id | VARCHAR(64) | YES | | | 流程定义主键 |
|
||||||
|
| process_instance_id | VARCHAR(64) | YES | | | 流程实例主键 |
|
||||||
|
| start_time | DATETIME(19) | YES | | | 开始时间 |
|
||||||
|
| end_time | DATETIME(19) | YES | | | 结束时间 |
|
||||||
|
| reason | VARCHAR(255) | YES | | | 请假理由 |
|
||||||
|
| task_user | VARCHAR(255) | YES | | | 第一级审批人 |
|
||||||
|
| apply_time | DATETIME(19) | YES | | | 申请时间 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_region(行政区划表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| code | VARCHAR(12) | NO | PRI | | 区划编号 |
|
||||||
|
| parent_code | VARCHAR(12) | YES | | | 父区划编号 |
|
||||||
|
| ancestors | VARCHAR(255) | YES | | | 祖区划编号 |
|
||||||
|
| name | VARCHAR(32) | YES | | | 区划名称 |
|
||||||
|
| province_code | VARCHAR(12) | YES | | | 省级区划编号 |
|
||||||
|
| province_name | VARCHAR(32) | YES | | | 省级名称 |
|
||||||
|
| city_code | VARCHAR(12) | YES | | | 市级区划编号 |
|
||||||
|
| city_name | VARCHAR(32) | YES | | | 市级名称 |
|
||||||
|
| district_code | VARCHAR(12) | YES | | | 区级区划编号 |
|
||||||
|
| district_name | VARCHAR(32) | YES | | | 区级名称 |
|
||||||
|
| town_code | VARCHAR(12) | YES | | | 镇级区划编号 |
|
||||||
|
| town_name | VARCHAR(32) | YES | | | 镇级名称 |
|
||||||
|
| village_code | VARCHAR(12) | YES | | | 村级区划编号 |
|
||||||
|
| village_name | VARCHAR(32) | YES | | | 村级名称 |
|
||||||
|
| region_level | INT(10) | YES | | | 层级 |
|
||||||
|
| sort | INT(10) | YES | | | 排序 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 备注 |
|
||||||
|
|
||||||
|
Table: blade_report_file(报表文件表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------- | -------------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| name | VARCHAR(100) | NO | | | 文件名 |
|
||||||
|
| content | MEDIUMBLOB(16777215) | YES | | | 文件内容 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 更新时间 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_role(角色表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ---------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| parent_id | BIGINT(20) | YES | | 0 | 父主键 |
|
||||||
|
| role_name | VARCHAR(255) | YES | | | 角色名 |
|
||||||
|
| sort | INT(10) | YES | | | 排序 |
|
||||||
|
| role_alias | VARCHAR(255) | YES | | | 角色别名 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_role_menu(角色菜单关联表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------- | ---------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| menu_id | BIGINT(20) | YES | | | 菜单id |
|
||||||
|
| role_id | BIGINT(20) | YES | | | 角色id |
|
||||||
|
|
||||||
|
Table: blade_role_scope(角色数据权限关联表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| -------------- | ---------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| scope_category | INT(10) | YES | | | 权限类型(1:数据权限、2:接口权限)|
|
||||||
|
| scope_id | BIGINT(20) | YES | | | 权限id |
|
||||||
|
| role_id | BIGINT(20) | YES | | | 角色id |
|
||||||
|
|
||||||
|
Table: blade_scope_api(接口权限表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| menu_id | BIGINT(20) | YES | | | 菜单主键 |
|
||||||
|
| resource_code | VARCHAR(255) | YES | | | 资源编号 |
|
||||||
|
| scope_name | VARCHAR(255) | YES | | | 接口权限名 |
|
||||||
|
| scope_path | VARCHAR(255) | YES | | | 接口权限地址 |
|
||||||
|
| scope_type | INT(10) | YES | | | 接口权限类型 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 接口权限备注 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_scope_data(数据权限表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| menu_id | BIGINT(20) | YES | | | 菜单主键 |
|
||||||
|
| resource_code | VARCHAR(255) | YES | | | 资源编号 |
|
||||||
|
| scope_name | VARCHAR(255) | YES | | | 数据权限名称 |
|
||||||
|
| scope_field | VARCHAR(255) | YES | | | 数据权限字段 |
|
||||||
|
| scope_class | VARCHAR(500) | YES | | | 数据权限类名 |
|
||||||
|
| scope_column | VARCHAR(255) | YES | | | 数据权限字段 |
|
||||||
|
| scope_type | INT(10) | YES | | | 数据权限类型 |
|
||||||
|
| scope_value | VARCHAR(2000) | YES | | | 数据权限值域 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 数据权限备注 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_sms(短信配置表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| category | INT(10) | YES | | | 分类 |
|
||||||
|
| sms_code | VARCHAR(32) | YES | | | 资源编号 |
|
||||||
|
| template_id | VARCHAR(64) | YES | | | 模板ID |
|
||||||
|
| access_key | VARCHAR(255) | YES | | | accessKey|
|
||||||
|
| secret_key | VARCHAR(255) | YES | | | secretKey|
|
||||||
|
| region_id | VARCHAR(255) | YES | | | regionId|
|
||||||
|
| sign_name | VARCHAR(64) | YES | | | 短信签名 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 备注 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_tenant(租户表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| -------------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| tenant_name | VARCHAR(50) | NO | | | 租户名称 |
|
||||||
|
| domain_url | VARCHAR(255) | YES | | | 域名地址 |
|
||||||
|
| background_url | VARCHAR(1000) | YES | | | 系统背景 |
|
||||||
|
| linkman | VARCHAR(20) | YES | | | 联系人 |
|
||||||
|
| contact_number | VARCHAR(20) | YES | | | 联系电话 |
|
||||||
|
| address | VARCHAR(255) | YES | | | 联系地址 |
|
||||||
|
| account_number | INT(10) | YES | | -1 | 账号额度 |
|
||||||
|
| expire_time | DATETIME(19) | YES | | | 过期时间 |
|
||||||
|
| datasource | BIGINT(20) | YES | | | 数据源ID |
|
||||||
|
| license_key | VARCHAR(1000) | YES | | | 授权码 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_top_menu(顶部菜单表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------- | ------------ | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | | 租户id |
|
||||||
|
| code | VARCHAR(255) | YES | | | 顶部菜单编号 |
|
||||||
|
| name | VARCHAR(255) | YES | | | 顶部菜单名 |
|
||||||
|
| source | VARCHAR(255) | YES | | | 顶部菜单资源 |
|
||||||
|
| sort | INT(10) | YES | | | 顶部菜单排序 |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_top_menu_setting(顶部菜单配置表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------- | ---------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| top_menu_id | BIGINT(20) | YES | | | 顶部菜单主键 |
|
||||||
|
| menu_id | BIGINT(20) | YES | | | 菜单主键 |
|
||||||
|
|
||||||
|
Table: blade_user(用户表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ----------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | 000000 | 租户ID |
|
||||||
|
| code | VARCHAR(12) | YES | | | 用户编号 |
|
||||||
|
| user_type | SMALLINT(5) | YES | | | 用户平台 |
|
||||||
|
| account | VARCHAR(45) | YES | | | 账号 |
|
||||||
|
| password | VARCHAR(45) | YES | | | 密码 |
|
||||||
|
| name | VARCHAR(20) | YES | | | 昵称 |
|
||||||
|
| real_name | VARCHAR(10) | YES | | | 真名 |
|
||||||
|
| avatar | VARCHAR(500) | YES | | | 头像 |
|
||||||
|
| email | VARCHAR(45) | YES | | | 邮箱 |
|
||||||
|
| phone | VARCHAR(45) | YES | | | 手机 |
|
||||||
|
| birthday | DATETIME(19) | YES | | | 生日 |
|
||||||
|
| sex | SMALLINT(5) | YES | | | 性别 |
|
||||||
|
| role_id | VARCHAR(1000) | YES | | | 角色id |
|
||||||
|
| dept_id | VARCHAR(1000) | YES | | | 部门id |
|
||||||
|
| post_id | VARCHAR(1000) | YES | | | 岗位id |
|
||||||
|
| create_user | BIGINT(20) | YES | | | 创建人 |
|
||||||
|
| create_dept | BIGINT(20) | YES | | | 创建部门 |
|
||||||
|
| create_time | DATETIME(19) | YES | | | 创建时间 |
|
||||||
|
| update_user | BIGINT(20) | YES | | | 修改人 |
|
||||||
|
| update_time | DATETIME(19) | YES | | | 修改时间 |
|
||||||
|
| status | INT(10) | YES | | | 状态 |
|
||||||
|
| is_deleted | INT(10) | YES | | 0 | 是否已删除 |
|
||||||
|
|
||||||
|
Table: blade_user_dept(用户部门表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------- | ---------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| user_id | BIGINT(20) | YES | | 0 | 用户ID |
|
||||||
|
| dept_id | BIGINT(20) | YES | | 0 | 部门ID |
|
||||||
|
|
||||||
|
Table: blade_user_oauth(用户第三方认证表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| --------- | ------------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| tenant_id | VARCHAR(12) | YES | | | 租户ID |
|
||||||
|
| uuid | VARCHAR(64) | YES | | | 第三方系统用户ID|
|
||||||
|
| user_id | BIGINT(20) | YES | | | 用户ID |
|
||||||
|
| username | VARCHAR(32) | YES | | | 账号 |
|
||||||
|
| nickname | VARCHAR(64) | YES | | | 用户名 |
|
||||||
|
| avatar | VARCHAR(1000) | YES | | | 头像 |
|
||||||
|
| blog | VARCHAR(50) | YES | | | 应用主页 |
|
||||||
|
| company | VARCHAR(255) | YES | | | 公司名 |
|
||||||
|
| location | VARCHAR(255) | YES | | | 地址 |
|
||||||
|
| email | VARCHAR(255) | YES | | | 邮件 |
|
||||||
|
| remark | VARCHAR(255) | YES | | | 备注 |
|
||||||
|
| gender | VARCHAR(16) | YES | | | 性别 |
|
||||||
|
| source | VARCHAR(16) | YES | | | 来源 |
|
||||||
|
|
||||||
|
Table: blade_user_web(用户平台拓展表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------- | ---------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| user_id | BIGINT(20) | YES | | 0 | 用户ID |
|
||||||
|
| user_ext | VARCHAR(255) | YES | | | 用户拓展信息 |
|
||||||
|
|
||||||
|
Table: blade_user_app(用户平台拓展表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------- | ---------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| user_id | BIGINT(20) | YES | | 0 | 用户ID |
|
||||||
|
| user_ext | VARCHAR(255) | YES | | | 用户拓展信息 |
|
||||||
|
|
||||||
|
Table: blade_user_other(用户平台拓展表)
|
||||||
|
|
||||||
|
| Field | Type | Null | Key | Default | Remarks |
|
||||||
|
| ------- | ---------- | ---- | --- | ------- | ------- |
|
||||||
|
| id | BIGINT(20) | NO | PRI | | 主键 |
|
||||||
|
| user_id | BIGINT(19) | YES | | 0 | 用户ID |
|
||||||
|
| user_ext | VARCHAR(255) | YES | | | 用户拓展信息 |
|
||||||
25
pom.xml
25
pom.xml
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -199,11 +200,7 @@
|
|||||||
<artifactId>mapstruct-processor</artifactId>
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
<version>1.5.3.Final</version>
|
<version>1.5.3.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- elasticsearch -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- json-api -->
|
<!-- json-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.json</groupId>
|
<groupId>jakarta.json</groupId>
|
||||||
@@ -301,17 +298,11 @@
|
|||||||
<version>3.3.2</version>
|
<version>3.3.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>cn.hutool</groupId>-->
|
<!-- <groupId>cn.hutool</groupId>-->
|
||||||
<!-- <artifactId>hutool-all</artifactId>-->
|
<!-- <artifactId>hutool-all</artifactId>-->
|
||||||
<!-- <version>5.8.8</version>-->
|
<!-- <version>5.8.8</version>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fly</groupId>
|
|
||||||
<artifactId>fly-tool-jsonParse</artifactId>
|
|
||||||
<version>1.0.0-RELEASE</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* @Author: lzq
|
||||||
|
* @Date: 2025-10-14 17:07:43
|
||||||
|
* @LastEditors: Do not edit
|
||||||
|
* @LastEditTime: 2025-10-15 09:17:14
|
||||||
|
* @Description:
|
||||||
|
* @FilePath: \workspace\ZhiYouPiao-Admin\ZhiYouPiao-Admin-Boot\src\main\java\org\springblade\Application.java
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
package org.springblade;
|
package org.springblade;
|
||||||
|
|
||||||
import org.springblade.common.constant.CommonConstant;
|
import org.springblade.common.constant.CommonConstant;
|
||||||
|
|||||||
57
src/main/java/org/springblade/common/cache/JsonModelCache.java
vendored
Normal file
57
src/main/java/org/springblade/common/cache/JsonModelCache.java
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* @Author: lzq
|
||||||
|
* @Date: 2025-10-14 17:07:43
|
||||||
|
* @LastEditors: Do not edit
|
||||||
|
* @LastEditTime: 2025-10-15 09:11:57
|
||||||
|
* @Description:
|
||||||
|
* @FilePath: \workspace\ZhiYouPiao-Admin\ZhiYouPiao-Admin-Boot\src\main\java\org\springblade\common\cache\JsonModelCache.java
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
package org.springblade.common.cache;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import io.jsonwebtoken.lang.Assert;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springblade.core.redis.cache.BladeRedis;
|
||||||
|
import org.springblade.core.tool.utils.BeanUtil;
|
||||||
|
import org.springblade.core.tool.utils.SpringUtil;
|
||||||
|
import org.springblade.modules.jsonparse.entity.ParseLine;
|
||||||
|
import org.springblade.modules.jsonparse.entity.ParseModel;
|
||||||
|
import org.springblade.modules.jsonparse.entity.ParseNode;
|
||||||
|
import org.springblade.modules.jsonparse.service.ParseLineService;
|
||||||
|
import org.springblade.modules.jsonparse.service.ParseModelService;
|
||||||
|
import org.springblade.modules.jsonparse.service.ParseNodeService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* json模型缓存
|
||||||
|
*
|
||||||
|
* @author ganwu
|
||||||
|
*/
|
||||||
|
public class JsonModelCache {
|
||||||
|
|
||||||
|
private static final String PARAM_CACHE = "blade:param:";
|
||||||
|
private static final String JSONPARSE_MODEL = "jsonParse:model:";
|
||||||
|
|
||||||
|
private static final ParseModelService parseModelService;
|
||||||
|
private static final ParseNodeService parseNodeService;
|
||||||
|
private static final ParseLineService parseLineService;
|
||||||
|
private static final Long OUT_DAYS = Long.valueOf(60*60*24*7);
|
||||||
|
|
||||||
|
private static final BladeRedis bladeRedis;
|
||||||
|
|
||||||
|
static {
|
||||||
|
parseModelService = SpringUtil.getBean(ParseModelService.class);
|
||||||
|
parseNodeService = SpringUtil.getBean(ParseNodeService.class);
|
||||||
|
parseLineService = SpringUtil.getBean(ParseLineService.class);
|
||||||
|
bladeRedis = SpringUtil.getBean(BladeRedis.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getKey(String cacheName, String keyPrefix, Object key){
|
||||||
|
return new StringBuffer(cacheName).append(keyPrefix).append(key.toString()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
189
src/main/java/org/springblade/common/cache/JsonParseCache.java
vendored
Normal file
189
src/main/java/org/springblade/common/cache/JsonParseCache.java
vendored
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
package org.springblade.common.cache;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import io.jsonwebtoken.lang.Assert;
|
||||||
|
import org.noear.snack.ONode;
|
||||||
|
import org.springblade.common.utils.JsonParseUtil;
|
||||||
|
import org.springblade.core.redis.cache.BladeRedis;
|
||||||
|
import org.springblade.core.tool.utils.SpringUtil;
|
||||||
|
import org.springblade.core.tool.utils.StringPool;
|
||||||
|
import org.springblade.modules.jsonparse.entity.ParseLine;
|
||||||
|
import org.springblade.modules.jsonparse.entity.ParseModel;
|
||||||
|
import org.springblade.modules.jsonparse.entity.ParseNode;
|
||||||
|
import org.springblade.modules.jsonparse.entity.ParsePlugs;
|
||||||
|
import org.springblade.modules.jsonparse.service.ParseLineService;
|
||||||
|
import org.springblade.modules.jsonparse.service.ParseModelService;
|
||||||
|
import org.springblade.modules.jsonparse.service.ParseNodeService;
|
||||||
|
import org.springblade.modules.jsonparse.service.ParsePlugsService;
|
||||||
|
import org.springblade.modules.jsonparse.vo.ParseModelVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* json解析缓存工具类
|
||||||
|
*
|
||||||
|
* @author ganwu
|
||||||
|
*/
|
||||||
|
public class JsonParseCache {
|
||||||
|
|
||||||
|
private static final String PARAM_CACHE = "blade:param:";
|
||||||
|
private static final String JSONPARSE_ID = "jsonParse:id:";
|
||||||
|
// private static final String JSONPARSE_MODEL = "jsonParse:model:";
|
||||||
|
private static final String JSONPARSE_KEY = "jsonParse:key:";
|
||||||
|
private static final String JSONPARSE_NODE_STATUS = "jsonParse:node:status:";
|
||||||
|
private static final String JSONPARSE_EXECUTE_STATUS = "jsonParse:execute:status:";
|
||||||
|
|
||||||
|
private static final ParseModelService parseModelService;
|
||||||
|
private static final ParseNodeService parseNodeService;
|
||||||
|
private static final ParseLineService parseLineService;
|
||||||
|
private static final ParsePlugsService parsePlugsService;
|
||||||
|
|
||||||
|
private static final Long OUT_SECONDS = 30L;
|
||||||
|
private static final Long OUT_DAYS = Long.valueOf(60*60*24*7);
|
||||||
|
|
||||||
|
private static final BladeRedis bladeRedis;
|
||||||
|
|
||||||
|
static {
|
||||||
|
parseModelService = SpringUtil.getBean(ParseModelService.class);
|
||||||
|
parseNodeService = SpringUtil.getBean(ParseNodeService.class);
|
||||||
|
parseLineService = SpringUtil.getBean(ParseLineService.class);
|
||||||
|
parsePlugsService = SpringUtil.getBean(ParsePlugsService.class);
|
||||||
|
bladeRedis = SpringUtil.getBean(BladeRedis.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getKey(String cacheName, String keyPrefix, Object key){
|
||||||
|
return new StringBuffer(cacheName).append(keyPrefix).append(key.toString()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模型实体
|
||||||
|
*
|
||||||
|
* @param id 模型id
|
||||||
|
* @return ParseModelVO blade:paramjsonParse:id:
|
||||||
|
*/
|
||||||
|
public static ParseModelVO getModelById(Long id) {
|
||||||
|
String key = getKey(PARAM_CACHE,JSONPARSE_ID,id);
|
||||||
|
Object obj = bladeRedis.get(key);
|
||||||
|
if(obj == null){
|
||||||
|
ParseModelVO parseModelVO = parseModelService.getModeDetailById(id);
|
||||||
|
if(null != parseModelVO){
|
||||||
|
parseModelVO.setLines(parseLineService.list(new LambdaQueryWrapper<ParseLine>()
|
||||||
|
.select(ParseLine::getId,ParseLine::getModelId,ParseLine::getNodeStartId,ParseLine::getNodeEndId,ParseLine::getLocation)
|
||||||
|
.eq(ParseLine::getModelId,parseModelVO.getId())));
|
||||||
|
parseModelVO.setNodes(parseNodeService.list(new LambdaQueryWrapper<ParseNode>()
|
||||||
|
.select(ParseNode::getId,ParseNode::getModelId,ParseNode::getNodeType,ParseNode::getNodeName,ParseNode::getPlugCode,ParseNode::getExpression,ParseNode::getParams)
|
||||||
|
.eq(ParseNode::getModelId,parseModelVO.getId())));
|
||||||
|
bladeRedis.setEx(key, ONode.stringify(parseModelVO),OUT_DAYS);
|
||||||
|
return parseModelVO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ONode.deserialize(bladeRedis.get(key), ParseModelVO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取插件实体
|
||||||
|
*
|
||||||
|
* @param plugCode 插件id
|
||||||
|
* @return ParseModelVO
|
||||||
|
*/
|
||||||
|
public static ParsePlugs getPlugByCode(String plugCode) {
|
||||||
|
String key = getKey(PARAM_CACHE, JSONPARSE_ID, plugCode);
|
||||||
|
Object obj = bladeRedis.get(key);
|
||||||
|
if(obj == null){
|
||||||
|
ParsePlugs plugs = parsePlugsService.getOne(new LambdaQueryWrapper<ParsePlugs>()
|
||||||
|
.select(ParsePlugs::getId, ParsePlugs::getPlugsName, ParsePlugs::getPlugsCode, ParsePlugs::getLocationNum)
|
||||||
|
.eq(ParsePlugs::getPlugsCode, plugCode));
|
||||||
|
Assert.notNull(plugs,"插件不存在"+plugCode);
|
||||||
|
bladeRedis.setEx(key,ONode.stringify(plugs),OUT_DAYS);
|
||||||
|
return plugs;
|
||||||
|
}
|
||||||
|
return ONode.deserialize(bladeRedis.get(key), ParsePlugs.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取节点状态
|
||||||
|
*
|
||||||
|
* @param executeId 执行ID
|
||||||
|
* @param nodeId 节点ID`
|
||||||
|
* @return Integer 状态值 0 待执行 1 执行中 2 执行完成 3 错误
|
||||||
|
*/
|
||||||
|
public static Integer getNodeStatus(Long executeId,Long nodeId) {
|
||||||
|
String key = getKey(PARAM_CACHE,new StringBuffer(JSONPARSE_NODE_STATUS).append(executeId).append(StringPool.COLON).toString(), nodeId);
|
||||||
|
if(!bladeRedis.exists(key)){
|
||||||
|
bladeRedis.setEx(key, JsonParseUtil.PARSE_INIT,OUT_SECONDS);
|
||||||
|
return JsonParseUtil.PARSE_INIT;
|
||||||
|
}
|
||||||
|
return bladeRedis.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新节点状态
|
||||||
|
*
|
||||||
|
* @param executeId 执行ID
|
||||||
|
* @param nodeId 节点ID
|
||||||
|
* @param statusValue 状态值 0 待执行 1 执行中 2 执行完成 3 错误
|
||||||
|
*/
|
||||||
|
public static void updateNodeStatus(Long executeId,Long nodeId, Integer statusValue) {
|
||||||
|
String key = getKey(PARAM_CACHE, new StringBuffer(JSONPARSE_NODE_STATUS).append(executeId).append(StringPool.COLON).toString(), nodeId);
|
||||||
|
bladeRedis.setEx(key,statusValue,OUT_SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取执行状态
|
||||||
|
*
|
||||||
|
* @param executeId 执行id
|
||||||
|
* @return Integer 状态值 0 待执行 1 执行中 2 执行完成 3 错误
|
||||||
|
*/
|
||||||
|
public static Integer getExecuteStatus(Long executeId) {
|
||||||
|
String key = getKey(PARAM_CACHE, JSONPARSE_EXECUTE_STATUS, executeId);
|
||||||
|
if(!bladeRedis.exists(key)){
|
||||||
|
bladeRedis.setEx(key, JsonParseUtil.PARSE_INIT,OUT_SECONDS);
|
||||||
|
return JsonParseUtil.PARSE_INIT;
|
||||||
|
}
|
||||||
|
return bladeRedis.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新执行状态
|
||||||
|
*
|
||||||
|
* @param executeId 执行ID
|
||||||
|
* @param statusValue 状态值 0 待执行 1 执行中 2 执行完成 3 错误
|
||||||
|
*/
|
||||||
|
public static void updateExecuteStatus(Long executeId,Integer statusValue) {
|
||||||
|
bladeRedis.setEx(getKey(PARAM_CACHE,JSONPARSE_EXECUTE_STATUS,executeId),statusValue,OUT_SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取线数据
|
||||||
|
*
|
||||||
|
* @param executeId 执行ID
|
||||||
|
* @param lineId 线编号
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static ONode getLineData(Long executeId,Long lineId) {
|
||||||
|
String key = getKey(PARAM_CACHE,new StringBuffer(JSONPARSE_KEY).append(executeId).append(StringPool.COLON).toString(),lineId);
|
||||||
|
return ONode.load(bladeRedis.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置线数据
|
||||||
|
*
|
||||||
|
* @param executeId 执行ID
|
||||||
|
* @param lineId 线编号
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static void setLineData(Long executeId,Long lineId,String node) {
|
||||||
|
String key = getKey(PARAM_CACHE,new StringBuffer(JSONPARSE_KEY).append(executeId).append(StringPool.COLON).toString(),lineId);
|
||||||
|
bladeRedis.setEx(key,node,OUT_SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static ParseModel getParseModel(String modelLabel) {
|
||||||
|
// String key = getKey(PARAM_CACHE, JSONPARSE_MODEL, modelLabel);
|
||||||
|
// if(!bladeRedis.exists(key)){
|
||||||
|
// ParseModel parseMode = parseModelService.selectParseModel(modelLabel);
|
||||||
|
// bladeRedis.setEx(key,ONode.stringify(parseMode),OUT_DAYS);
|
||||||
|
// return parseMode;
|
||||||
|
// }
|
||||||
|
// return ONode.deserialize(bladeRedis.get(key).toString(), ParseModel.class);
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -19,7 +19,6 @@ public class AsyncConfiguration {
|
|||||||
private static final int QUEUE_CAPACITY = 500;
|
private static final int QUEUE_CAPACITY = 500;
|
||||||
private static final int KEEP_ALIVE_SECONDS = 60;
|
private static final int KEEP_ALIVE_SECONDS = 60;
|
||||||
private static final int AWAIT_TERMINATION_SECONDS = 60;
|
private static final int AWAIT_TERMINATION_SECONDS = 60;
|
||||||
|
|
||||||
@Bean("common")
|
@Bean("common")
|
||||||
public AsyncTaskExecutor commonAsyncExecutor() {
|
public AsyncTaskExecutor commonAsyncExecutor() {
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
|
|||||||
@@ -18,20 +18,25 @@ package org.springblade.common.config;
|
|||||||
|
|
||||||
import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
|
import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springblade.core.launch.constant.AppConstant;
|
||||||
import org.springblade.core.secure.BladeUser;
|
import org.springblade.core.secure.BladeUser;
|
||||||
import org.springblade.core.swagger.EnableSwagger;
|
import org.springblade.core.swagger.EnableSwagger;
|
||||||
import org.springblade.core.swagger.SwaggerProperties;
|
import org.springblade.core.swagger.SwaggerProperties;
|
||||||
import org.springblade.core.swagger.SwaggerUtil;
|
import org.springblade.core.swagger.SwaggerUtil;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import springfox.documentation.RequestHandler;
|
import springfox.documentation.RequestHandler;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
import springfox.documentation.service.*;
|
import springfox.documentation.service.*;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@@ -84,21 +89,21 @@ public class SwaggerConfiguration {
|
|||||||
// RequestHandlerSelectors.withClassAnnotation(Api.class),PathSelectors.any());
|
// RequestHandlerSelectors.withClassAnnotation(Api.class),PathSelectors.any());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// private Docket docket(String groupName, List<String> basePackages) {
|
private Docket docket(String groupName, List<String> basePackages) {
|
||||||
// return docket(groupName, SwaggerUtil.basePackages(basePackages), PathSelectors.any());
|
return docket(groupName,SwaggerUtil.basePackages(basePackages),PathSelectors.any());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// private Docket docket(String groupName, Predicate<RequestHandler> handler, Predicate<String> predicate) {
|
private Docket docket(String groupName, Predicate<RequestHandler> handler, Predicate<String> predicate) {
|
||||||
// return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
// .groupName(groupName)
|
.groupName(groupName)
|
||||||
// .apiInfo(apiInfo())
|
.apiInfo(apiInfo())
|
||||||
// .ignoredParameterTypes(BladeUser.class)
|
.ignoredParameterTypes(BladeUser.class)
|
||||||
// .select()
|
.select()
|
||||||
// .apis(handler)
|
.apis(handler)
|
||||||
// .paths(predicate)
|
.paths(predicate)
|
||||||
// .build().securityContexts(securityContexts()).securitySchemes(securitySchemas())
|
.build().securityContexts(securityContexts()).securitySchemes(securitySchemas())
|
||||||
// .extensions(openApiExtensionResolver.buildExtensions(groupName));
|
.extensions(openApiExtensionResolver.buildExtensions(groupName));
|
||||||
// }
|
}
|
||||||
|
|
||||||
private List<SecurityContext> securityContexts() {
|
private List<SecurityContext> securityContexts() {
|
||||||
return Collections.singletonList(SecurityContext.builder()
|
return Collections.singletonList(SecurityContext.builder()
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the dreamlu.net developer nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
* Author: Chill 庄骞 (smallchill@163.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典常量.
|
||||||
|
*
|
||||||
|
* @author zhuangqian
|
||||||
|
*/
|
||||||
|
public interface DictConstant {
|
||||||
|
|
||||||
|
String SEX_CODE = "sex";
|
||||||
|
|
||||||
|
String NOTICE_CODE = "notice";
|
||||||
|
|
||||||
|
String MENU_CATEGORY_CODE = "menu_category";
|
||||||
|
|
||||||
|
String BUTTON_FUNC_CODE = "button_func";
|
||||||
|
|
||||||
|
String YES_NO_CODE = "yes_no";
|
||||||
|
|
||||||
|
String FLOW_CATEGORY_CODE = "flow_category";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package org.springblade.common.constant;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知类型
|
||||||
|
* @author jing han
|
||||||
|
* @version 1.0
|
||||||
|
* @project Fly-Boot
|
||||||
|
* @description
|
||||||
|
* @date 2024/7/27 16:36:49
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
||||||
|
public enum NoticeTypeEnums {
|
||||||
|
SYS(0, "系统公告"),
|
||||||
|
MALL(1, "商城消息"),
|
||||||
|
TOUR(2, "旅行团消息"),
|
||||||
|
TICKET(3, "景点门票消息"),
|
||||||
|
STORE(4, "好省攻略消息"),
|
||||||
|
TRAVEL(5, "旅行规划消息"),
|
||||||
|
VR(6, "云游世界消息"),
|
||||||
|
SPOT(7, "智慧眼消息"),
|
||||||
|
NARRATE(8, "景点解说消息"),
|
||||||
|
SPEECHXF(9, "讯飞消息"),
|
||||||
|
PROMOTION(10, "活动消息"),
|
||||||
|
HOTEL(11, "酒店消息"),
|
||||||
|
SIGHT(12, "景点消息"),
|
||||||
|
AI_COURSE(13, "AI课程消息"),
|
||||||
|
VIP(14, "会员消息"),
|
||||||
|
OWNER(15, "自营商城消息"),
|
||||||
|
LIFE(6, "本地生活消息"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
NoticeTypeEnums(int code, String description) {
|
||||||
|
this.code = code;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
public static NoticeTypeEnums of(int code) {
|
||||||
|
for (NoticeTypeEnums status : NoticeTypeEnums.values()) {
|
||||||
|
if (status.getCode() == code) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Invalid code: " + code);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.springblade.common.constant;
|
||||||
|
|
||||||
|
public interface UserBaseConstant {
|
||||||
|
|
||||||
|
//默认头像
|
||||||
|
String DEFAULT_AVATAR = "http://letfly.oss-cn-zhangjiakou.aliyuncs.com/upload/20230511/2fad5c19c8ed34271dfb02ec26350d55.png";
|
||||||
|
|
||||||
|
String[] TYPE_NAME_ARR = {"","全部","支入","支出"};
|
||||||
|
|
||||||
|
String[] LUCKY_VALUE_TYPE = {"","获赠卖运值","配额幸运值"};
|
||||||
|
|
||||||
|
|
||||||
|
String[] ACTIVE_VALUE_LOG_SOURCE_NAME = {"任务签到","任务包消费","实名认证","邀请人分润","商品消费","商家卖货 ","交易所买卖 ","邀请新用户"};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package org.springblade.common.entity;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ganwu
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
public class EsQuery {
|
|
||||||
/**
|
|
||||||
* 模糊查询条件
|
|
||||||
*/
|
|
||||||
private List<MatchQuery> wildCard;
|
|
||||||
/**
|
|
||||||
* 查询条件
|
|
||||||
*/
|
|
||||||
private List<MatchQuery> match;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 范围查询
|
|
||||||
*/
|
|
||||||
private GepPointQuery geoPoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* in查询条件
|
|
||||||
*/
|
|
||||||
private List<MatchQuery> terms;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序字段
|
|
||||||
*/
|
|
||||||
private String sortFiled;
|
|
||||||
/**
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
private SortOrder sortOrder;
|
|
||||||
/**
|
|
||||||
* 页码
|
|
||||||
*/
|
|
||||||
private Integer current;
|
|
||||||
/**
|
|
||||||
* 条数
|
|
||||||
*/
|
|
||||||
private Integer size;
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package org.springblade.common.entity;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import org.elasticsearch.common.unit.DistanceUnit;
|
|
||||||
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 范围查询
|
|
||||||
*
|
|
||||||
* @author ganwu
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
public class GepPointQuery {
|
|
||||||
/**
|
|
||||||
* 字段
|
|
||||||
*/
|
|
||||||
private String field;
|
|
||||||
/**
|
|
||||||
* 经纬度
|
|
||||||
*/
|
|
||||||
private GeoPoint geoPoint;
|
|
||||||
/**
|
|
||||||
* 距离单位
|
|
||||||
*/
|
|
||||||
private DistanceUnit unit;
|
|
||||||
/**
|
|
||||||
* 半径
|
|
||||||
*/
|
|
||||||
private Double initRadius;
|
|
||||||
}
|
|
||||||
@@ -4,8 +4,8 @@ import lombok.Data;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 范围查询
|
|
||||||
*
|
*
|
||||||
|
* 范围查询
|
||||||
* @author ganwu
|
* @author ganwu
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
26
src/main/java/org/springblade/common/utils/CommonUtil.java
Normal file
26
src/main/java/org/springblade/common/utils/CommonUtil.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the dreamlu.net developer nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
* Author: Chill 庄骞 (smallchill@163.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.common.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用工具类
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
public class CommonUtil {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -180,7 +180,6 @@ public class DateUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前时间 + 分钟数
|
* 当前时间 + 分钟数
|
||||||
*
|
|
||||||
* @param minute
|
* @param minute
|
||||||
* @return 当前时间 + 分钟数
|
* @return 当前时间 + 分钟数
|
||||||
*/
|
*/
|
||||||
@@ -193,12 +192,11 @@ public class DateUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 指定日期后x天的日期
|
* 指定日期后x天的日期
|
||||||
*
|
|
||||||
* @param start 日期
|
* @param start 日期
|
||||||
* @param day 天数
|
* @param day 天数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Date getSpecifyDay(Date start, int day) {
|
public static Date getSpecifyDay(Date start,int day) {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(start);
|
calendar.setTime(start);
|
||||||
calendar.add(Calendar.DATE, day);
|
calendar.add(Calendar.DATE, day);
|
||||||
@@ -246,7 +244,7 @@ public class DateUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date convertFromString(String dateString) {
|
public static Date convertFromString(String dateString){
|
||||||
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
try {
|
try {
|
||||||
return ft.parse(dateString);
|
return ft.parse(dateString);
|
||||||
@@ -260,13 +258,13 @@ public class DateUtil {
|
|||||||
return ft.format(date);
|
return ft.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date convertLocalDateTimeToDate(LocalDateTime localDateTime) {
|
public static Date convertLocalDateTimeToDate(LocalDateTime localDateTime){
|
||||||
ZoneId zoneId = ZoneId.systemDefault();
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
ZonedDateTime zdt = localDateTime.atZone(zoneId);
|
ZonedDateTime zdt = localDateTime.atZone(zoneId);
|
||||||
return Date.from(zdt.toInstant());
|
return Date.from(zdt.toInstant());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getBegin(Date date) {
|
public static Date getBegin(Date date){
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(date);
|
calendar.setTime(date);
|
||||||
calendar.set(Calendar.SECOND, 0);
|
calendar.set(Calendar.SECOND, 0);
|
||||||
@@ -276,7 +274,7 @@ public class DateUtil {
|
|||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getEnd(Date date) {
|
public static Date getEnd(Date date){
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(date);
|
calendar.setTime(date);
|
||||||
calendar.set(Calendar.SECOND, 59);
|
calendar.set(Calendar.SECOND, 59);
|
||||||
@@ -291,9 +289,9 @@ public class DateUtil {
|
|||||||
result.add(start);
|
result.add(start);
|
||||||
Date startDay = convertFromString(start, "yyyy-MM-dd");
|
Date startDay = convertFromString(start, "yyyy-MM-dd");
|
||||||
Date endDay = convertFromString(end, "yyyy-MM-dd");
|
Date endDay = convertFromString(end, "yyyy-MM-dd");
|
||||||
Integer sub = getDaySub(startDay, endDay);
|
Integer sub= getDaySub(startDay, endDay);
|
||||||
Assert.isTrue(sub <= 31, "查询日期间隔不能大于31天减法");
|
Assert.isTrue(sub<=31,"查询日期间隔不能大于31天减法");
|
||||||
if (sub > 0) {
|
if(sub > 0){
|
||||||
for (int i = 1; i <= sub; i++) {
|
for (int i = 1; i <= sub; i++) {
|
||||||
result.add(convertFromDate(getDaysLate(startDay, i), "yyyy-MM-dd"));
|
result.add(convertFromDate(getDaysLate(startDay, i), "yyyy-MM-dd"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.springblade.common.utils;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.ExcelWriter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.codec.Charsets;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class ExportExcelUtil {
|
||||||
|
|
||||||
|
public ExportExcelUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static ExcelWriter createExcel(HttpServletResponse response, String fileName ) throws IOException {
|
||||||
|
response.setContentType("application/vnd.ms-excel");
|
||||||
|
response.setCharacterEncoding(Charsets.UTF_8.name());
|
||||||
|
fileName = URLEncoder.encode(fileName, Charsets.UTF_8.name());
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||||
|
return EasyExcel.write(response.getOutputStream()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void closeExcel(ExcelWriter excelWriter) {
|
||||||
|
excelWriter.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
43
src/main/java/org/springblade/common/utils/HolidayDTO.java
Normal file
43
src/main/java/org/springblade/common/utils/HolidayDTO.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package org.springblade.common.utils;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lzq
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class HolidayDTO implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期
|
||||||
|
*/
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节日名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节日中文名称
|
||||||
|
*/
|
||||||
|
private String name_cn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节日英文名称
|
||||||
|
*/
|
||||||
|
private String name_en;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节日类型
|
||||||
|
* public_holiday 节假日
|
||||||
|
* transfer_workday 节假日补班
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
package org.springblade.common.utils;
|
|
||||||
|
|
||||||
import cn.hutool.core.img.ImgUtil;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
public class ImageUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加字体的属性设置
|
|
||||||
*/
|
|
||||||
private static Font YaHei_35 = new Font("微软雅黑", Font.BOLD, 35);
|
|
||||||
private static Font YaHei_40 = new Font("微软雅黑", Font.BOLD, 40);
|
|
||||||
private static Font YaHei_20 = new Font("微软雅黑", Font.PLAIN, 20);
|
|
||||||
private static Font SiYuanHeiTi_22 = new Font("思源黑体", Font.BOLD, 22);
|
|
||||||
private static Font SiYuanHeiTi_20 = new Font("思源黑体", Font.BOLD, 20);
|
|
||||||
private static Color BLACK_COLOR = new Color(2, 1, 1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成图片
|
|
||||||
*
|
|
||||||
* @param image 图片
|
|
||||||
* @param file 文件
|
|
||||||
*/
|
|
||||||
public static void getFile(Image image, File file) {
|
|
||||||
ImgUtil.write(image, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取纯色图片
|
|
||||||
*
|
|
||||||
* @param width 宽
|
|
||||||
* @param height 高
|
|
||||||
* @param color 颜色
|
|
||||||
* @return java.awt.image.BufferedImage
|
|
||||||
*/
|
|
||||||
public static BufferedImage getSolidImage(int width, int height, Color color) {
|
|
||||||
BufferedImage image = new BufferedImage(width, height, 1);
|
|
||||||
Graphics g = image.getGraphics();
|
|
||||||
g.setColor(color);
|
|
||||||
g.fillRect(0, 0, width, height);
|
|
||||||
g.dispose();
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 图片转base64
|
|
||||||
*
|
|
||||||
* @param image
|
|
||||||
* @param fileType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getBase64(BufferedImage image, String fileType) {
|
|
||||||
ByteArrayOutputStream bass = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
ImageIO.write(image, fileType, bass);
|
|
||||||
return Base64.getEncoder().encodeToString(bass.toByteArray());
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} finally {
|
|
||||||
if (bass != null) {
|
|
||||||
try {
|
|
||||||
bass.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
package org.springblade.common.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import org.noear.snack.ONode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
public class JsonParseFunction {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除属性
|
||||||
|
* @param node 函数
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void delProperty(ONode node,Map<String,List<String>> param){
|
||||||
|
param.forEach((k,v) ->{
|
||||||
|
if(node.select(k).isArray()){
|
||||||
|
v.forEach(child ->{
|
||||||
|
node.select(k).forEach(n1 -> {
|
||||||
|
if(n1.isArray()){
|
||||||
|
n1.forEach(n2 -> {
|
||||||
|
n2.remove(child);
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
n1.remove(child);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
v.forEach(child ->{
|
||||||
|
node.select(k).remove(child);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除属性
|
||||||
|
* @param node 函数
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void delProperty(ONode node,List<String> param){
|
||||||
|
param.forEach(k->{
|
||||||
|
node.remove(k);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建新节点
|
||||||
|
* @param node 函数
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ONode getNewNode(ONode node,List<String> param){
|
||||||
|
ONode item = new ONode();
|
||||||
|
param.forEach(k->{
|
||||||
|
item.set(k,node.get(k));
|
||||||
|
});
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建新节点
|
||||||
|
* @param node 函数
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ONode getNewNode(ONode node,Map<String,List<Object>> param){
|
||||||
|
ONode item = new ONode();
|
||||||
|
if(node.isArray()){
|
||||||
|
node.forEach(n -> {
|
||||||
|
param.forEach((k,v)->{
|
||||||
|
if(v.contains(n.get(k))){
|
||||||
|
// reNodes.add(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件过滤
|
||||||
|
* @param node
|
||||||
|
* @param paraMap
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean filterQueryNode(ONode node,Map<String, List<Object>> paraMap){
|
||||||
|
AtomicBoolean success = new AtomicBoolean(true);
|
||||||
|
for(Map.Entry<String, List<Object>> e : paraMap.entrySet()){
|
||||||
|
if(!e.getValue().contains(node.get(e.getKey()))){
|
||||||
|
success.set(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件过滤
|
||||||
|
* @param node 集合
|
||||||
|
* @param paraMap
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ONode sortNode(ONode node,Map<String, List<Object>> paraMap){
|
||||||
|
if(node.isNull() || !node.isArray()){
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
ONode re = new ONode();
|
||||||
|
if(node.isArray()){
|
||||||
|
re.asArray();
|
||||||
|
for (Map.Entry<String, List<Object>> e : paraMap.entrySet()){
|
||||||
|
for (int i = 0; i <e.getValue().size() ; i++) {
|
||||||
|
for (ONode n : node.ary()) {
|
||||||
|
if(e.getValue().get(i).toString().equals(n.get(e.getKey()).getString())){
|
||||||
|
re.add(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
for (Map.Entry<String, List<Object>> e : paraMap.entrySet()){
|
||||||
|
for (int i = 0; i <e.getValue().size() ; i++) {
|
||||||
|
if(e.getValue().get(i).toString().equals(node.get(e.getKey()).getString())){
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return re;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象转集合
|
||||||
|
* @param requestNode 输入
|
||||||
|
* @param responseNode 返回
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void recursionAddNode(ONode requestNode , ONode responseNode){
|
||||||
|
if(requestNode.isObject()){
|
||||||
|
responseNode.add(requestNode);
|
||||||
|
}else {
|
||||||
|
if(requestNode.isArray()){
|
||||||
|
requestNode.forEach(n -> {
|
||||||
|
recursionAddNode(n, responseNode);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象转集合
|
||||||
|
* @param requestNode 输入
|
||||||
|
* @param responseNode 返回
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void recursionSelfAddNode(ONode requestNode , ONode responseNode){
|
||||||
|
requestNode.forEach((k, v) -> {
|
||||||
|
if(v.isArray()){
|
||||||
|
responseNode.addAll(v);
|
||||||
|
}else {
|
||||||
|
responseNode.add(v);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除属性
|
||||||
|
* @param node 函数
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void removeProperty(ONode node,Map<String,List<String>> param){
|
||||||
|
param.forEach((k,v) ->{
|
||||||
|
if(node.isArray()){
|
||||||
|
for (int i = node.ary().size() - 1; i >= 0; i--){
|
||||||
|
if(v.contains(node.get(i).get(k).getString())){
|
||||||
|
node.removeAt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
String str1 = "{\"descCn\":\"肉质紧密,柔嫩多汁,好口感席卷味蕾。 主要原料:西冷牛排、烤土豆、小番茄、西兰花 酱汁:炭烤风味汁/黑胡椒汁(2选1) 克重:180g/份。 (温馨提示: 必胜客牛排产品所标克数均为餐厅烤制前净含量,随餐配菜、酱汁可能随季节变化而有所调整,盛器及图示内容仅供参考,请以餐厅实际供应为准。)\",\"disabledStatus\":\"0\",\"imageUrl\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015/images/18623__ALL__S__20221117133127512.png\",\"linkId\":\"18623\",\"maxQty\":999,\"menuFlag\":\"C\",\"menuFlagType\":\"2\",\"minQty\":0,\"nameCn\":\"臻选西冷牛排\",\"price\":85,\"amount\":0,\"roundList\":[{\"id\":\"1\",\"itemCount\":1,\"itemList\":[{\"allowDiscount\":\"1\",\"attrTag\":\"\",\"base\":{\"descCn\":\"\"},\"defaultSelected\":\"1\",\"descCn\":\"\",\"disabledStatus\":\"0\",\"imageUrl\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015/images/17327__ALL__S__20230519143959132.png\",\"imageUrlNew\":{\"S\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015/images/17327__ALL__S__20230519143959132.png\",\"L\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015//images/17327__ALL__L__20210708162637139.jpg\",\"M\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015//images/17327__ALL__M__20210708162631780.jpg\"},\"linkId\":\"17327\",\"maxQty\":1,\"menuFlag\":\"P\",\"minQty\":0,\"nameCn\":\"配餐黑椒汁\",\"orgPrice\":0,\"price\":0,\"priceHead\":0,\"quantity\":1,\"roundList\":[],\"showNameCn\":\"黑椒汁\",\"viewOptionValues\":[{\"optionClassId\":\"1\",\"optionId\":\"17327\"}]},{\"allowDiscount\":\"1\",\"attrTag\":\"\",\"base\":{\"descCn\":\"\"},\"descCn\":\"\",\"disabledStatus\":\"0\",\"imageUrl\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015/images/500003943__ALL__S__20230519143959153.png\",\"imageUrlNew\":{\"S\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015/images/500003943__ALL__S__20230519143959153.png\",\"L\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015/images/500003943__ALL__L__20210920121057221.jpg\",\"M\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015//images/500003943__ALL__M__20210708162632311.jpg\"},\"linkId\":\"500003943\",\"maxQty\":1,\"menuFlag\":\"P\",\"minQty\":0,\"nameCn\":\"碳烤风味汁\",\"orgPrice\":0,\"price\":0,\"priceHead\":0,\"quantity\":1,\"roundList\":[],\"showNameCn\":\"碳烤风味汁\",\"viewOptionValues\":[{\"optionClassId\":\"1\",\"optionId\":\"500003943\"}]},{\"allowDiscount\":\"1\",\"attrTag\":\"\",\"base\":{\"descCn\":\"\"},\"descCn\":\"\",\"disabledStatus\":\"0\",\"imageUrl\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015/images/500045748__ALL__S__20230519143959175.png\",\"imageUrlNew\":{\"S\":\"https://cdnimg.4008123123.com/PHHSMWOS/Pnew//2/02015/images/500045748__ALL__S__20230519143959175.png\"},\"linkId\":\"500045748\",\"maxQty\":1,\"menuFlag\":\"P\",\"minQty\":0,\"nameCn\":\"和风烤肉汁\",\"orgPrice\":0,\"price\":0,\"priceHead\":0,\"quantity\":1,\"roundList\":[],\"showNameCn\":\"和风烤肉汁\",\"viewOptionValues\":[{\"optionClassId\":\"1\",\"optionId\":\"500045748\"}]}],\"minItemCount\":1,\"name\":\"配料\",\"type\":\"C\",\"viewOptionList\":[{\"id\":\"1\",\"name\":\"配料\",\"options\":[{\"id\":\"17327\",\"imgUrl\":\"/2/02015/images/17327__ALL__S__20230519143959132.png\",\"name\":\"黑椒汁\"},{\"id\":\"500003943\",\"imgUrl\":\"/2/02015/images/500003943__ALL__S__20230519143959153.png\",\"name\":\"碳烤风味汁\"},{\"id\":\"500045748\",\"imgUrl\":\"/2/02015/images/500045748__ALL__S__20230519143959175.png\",\"name\":\"和风烤肉汁\"}]}]}],\"showNameCn\":\"臻选西冷牛排\"}";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ONode node1 = ONode.load(str1);
|
||||||
|
|
||||||
|
// delProperty(node1.select("$.roundList"), JSON.parseObject("{\"itemList\":[\"viewOptionValues\",\"roundList\",\"descCn\",\"quantity\",\"orgPrice\",\"priceHead\",\"allowDiscount\",\"base\",\"activityType\",\"attrTag\",\"defaultSelected\",\"imageUrlNew\",\"menuFlag\",\"menuFlagType\",\"nameCn\",\"itemCount\"]}", Map.class));
|
||||||
|
delProperty(node1.select(""), JSON.parseObject("{\"roundList\":[\"itemCount\",\"minItemCount\"]}", Map.class));
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(node1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
1635
src/main/java/org/springblade/common/utils/JsonParseUtil.java
Normal file
1635
src/main/java/org/springblade/common/utils/JsonParseUtil.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,7 @@ public class XmlUtil {
|
|||||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||||
return (T) unmarshaller.unmarshal(new StringReader(xml));
|
return (T) unmarshaller.unmarshal(new StringReader(xml));
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.springblade.modules.advertisement.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import org.springblade.core.mp.base.BaseService;
|
||||||
|
import org.springblade.modules.advertisement.entity.Advertisement;
|
||||||
|
import org.springblade.modules.advertisement.vo.AdvertisementVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自营广告 服务类
|
||||||
|
*
|
||||||
|
* @author 刘玮杰
|
||||||
|
* @since 2023-06-16
|
||||||
|
*/
|
||||||
|
public interface IAdvertisementService extends BaseService<Advertisement> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义分页
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param advertisement
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<AdvertisementVO> selectAdvertisementPage(IPage<AdvertisementVO> page, AdvertisementVO advertisement);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the dreamlu.net developer nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
* Author: Chill 庄骞 (smallchill@163.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.aiaudio.service;
|
||||||
|
|
||||||
|
import org.springblade.modules.aiaudio.entity.AiAudioEntity;
|
||||||
|
import org.springblade.modules.aiaudio.vo.AiAudioVO;
|
||||||
|
import org.springblade.core.mp.base.BaseService;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai语音解说音频表 服务类
|
||||||
|
*
|
||||||
|
* @author jinghan
|
||||||
|
* @since 2024-04-10
|
||||||
|
*/
|
||||||
|
public interface IAiAudioService extends BaseService<AiAudioEntity> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义分页
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param aiAudio
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<AiAudioVO> selectAiAudioPage(IPage<AiAudioVO> page, AiAudioVO aiAudio);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the dreamlu.net developer nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
* Author: Chill 庄骞 (smallchill@163.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.aiaudio.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import org.springblade.core.mp.base.BaseService;
|
||||||
|
import org.springblade.modules.aiaudio.entity.AiScenicEntity;
|
||||||
|
import org.springblade.modules.aiaudio.vo.AiScenicVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai语音解说景区景点表 服务类
|
||||||
|
*
|
||||||
|
* @author jinghan
|
||||||
|
* @since 2024-04-10
|
||||||
|
*/
|
||||||
|
public interface IAiScenicService extends BaseService<AiScenicEntity> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义分页
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param aiScenic
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<AiScenicVO> selectAiScenicPage(IPage<AiScenicVO> page, AiScenicVO aiScenic);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the dreamlu.net developer nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
* Author: Chill 庄骞 (smallchill@163.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.aiaudio.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import org.springblade.core.mp.base.BaseService;
|
||||||
|
import org.springblade.modules.aiaudio.entity.AiSysareaEntity;
|
||||||
|
import org.springblade.modules.aiaudio.vo.AiSysareaVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai语音解说地域表 服务类
|
||||||
|
*
|
||||||
|
* @author jinghan
|
||||||
|
* @since 2024-04-10
|
||||||
|
*/
|
||||||
|
public interface IAiSysareaService extends BaseService<AiSysareaEntity> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义分页
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param aiSysarea
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<AiSysareaVO> selectAiSysareaPage(IPage<AiSysareaVO> page, AiSysareaVO aiSysarea);
|
||||||
|
|
||||||
|
List<AiSysareaVO> getAreaListByPid(String pid);
|
||||||
|
|
||||||
|
List<AiSysareaVO> lazyList(Long parentId, AiSysareaEntity aiSysarea);
|
||||||
|
|
||||||
|
List<AiSysareaVO> tree(Long parentId);
|
||||||
|
|
||||||
|
List<AiSysareaVO> lazyTree(Long parentId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.crossborder.param;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class PoolProductPullOfferPoolQueryParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置商品池ID *
|
||||||
|
* 参数示例:<pre>23423</pre>
|
||||||
|
* 此参数必填
|
||||||
|
@return 商品池ID
|
||||||
|
*/
|
||||||
|
private Long offerPoolId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置类目ID *
|
||||||
|
* 参数示例:<pre>324234</pre>
|
||||||
|
* 此参数必填
|
||||||
|
@return 类目ID
|
||||||
|
*/
|
||||||
|
private Long cateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置查询任务ID *
|
||||||
|
* 参数示例:<pre>1</pre>
|
||||||
|
* 此参数必填
|
||||||
|
@return 查询任务ID
|
||||||
|
*/
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置语言 *
|
||||||
|
* 参数示例:<pre>en</pre>
|
||||||
|
* 此参数必填
|
||||||
|
@return 语言
|
||||||
|
*/
|
||||||
|
private String language;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置页码 *
|
||||||
|
* 参数示例:<pre>1</pre>
|
||||||
|
* 此参数必填
|
||||||
|
@return 页码
|
||||||
|
*/
|
||||||
|
private Integer pageNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置每页数量 *
|
||||||
|
* 参数示例:<pre>10</pre>
|
||||||
|
* 此参数必填
|
||||||
|
@return 每页数量
|
||||||
|
*/
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置机构appKey *
|
||||||
|
* 参数示例:<pre>1</pre>
|
||||||
|
* 此参数必填
|
||||||
|
@return 机构appKey
|
||||||
|
*/
|
||||||
|
private String appKey;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.crossborder.param;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.APIId;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
|
||||||
|
public class PoolProductPullParam extends AbstractAPIRequest<PoolProductPullResult> {
|
||||||
|
|
||||||
|
public PoolProductPullParam() {
|
||||||
|
super();
|
||||||
|
oceanApiId = new APIId("com.alibaba.fenxiao.crossborder", "pool.product.pull", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PoolProductPullOfferPoolQueryParam offerPoolQueryParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public PoolProductPullOfferPoolQueryParam getOfferPoolQueryParam() {
|
||||||
|
return offerPoolQueryParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setOfferPoolQueryParam(PoolProductPullOfferPoolQueryParam offerPoolQueryParam) {
|
||||||
|
this.offerPoolQueryParam = offerPoolQueryParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.crossborder.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class PoolProductPullProductPoolModel {
|
||||||
|
|
||||||
|
private Long offerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 商品ID
|
||||||
|
*/
|
||||||
|
public Long getOfferId() {
|
||||||
|
return offerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置商品ID *
|
||||||
|
* 参数示例:<pre>111111</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setOfferId(Long offerId) {
|
||||||
|
this.offerId = offerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String bizCategoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 机构类目ID
|
||||||
|
*/
|
||||||
|
public String getBizCategoryId() {
|
||||||
|
return bizCategoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置机构类目ID *
|
||||||
|
* 参数示例:<pre>11111</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setBizCategoryId(String bizCategoryId) {
|
||||||
|
this.bizCategoryId = bizCategoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.crossborder.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class PoolProductPullResult {
|
||||||
|
|
||||||
|
private PoolProductPullResultModel result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public PoolProductPullResultModel getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(PoolProductPullResultModel result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.crossborder.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class PoolProductPullResultModel {
|
||||||
|
|
||||||
|
private String success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 调用结果
|
||||||
|
*/
|
||||||
|
public String getSuccess() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置调用结果 *
|
||||||
|
* 参数示例:<pre>true</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSuccess(String success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 错误码
|
||||||
|
*/
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置错误码 *
|
||||||
|
* 参数示例:<pre>S0000</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 错误描述
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置错误描述 *
|
||||||
|
* 参数示例:<pre>成功</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PoolProductPullProductPoolModel[] result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public PoolProductPullProductPoolModel[] getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置结果 *
|
||||||
|
* 参数示例:<pre>如下</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(PoolProductPullProductPoolModel[] result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class ComAlibabaOceanOpenplatformBizTradeResultSaleLimitAddress {
|
||||||
|
|
||||||
|
private String limitAddressCodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 禁售区域
|
||||||
|
*/
|
||||||
|
public String getLimitAddressCodes() {
|
||||||
|
return limitAddressCodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置禁售区域 *
|
||||||
|
* 参数示例:<pre>{"310000":{"310100":""},"320000":{"320100":"","320200":"","320300":"","320400":""}}</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setLimitAddressCodes(String limitAddressCodes) {
|
||||||
|
this.limitAddressCodes = limitAddressCodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 状态
|
||||||
|
*/
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置状态 *
|
||||||
|
* 参数示例:<pre>1</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 备注
|
||||||
|
*/
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置备注 *
|
||||||
|
* 参数示例:<pre>""</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.APIId;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
|
||||||
|
public class DkeyGetParam extends AbstractAPIRequest<DkeyGetResult> {
|
||||||
|
|
||||||
|
public DkeyGetParam() {
|
||||||
|
super();
|
||||||
|
oceanApiId = new APIId("com.alibaba.fenxiao", "dkey.get", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private long[] offerIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return offerId列表
|
||||||
|
*/
|
||||||
|
public long[] getOfferIds() {
|
||||||
|
return offerIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置offerId列表 *
|
||||||
|
* 参数示例:<pre>[1233465454554,1223354545]</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setOfferIds(long[] offerIds) {
|
||||||
|
this.offerIds = offerIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String entranceCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 入口类型,不传默认1688
|
||||||
|
*/
|
||||||
|
public String getEntranceCode() {
|
||||||
|
return entranceCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置入口类型,不传默认1688 *
|
||||||
|
* 参数示例:<pre>entrance_pft</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setEntranceCode(String entranceCode) {
|
||||||
|
this.entranceCode = entranceCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class DkeyGetResult {
|
||||||
|
|
||||||
|
private AlibabaCbuDistributeModelDkeyResultModel result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 生成的dKey模型
|
||||||
|
*/
|
||||||
|
public AlibabaCbuDistributeModelDkeyResultModel getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置生成的dKey模型 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(AlibabaCbuDistributeModelDkeyResultModel result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.APIId;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
|
||||||
|
public class FenxiaoDistributebillGetListParam extends AbstractAPIRequest<FenxiaoDistributebillGetListResult> {
|
||||||
|
|
||||||
|
public FenxiaoDistributebillGetListParam() {
|
||||||
|
super();
|
||||||
|
oceanApiId = new APIId("com.alibaba.fenxiao", "fenxiao.distributebill.getList", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class FenxiaoDistributebillGetListResult {
|
||||||
|
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean getSuccess() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSuccess(Boolean success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AlibabaOceanOpenplatformBizProductResultGlobalDistributeBillOfferListResult result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AlibabaOceanOpenplatformBizProductResultGlobalDistributeBillOfferListResult getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(AlibabaOceanOpenplatformBizProductResultGlobalDistributeBillOfferListResult result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.APIId;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
|
||||||
|
public class FenxiaoDistributebillRemoveallParam extends AbstractAPIRequest<FenxiaoDistributebillRemoveallResult> {
|
||||||
|
|
||||||
|
public FenxiaoDistributebillRemoveallParam() {
|
||||||
|
super();
|
||||||
|
oceanApiId = new APIId("com.alibaba.fenxiao", "fenxiao.distributebill.removeall", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class FenxiaoDistributebillRemoveallResult {
|
||||||
|
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean getSuccess() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSuccess(Boolean success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Boolean result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(Boolean result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.APIId;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
|
||||||
|
public class JxhyProductFilterGetParam extends AbstractAPIRequest<JxhyProductFilterGetResult> {
|
||||||
|
|
||||||
|
public JxhyProductFilterGetParam() {
|
||||||
|
super();
|
||||||
|
oceanApiId = new APIId("com.alibaba.fenxiao", "jxhy.productFilter.get", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductFilterGetQueryResult {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return filter类型
|
||||||
|
*/
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置filter类型 *
|
||||||
|
* 参数示例:<pre>shipIn48Hours</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return filter描述
|
||||||
|
*/
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置filter描述 *
|
||||||
|
* 参数示例:<pre>48小时发货</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setDesc(String desc) {
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductFilterGetResult {
|
||||||
|
|
||||||
|
private JxhyProductFilterGetResultModel result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 结果值
|
||||||
|
*/
|
||||||
|
public JxhyProductFilterGetResultModel getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置结果值 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(JxhyProductFilterGetResultModel result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductFilterGetResultModel {
|
||||||
|
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public Boolean getSuccess() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置是否成功 *
|
||||||
|
* 参数示例:<pre>true</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSuccess(Boolean success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 错误信息
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置错误信息 *
|
||||||
|
* 参数示例:<pre>null</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 错误码
|
||||||
|
*/
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置错误码 *
|
||||||
|
* 参数示例:<pre>null</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JxhyProductFilterGetQueryResult[] result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 结果值
|
||||||
|
*/
|
||||||
|
public JxhyProductFilterGetQueryResult[] getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置结果值 *
|
||||||
|
* 参数示例:<pre>[]</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(JxhyProductFilterGetQueryResult[] result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductGetPageListPageInfo {
|
||||||
|
|
||||||
|
private Integer currentPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 当前页码
|
||||||
|
*/
|
||||||
|
public Integer getCurrentPage() {
|
||||||
|
return currentPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置当前页码 *
|
||||||
|
* 参数示例:<pre>1</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setCurrentPage(Integer currentPage) {
|
||||||
|
this.currentPage = currentPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer totalRecords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 结果总数
|
||||||
|
*/
|
||||||
|
public Integer getTotalRecords() {
|
||||||
|
return totalRecords;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置结果总数 *
|
||||||
|
* 参数示例:<pre>100</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setTotalRecords(Integer totalRecords) {
|
||||||
|
this.totalRecords = totalRecords;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 分页大小
|
||||||
|
*/
|
||||||
|
public Integer getPageSize() {
|
||||||
|
return pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置分页大小 *
|
||||||
|
* 参数示例:<pre>10</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setPageSize(Integer pageSize) {
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.APIId;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class JxhyProductGetPageListParam extends AbstractAPIRequest<JxhyProductGetPageListResult> {
|
||||||
|
|
||||||
|
public JxhyProductGetPageListParam() {
|
||||||
|
super();
|
||||||
|
oceanApiId = new APIId("com.alibaba.fenxiao", "jxhy.product.getPageList", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置当前页码 *
|
||||||
|
* 参数示例:<pre>1</pre>
|
||||||
|
* 此参数必填
|
||||||
|
* 当前页码
|
||||||
|
*/
|
||||||
|
private Integer pageNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置分页大小(默认为20,最大为50) *
|
||||||
|
* 参数示例:<pre>10</pre>
|
||||||
|
* 此参数必填
|
||||||
|
* 分页大小(默认为20,最大为50)
|
||||||
|
*/
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置关键词 *
|
||||||
|
* 参数示例:<pre>"连衣裙"</pre>
|
||||||
|
* 此参数必填
|
||||||
|
* 关键词
|
||||||
|
*/
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置选品Id *
|
||||||
|
* 参数示例:<pre>["357954"]</pre>
|
||||||
|
* 此参数必填
|
||||||
|
* 选品Id
|
||||||
|
*/
|
||||||
|
private String[] ruleIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置类目Id,1,2,3级均可,填几级类目就限定到第几级 *
|
||||||
|
* 参数示例:<pre>80</pre>
|
||||||
|
* 此参数必填
|
||||||
|
* 类目Id,1,2,3级均可,填几级类目就限定到第几级
|
||||||
|
*/
|
||||||
|
private Long categoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置价格区间开始(大市场价格,元) *
|
||||||
|
* 参数示例:<pre>"1"</pre>
|
||||||
|
* 此参数必填
|
||||||
|
* 价格区间开始(大市场价格,元)
|
||||||
|
*/
|
||||||
|
private String priceStart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置价格区间结束(大市场价格,元) *
|
||||||
|
* 参数示例:<pre>"10"</pre>
|
||||||
|
* 此参数必填
|
||||||
|
* 价格区间结束(大市场价格,元)
|
||||||
|
*/
|
||||||
|
private String priceEnd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置过滤枚举(从精选货源商品列表筛选条件枚举值查询中获取) *
|
||||||
|
* 参数示例:<pre>["getRate24HLv1"]</pre>
|
||||||
|
* 此参数必填
|
||||||
|
* 过滤枚举(从精选货源商品列表筛选条件枚举值查询中获取)
|
||||||
|
*/
|
||||||
|
private String[] filters;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductGetPageListQueryResult {
|
||||||
|
|
||||||
|
private String imgUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getImgUrl() {
|
||||||
|
return imgUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setImgUrl(String imgUrl) {
|
||||||
|
this.imgUrl = imgUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long itemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setItemId(Long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long maxPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Long getMaxPrice() {
|
||||||
|
return maxPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMaxPrice(Long maxPrice) {
|
||||||
|
this.maxPrice = maxPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long minPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Long getMinPrice() {
|
||||||
|
return minPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMinPrice(Long minPrice) {
|
||||||
|
this.minPrice = minPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer salesCnt90d;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer getSalesCnt90d() {
|
||||||
|
return salesCnt90d;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSalesCnt90d(Integer salesCnt90d) {
|
||||||
|
this.salesCnt90d = salesCnt90d;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JxhyProductGetPageListSellPointModel sellPointInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public JxhyProductGetPageListSellPointModel getSellPointInfo() {
|
||||||
|
return sellPointInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSellPointInfo(JxhyProductGetPageListSellPointModel sellPointInfo) {
|
||||||
|
this.sellPointInfo = sellPointInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JxhyProductGetPageListServiceModel[] serviceList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public JxhyProductGetPageListServiceModel[] getServiceList() {
|
||||||
|
return serviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setServiceList(JxhyProductGetPageListServiceModel[] serviceList) {
|
||||||
|
this.serviceList = serviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer skuCnt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 精选货源价格的sku数量
|
||||||
|
*/
|
||||||
|
public Integer getSkuCnt() {
|
||||||
|
return skuCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置精选货源价格的sku数量 *
|
||||||
|
* 参数示例:<pre>5</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSkuCnt(Integer skuCnt) {
|
||||||
|
this.skuCnt = skuCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductGetPageListResult {
|
||||||
|
|
||||||
|
private JxhyProductGetPageListResultModel result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 返回值
|
||||||
|
*/
|
||||||
|
public JxhyProductGetPageListResultModel getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置返回值 *
|
||||||
|
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(JxhyProductGetPageListResultModel result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductGetPageListResultModel {
|
||||||
|
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public Boolean getSuccess() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置是否成功 *
|
||||||
|
* 参数示例:<pre>true</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSuccess(Boolean success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 错误信息
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置错误信息 *
|
||||||
|
* 参数示例:<pre>null</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 错误码
|
||||||
|
*/
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置错误码 *
|
||||||
|
* 参数示例:<pre>null</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JxhyProductGetPageListQueryResult[] result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 结果值
|
||||||
|
*/
|
||||||
|
public JxhyProductGetPageListQueryResult[] getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置结果值 *
|
||||||
|
* 参数示例:<pre>[]</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setResult(JxhyProductGetPageListQueryResult[] result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JxhyProductGetPageListPageInfo pageInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 分页信息
|
||||||
|
*/
|
||||||
|
public JxhyProductGetPageListPageInfo getPageInfo() {
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置分页信息 *
|
||||||
|
* 参数示例:<pre>{}</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setPageInfo(JxhyProductGetPageListPageInfo pageInfo) {
|
||||||
|
this.pageInfo = pageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer skuCnt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 精选货源价格的sku数量
|
||||||
|
*/
|
||||||
|
public Integer getSkuCnt() {
|
||||||
|
return skuCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置精选货源价格的sku数量 *
|
||||||
|
* 参数示例:<pre>5</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSkuCnt(Integer skuCnt) {
|
||||||
|
this.skuCnt = skuCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductGetPageListSellPointModel {
|
||||||
|
|
||||||
|
private String itemTags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getItemTags() {
|
||||||
|
return itemTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setItemTags(String itemTags) {
|
||||||
|
this.itemTags = itemTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String longSellingPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getLongSellingPoint() {
|
||||||
|
return longSellingPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setLongSellingPoint(String longSellingPoint) {
|
||||||
|
this.longSellingPoint = longSellingPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long offerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Long getOfferId() {
|
||||||
|
return offerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setOfferId(Long offerId) {
|
||||||
|
this.offerId = offerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String shotSellingPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getShotSellingPoint() {
|
||||||
|
return shotSellingPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setShotSellingPoint(String shotSellingPoint) {
|
||||||
|
this.shotSellingPoint = shotSellingPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long tagId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Long getTagId() {
|
||||||
|
return tagId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setTagId(Long tagId) {
|
||||||
|
this.tagId = tagId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String tagName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getTagName() {
|
||||||
|
return tagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setTagName(String tagName) {
|
||||||
|
this.tagName = tagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package org.springblade.modules.alibaba.fenxiao.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class JxhyProductGetPageListServiceModel {
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 *
|
||||||
|
* 参数示例:<pre></pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package org.springblade.modules.alibaba.logistics.param;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class ComAlibabaOceanOpenplatformBizLogisticsCommonModelOpenPlatformLogisticsOrderSendGood {
|
||||||
|
|
||||||
|
private Long logisticsOrderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 物流订单号
|
||||||
|
*/
|
||||||
|
public Long getLogisticsOrderId() {
|
||||||
|
return logisticsOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置物流订单号 *
|
||||||
|
* 参数示例:<pre>189435013090051</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setLogisticsOrderId(Long logisticsOrderId) {
|
||||||
|
this.logisticsOrderId = logisticsOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String logisticsId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 物流编号
|
||||||
|
*/
|
||||||
|
public String getLogisticsId() {
|
||||||
|
return logisticsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置物流编号 *
|
||||||
|
* 参数示例:<pre>LP00616288919385</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setLogisticsId(String logisticsId) {
|
||||||
|
this.logisticsId = logisticsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long tradeOrderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 交易主订单号
|
||||||
|
*/
|
||||||
|
public Long getTradeOrderId() {
|
||||||
|
return tradeOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置交易主订单号 *
|
||||||
|
* 参数示例:<pre>3657499272179232333</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setTradeOrderId(Long tradeOrderId) {
|
||||||
|
this.tradeOrderId = tradeOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long tradeOrderItemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 交易子订单号
|
||||||
|
*/
|
||||||
|
public Long getTradeOrderItemId() {
|
||||||
|
return tradeOrderItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置交易子订单号 *
|
||||||
|
* 参数示例:<pre>3657499272179232333</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setTradeOrderItemId(Long tradeOrderItemId) {
|
||||||
|
this.tradeOrderItemId = tradeOrderItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return sku描述
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置sku描述 *
|
||||||
|
* 参数示例:<pre>颜色: 黑色; 尺码: M;</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Double quantity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 数量
|
||||||
|
*/
|
||||||
|
public Double getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数量 *
|
||||||
|
* 参数示例:<pre>1</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setQuantity(Double quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 单位
|
||||||
|
*/
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置单位 *
|
||||||
|
* 参数示例:<pre>件</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 商品名称
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置商品名称 *
|
||||||
|
* 参数示例:<pre>短袖t恤女2023夏季新款韩版宽松字母圆领上衣半袖体恤打底衫女潮</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 商品名称
|
||||||
|
*/
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置商品名称 *
|
||||||
|
* 参数示例:<pre>品名</pre>
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,268 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.*;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.AuthorizationToken;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.AuthorizationTokenStore;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.DefaultAuthorizationTokenStore;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.exception.OceanException;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.InvokeContext;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.mapi.MapiResult;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.mapi.SyncMapiClient;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.ClientPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.RequestPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.SDKResult;
|
||||||
|
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The API facade.
|
||||||
|
*/
|
||||||
|
public final class ApiExecutor implements SDKListener {
|
||||||
|
|
||||||
|
private String serverHost = "gw.open.1688.com";
|
||||||
|
private int httpPort = 80;
|
||||||
|
private int httpsPort = 443;
|
||||||
|
private String appKey;
|
||||||
|
private String secKey;
|
||||||
|
|
||||||
|
private Proxy proxy;
|
||||||
|
|
||||||
|
private AuthorizationTokenStore authorizationTokenStore;
|
||||||
|
|
||||||
|
private Map<Class<? extends SerializerListener>, SerializerListener> serializerListeners = new LinkedHashMap<Class<? extends SerializerListener>, SerializerListener>();
|
||||||
|
private Map<Class<? extends DeSerializerListener>, DeSerializerListener> deSerializerListeners = new LinkedHashMap<Class<? extends DeSerializerListener>, DeSerializerListener>();
|
||||||
|
private volatile SyncAPIClient syncAPIClient;
|
||||||
|
private volatile SyncMapiClient syncMAPIClient;
|
||||||
|
|
||||||
|
public ApiExecutor(String appKey, String secKey) {
|
||||||
|
super();
|
||||||
|
this.appKey = appKey;
|
||||||
|
this.secKey = secKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiExecutor(String appKey, String secKey, Proxy proxy) {
|
||||||
|
super();
|
||||||
|
this.appKey = appKey;
|
||||||
|
this.secKey = secKey;
|
||||||
|
this.proxy = proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiExecutor(String serverHost, int httpPort, int httpsPort, String appKey, String secKey) {
|
||||||
|
super();
|
||||||
|
this.serverHost = serverHost;
|
||||||
|
this.httpPort = httpPort;
|
||||||
|
this.httpsPort = httpsPort;
|
||||||
|
this.appKey = appKey;
|
||||||
|
this.secKey = secKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiExecutor(String serverHost, int httpPort, int httpsPort, String appKey, String secKey, Proxy proxy) {
|
||||||
|
super();
|
||||||
|
this.serverHost = serverHost;
|
||||||
|
this.httpPort = httpPort;
|
||||||
|
this.httpsPort = httpsPort;
|
||||||
|
this.appKey = appKey;
|
||||||
|
this.secKey = secKey;
|
||||||
|
this.proxy = proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(SerializerListener serializerListener) {
|
||||||
|
serializerListeners.put(serializerListener.getClass(), serializerListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(DeSerializerListener deSerializerListener) {
|
||||||
|
deSerializerListeners.put(deSerializerListener.getClass(), deSerializerListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SyncAPIClient getAPIClient() {
|
||||||
|
ClientPolicy clientPolicy = new ClientPolicy(serverHost);
|
||||||
|
clientPolicy.setHttpPort(httpPort);
|
||||||
|
clientPolicy.setHttpsPort(httpsPort);
|
||||||
|
if (appKey != null) {
|
||||||
|
clientPolicy.setAppKey(appKey);
|
||||||
|
}
|
||||||
|
if (secKey != null) {
|
||||||
|
clientPolicy.setSigningKey(secKey);
|
||||||
|
}
|
||||||
|
if (proxy != null) {
|
||||||
|
clientPolicy.setProxy(proxy);
|
||||||
|
}
|
||||||
|
if (authorizationTokenStore == null) {
|
||||||
|
authorizationTokenStore = new DefaultAuthorizationTokenStore();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syncAPIClient == null) {
|
||||||
|
synchronized(this) {
|
||||||
|
if (syncAPIClient == null) {
|
||||||
|
syncAPIClient = new AlibabaClientFactory().createAPIClient(clientPolicy, authorizationTokenStore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return syncAPIClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SyncMapiClient getMAPIClient() {
|
||||||
|
ClientPolicy clientPolicy = new ClientPolicy(serverHost);
|
||||||
|
clientPolicy.setHttpPort(httpPort);
|
||||||
|
clientPolicy.setHttpsPort(httpsPort);
|
||||||
|
if (appKey != null) {
|
||||||
|
clientPolicy.setAppKey(appKey);
|
||||||
|
}
|
||||||
|
if (secKey != null) {
|
||||||
|
clientPolicy.setSigningKey(secKey);
|
||||||
|
}
|
||||||
|
if (authorizationTokenStore == null) {
|
||||||
|
authorizationTokenStore = new DefaultAuthorizationTokenStore();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syncMAPIClient == null) {
|
||||||
|
synchronized(this) {
|
||||||
|
if (syncMAPIClient == null) {
|
||||||
|
syncMAPIClient = new AlibabaClientFactory().createMAPIClient(clientPolicy, authorizationTokenStore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return syncMAPIClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param code
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final AuthorizationToken getToken(String code) {
|
||||||
|
try {
|
||||||
|
return getAPIClient().getToken(code);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* refresh the access token with refreshToken
|
||||||
|
*
|
||||||
|
* @param refreshToken
|
||||||
|
*
|
||||||
|
* @return access token object.
|
||||||
|
*/
|
||||||
|
public final AuthorizationToken refreshToken(String refreshToken) {
|
||||||
|
try {
|
||||||
|
return getAPIClient().refreshToken(refreshToken);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param apiRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final <TResponse> SDKResult<TResponse> execute(AbstractAPIRequest<TResponse> apiRequest) {
|
||||||
|
RequestPolicy reqPolicy = apiRequest.getOceanRequestPolicy();
|
||||||
|
InvokeContext context=new InvokeContext();
|
||||||
|
try {
|
||||||
|
APIId apiId = apiRequest.getOceanApiId();
|
||||||
|
Request req = new Request(apiId.getNamespace(), apiId.getName(), apiId.getVersion());
|
||||||
|
req.setTraceId(apiRequest.getTraceId());
|
||||||
|
req.setRpcId(apiRequest.getRpcId());
|
||||||
|
req.setRequestEntity(apiRequest);
|
||||||
|
TResponse ret = getAPIClient().send(req, apiRequest.getResponseClass(), reqPolicy,
|
||||||
|
serializerListeners.values(), deSerializerListeners.values(),context);
|
||||||
|
return buildSdkResult( ret,context,null,null,null);
|
||||||
|
} catch (OceanException e) {
|
||||||
|
if(e.getErrorCode()==null){
|
||||||
|
return buildSdkResult(null,context,"UNKNOWN_ERROR",e.getErrorMessage(),e);
|
||||||
|
}
|
||||||
|
return buildSdkResult(null,context,e.getErrorCode(), e.getErrorMessage(),e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param apiRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final <TResponse> SDKResult<TResponse> execute(AbstractAPIRequest<TResponse> apiRequest, String accessToken) {
|
||||||
|
RequestPolicy reqPolicy = apiRequest.getOceanRequestPolicy();
|
||||||
|
InvokeContext context=new InvokeContext();
|
||||||
|
try {
|
||||||
|
APIId apiId = apiRequest.getOceanApiId();
|
||||||
|
Request req = new Request(apiId.getNamespace(), apiId.getName(), apiId.getVersion());
|
||||||
|
req.setRequestEntity(apiRequest);
|
||||||
|
req.setAccessToken(accessToken);
|
||||||
|
req.setTraceId(apiRequest.getTraceId());
|
||||||
|
req.setRpcId(apiRequest.getRpcId());
|
||||||
|
TResponse ret = getAPIClient().send(req, apiRequest.getResponseClass(), reqPolicy,
|
||||||
|
serializerListeners.values(), deSerializerListeners.values(),context);
|
||||||
|
return buildSdkResult( ret,context,null,null,null);
|
||||||
|
} catch (OceanException e) {
|
||||||
|
if(e.getErrorCode()==null){
|
||||||
|
return buildSdkResult(null,context,"UNKNOWN_ERROR",e.getErrorMessage(),e);
|
||||||
|
}
|
||||||
|
return buildSdkResult(null,context,e.getErrorCode(), e.getErrorMessage(),e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private <TResponse> SDKResult<TResponse> buildSdkResult(TResponse ret,InvokeContext context,String errorCode,String errorMessage,OceanException e) {
|
||||||
|
SDKResult<TResponse> result = new SDKResult<TResponse>();
|
||||||
|
result.setErrorCode(errorCode);
|
||||||
|
result.setErrorMessage(errorMessage);
|
||||||
|
result.setResult(ret);
|
||||||
|
if(context!=null && context.getResponse()!=null) {
|
||||||
|
if(context.getResponse().getRequestId()!=null){
|
||||||
|
result.setRequestId(context.getResponse().getRequestId());
|
||||||
|
}
|
||||||
|
if(context.getResponse().getTraceId()!=null){
|
||||||
|
result.setTraceId(context.getResponse().getTraceId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(e!=null && e.getRequestId()!=null && e.getTraceId()!=null){
|
||||||
|
result.setRequestId(e.getRequestId());
|
||||||
|
result.setTraceId(e.getTraceId());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param apiRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final <TResponse> SDKResult<MapiResult<TResponse>> mapiExecute(AbstractAPIRequest<TResponse> apiRequest, String accessToken) {
|
||||||
|
RequestPolicy reqPolicy = apiRequest.getOceanRequestPolicy();
|
||||||
|
try {
|
||||||
|
APIId apiId = apiRequest.getOceanApiId();
|
||||||
|
Request req = new Request(apiId.getNamespace(), apiId.getName(), apiId.getVersion());
|
||||||
|
|
||||||
|
req.setRequestEntity(apiRequest);
|
||||||
|
if(accessToken!=null){
|
||||||
|
req.setAccessToken(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
MapiResult<TResponse> ret = getMAPIClient().mapiSend(req, apiRequest.getResponseClass(), reqPolicy,
|
||||||
|
serializerListeners.values(), deSerializerListeners.values());
|
||||||
|
return new SDKResult<>(ret);
|
||||||
|
} catch (OceanException e) {
|
||||||
|
return new SDKResult<>(e.getErrorCode(), e.getErrorMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.AuthorizationToken;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.exception.OceanException;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.RequestPolicy;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface APIClient {
|
||||||
|
|
||||||
|
|
||||||
|
public <T> T send(Request request, Class<T> resultType, RequestPolicy policy) throws OceanException;
|
||||||
|
|
||||||
|
|
||||||
|
public AuthorizationToken getToken(String code) throws OceanException;
|
||||||
|
|
||||||
|
|
||||||
|
public AuthorizationToken refreshToken(String refreshToken) throws OceanException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void start();
|
||||||
|
|
||||||
|
public void shutdown();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class APIId implements Serializable {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 3310099984731564724L;
|
||||||
|
|
||||||
|
public static final int DEFAULT_VERSION = 1;
|
||||||
|
|
||||||
|
private String namespace;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private int version;
|
||||||
|
|
||||||
|
public APIId() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public APIId(String namespace, String name) {
|
||||||
|
this(namespace, name, DEFAULT_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public APIId(String namespace, String name, int version) {
|
||||||
|
this.namespace = namespace;
|
||||||
|
this.name = name;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return namespace + ':' + name + '-' + version;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.exception.OceanException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类ErrorHandler.java的实现描述:业务异常处理
|
||||||
|
* @author fray.yangb Aug 15, 2012 4:00:33 PM
|
||||||
|
*/
|
||||||
|
public interface ErrorHandler {
|
||||||
|
void handle(OceanException targetException);
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
/**
|
||||||
|
* Project: ocean.client.java.basic
|
||||||
|
*
|
||||||
|
* File Created at 2011-10-17
|
||||||
|
* $Id: Request.java 406840 2015-04-13 09:12:42Z hongbang.hb $
|
||||||
|
*
|
||||||
|
* Copyright 2008 Alibaba.com Croporation Limited.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is the confidential and proprietary information of
|
||||||
|
* Alibaba Company. ("Confidential Information"). You shall not
|
||||||
|
* disclose such Confidential Information and shall use it only in
|
||||||
|
* accordance with the terms of the license agreement you entered into
|
||||||
|
* with Alibaba.com.
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.AuthorizationToken;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API请求实体
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @author jade
|
||||||
|
* @author xiaoning.qxn
|
||||||
|
*/
|
||||||
|
public class Request {
|
||||||
|
|
||||||
|
public static final String ACCESS_TOKEN = "access_token";
|
||||||
|
|
||||||
|
private APIId apiId;
|
||||||
|
private Map<String, Object> addtionalParams = new HashMap<String, Object>();
|
||||||
|
private AbstractAPIRequest requestEntity;
|
||||||
|
private Map<String, String> attachments;
|
||||||
|
private String authCodeKey;
|
||||||
|
private String accessToken;
|
||||||
|
private AuthorizationToken authToken;
|
||||||
|
private String traceId;
|
||||||
|
private String rpcId;
|
||||||
|
|
||||||
|
public Request(String namespace, String name) {
|
||||||
|
apiId = new APIId(namespace, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用API唯一标示:namespace,name,version构建一个API request
|
||||||
|
*
|
||||||
|
* @param namespace
|
||||||
|
* @param name
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
public Request(String namespace, String name, int version) {
|
||||||
|
apiId = new APIId(namespace, name, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Request(APIId apiId) {
|
||||||
|
this.apiId = apiId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public APIId getApiId() {
|
||||||
|
return apiId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Request setAttachment(String name, String value) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getAttachments() {
|
||||||
|
if (attachments == null) {
|
||||||
|
attachments = new LinkedHashMap<String, String>();
|
||||||
|
}
|
||||||
|
return attachments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractAPIRequest getRequestEntity() {
|
||||||
|
return requestEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestEntity(AbstractAPIRequest requestEntity) {
|
||||||
|
this.requestEntity = requestEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getAddtionalParams() {
|
||||||
|
return addtionalParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAddtionalParams(String key, Object param) {
|
||||||
|
addtionalParams.put(key, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthCodeKey() {
|
||||||
|
return authCodeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Request setAuthCodeKey(String authCodeKey) {
|
||||||
|
this.authCodeKey = authCodeKey;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessToken() {
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Request setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
addtionalParams.put(ACCESS_TOKEN, accessToken);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken getAuthToken() {
|
||||||
|
return authToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Request setAuthToken(AuthorizationToken authToken) {
|
||||||
|
this.authToken = authToken;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTraceId() {
|
||||||
|
return traceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTraceId(String traceId) {
|
||||||
|
this.traceId = traceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRpcId() {
|
||||||
|
return rpcId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRpcId(String rpcId) {
|
||||||
|
this.rpcId = rpcId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/**
|
||||||
|
* Project: ocean.client.java.basic
|
||||||
|
*
|
||||||
|
* File Created at 2011-10-18
|
||||||
|
* $Id: Response.java 410052 2015-05-06 08:18:05Z hongbang.hb $
|
||||||
|
*
|
||||||
|
* Copyright 2008 Alibaba.com Croporation Limited.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is the confidential and proprietary information of
|
||||||
|
* Alibaba Company. ("Confidential Information"). You shall not
|
||||||
|
* disclose such Confidential Information and shall use it only in
|
||||||
|
* accordance with the terms of the license agreement you entered into
|
||||||
|
* with Alibaba.com.
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.ResponseWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http调用返回的结果对象
|
||||||
|
*
|
||||||
|
* @author jade
|
||||||
|
*/
|
||||||
|
public class Response {
|
||||||
|
private static final String DEFAULT_CHARSET = "UTF-8";
|
||||||
|
private int statusCode;
|
||||||
|
private Object result;
|
||||||
|
private Throwable exception;
|
||||||
|
private String charset = DEFAULT_CHARSET;
|
||||||
|
private String encoding;
|
||||||
|
private String requestId;
|
||||||
|
private String traceId;
|
||||||
|
private ResponseWrapper responseWrapper;
|
||||||
|
|
||||||
|
public Response setResult(Object result) {
|
||||||
|
this.result = result;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatusCode() {
|
||||||
|
return statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusCode(int statusCode) {
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Throwable getException() {
|
||||||
|
return exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setException(Throwable exception) {
|
||||||
|
this.exception = exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCharset() {
|
||||||
|
return charset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharset(String charset) {
|
||||||
|
this.charset = charset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEncoding() {
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEncoding(String encoding) {
|
||||||
|
this.encoding = encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestId() {
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestId(String requestId) {
|
||||||
|
this.requestId = requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTraceId() {
|
||||||
|
return traceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTraceId(String traceId) {
|
||||||
|
this.traceId = traceId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface SDKListener {
|
||||||
|
|
||||||
|
public void register(SerializerListener serializerListener);
|
||||||
|
|
||||||
|
public void register(DeSerializerListener deSerializerListener);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.AuthorizationToken;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.AuthorizationTokenStore;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.DefaultAuthorizationTokenStore;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.exception.OceanException;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.AbstractHttpClient;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.HttpResponseBuilder;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.InvokeContext;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.platform.DefaultHttpResponseBuilder;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.platform.HttpURLConnectionClient;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.ClientPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.RequestPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerProvider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SyncAPIClient {
|
||||||
|
|
||||||
|
private final AbstractHttpClient httpClient;
|
||||||
|
private final ClientPolicy clientPolicy;
|
||||||
|
private AuthorizationTokenStore authorizationTokenStore;
|
||||||
|
|
||||||
|
public SyncAPIClient(ClientPolicy clientPolicy, SerializerProvider serializerProvider) {
|
||||||
|
this(clientPolicy, serializerProvider, new DefaultAuthorizationTokenStore());
|
||||||
|
}
|
||||||
|
|
||||||
|
public SyncAPIClient(ClientPolicy clientPolicy, SerializerProvider serializerProvider,
|
||||||
|
AuthorizationTokenStore authorizationTokenStore) {
|
||||||
|
super();
|
||||||
|
this.clientPolicy = clientPolicy;
|
||||||
|
this.authorizationTokenStore = authorizationTokenStore;
|
||||||
|
HttpResponseBuilder httpResponseBuilder = new DefaultHttpResponseBuilder(clientPolicy, serializerProvider);
|
||||||
|
httpClient = new HttpURLConnectionClient(serializerProvider, httpResponseBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T send(Request request, Class<T> resultType, RequestPolicy policy) throws OceanException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T send(Request request, Class<T> resultType, RequestPolicy policy,
|
||||||
|
Collection<SerializerListener> serializerListners, Collection<DeSerializerListener> deSerializerListners, InvokeContext context)
|
||||||
|
throws OceanException {
|
||||||
|
InvokeContext invokeContext = context == null? new InvokeContext() : context;
|
||||||
|
invokeContext.setPolicy(policy);
|
||||||
|
invokeContext.setRequest(request);
|
||||||
|
invokeContext.setResultType(resultType);
|
||||||
|
try {
|
||||||
|
httpClient.request(invokeContext, clientPolicy, serializerListners, deSerializerListners);
|
||||||
|
if (invokeContext.getResponse().getException() != null) {
|
||||||
|
Throwable responseException = invokeContext.getResponse().getException();
|
||||||
|
if (responseException instanceof OceanException) {
|
||||||
|
((OceanException) responseException).setRequestId(invokeContext.getResponse().getRequestId());
|
||||||
|
((OceanException) responseException).setTraceId(invokeContext.getResponse().getTraceId());
|
||||||
|
throw (OceanException) responseException;
|
||||||
|
} else {
|
||||||
|
throw new OceanException("UNKNOWN_ERROR",responseException.getMessage(),responseException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (T) invokeContext.getResponse().getResult();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new OceanException("IOException",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken getToken(String code) throws OceanException {
|
||||||
|
|
||||||
|
Request request = new Request("system.oauth2", "getToken");
|
||||||
|
request.addAddtionalParams("code", code);
|
||||||
|
request.addAddtionalParams("grant_type", "authorization_code");
|
||||||
|
request.addAddtionalParams("need_refresh_token", true);
|
||||||
|
request.addAddtionalParams("client_id", clientPolicy.getAppKey());
|
||||||
|
request.addAddtionalParams("client_secret", clientPolicy.getSigningKey());
|
||||||
|
request.addAddtionalParams("redirect_uri", "default");
|
||||||
|
RequestPolicy oauthPolicy = RequestPolicy.getAuthPolicy();
|
||||||
|
|
||||||
|
return this.send(request, AuthorizationToken.class, oauthPolicy, new ArrayList<>(),
|
||||||
|
new ArrayList<>(),null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken refreshToken(String refreshToken) throws OceanException {
|
||||||
|
Request request = new Request("system.oauth2", "getToken");
|
||||||
|
request.addAddtionalParams("refreshToken", refreshToken);
|
||||||
|
request.addAddtionalParams("grant_type", "refresh_token");
|
||||||
|
request.addAddtionalParams("client_id", clientPolicy.getAppKey());
|
||||||
|
request.addAddtionalParams("client_secret", clientPolicy.getSigningKey());
|
||||||
|
RequestPolicy oauthPolicy = RequestPolicy.getAuthPolicy();
|
||||||
|
return this.send(request, AuthorizationToken.class, oauthPolicy, new ArrayList<SerializerListener>(),
|
||||||
|
new ArrayList<DeSerializerListener>(),null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权返回结果
|
||||||
|
*
|
||||||
|
* @author fray.yangb Aug 21, 2012 2:47:07 PM
|
||||||
|
*/
|
||||||
|
public class AuthorizationToken implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -7582222338466164367L;
|
||||||
|
|
||||||
|
private String access_token;
|
||||||
|
private String refresh_token;
|
||||||
|
private long expires_in;
|
||||||
|
private Date expires_time;
|
||||||
|
private Date refresh_token_timeout;
|
||||||
|
private String resource_owner;
|
||||||
|
private String uid;
|
||||||
|
private long aliId;
|
||||||
|
private String memberId;
|
||||||
|
|
||||||
|
public AuthorizationToken(){
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken(String accessToken, long accessTokenTimeout, String resourceOwnerId, long aliId){
|
||||||
|
this(accessToken, accessTokenTimeout, null, null, resourceOwnerId, null, aliId, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken(String accessToken, long accessTokenTimeout, String resourceOwnerId, String uid,
|
||||||
|
long aliId, String memberId){
|
||||||
|
this(accessToken, accessTokenTimeout, null, null, resourceOwnerId, uid, aliId, memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken(String accessToken, long accessTokenTimeout, String refreshToken,
|
||||||
|
Date refreshTokenTimeout, String resourceOwnerId, long aliId, String memberId){
|
||||||
|
this(accessToken, accessTokenTimeout, refreshToken, refreshTokenTimeout, resourceOwnerId, null, aliId, memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken(String accessToken, long accessTokenTimeout, String refreshToken,
|
||||||
|
Date refreshTokenTimeout, String resourceOwnerId, String uid, long aliId, String memberId){
|
||||||
|
this.access_token = accessToken;
|
||||||
|
this.expires_in = accessTokenTimeout;
|
||||||
|
this.refresh_token = refreshToken;
|
||||||
|
this.refresh_token_timeout = refreshTokenTimeout;
|
||||||
|
this.resource_owner = resourceOwnerId;
|
||||||
|
this.uid = uid;
|
||||||
|
this.aliId = aliId;
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取access_token
|
||||||
|
*
|
||||||
|
* @return the accessToken
|
||||||
|
*/
|
||||||
|
public String getAccess_token() {
|
||||||
|
return access_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取access_token过期时间
|
||||||
|
*
|
||||||
|
* @return the accessTokenTimeout
|
||||||
|
*/
|
||||||
|
public long getExpires_in() {
|
||||||
|
return expires_in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取refresh_token
|
||||||
|
*
|
||||||
|
* @return the refreshToken
|
||||||
|
*/
|
||||||
|
public String getRefresh_token() {
|
||||||
|
return refresh_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取refresh_token过期时间
|
||||||
|
*
|
||||||
|
* @return the refreshTokenTimeout
|
||||||
|
*/
|
||||||
|
public Date getRefresh_token_timeout() {
|
||||||
|
return refresh_token_timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(String memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取resource_owner
|
||||||
|
*
|
||||||
|
* @return the resourceOwnerId
|
||||||
|
*/
|
||||||
|
public String getResource_owner() {
|
||||||
|
return resource_owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取uid
|
||||||
|
*
|
||||||
|
* @return the uid
|
||||||
|
*/
|
||||||
|
public String getUid() {
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取aliId
|
||||||
|
*
|
||||||
|
* @return the aliId
|
||||||
|
*/
|
||||||
|
public long getAliId() {
|
||||||
|
return aliId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccess_token(String accessToken) {
|
||||||
|
this.access_token = accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRefresh_token(String refreshToken) {
|
||||||
|
this.refresh_token = refreshToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpires_in(long accessTokenTimeout) {
|
||||||
|
this.expires_in = accessTokenTimeout;
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.add(Calendar.SECOND, (int) expires_in);
|
||||||
|
this.expires_time = cal.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRefresh_token_timeout(Date refresh_token_timeout) {
|
||||||
|
this.refresh_token_timeout = refresh_token_timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResource_owner(String resourceOwnerId) {
|
||||||
|
this.resource_owner = resourceOwnerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUid(String uid) {
|
||||||
|
this.uid = uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliId(long aliId) {
|
||||||
|
this.aliId = aliId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取access_token过期时间,Date格式
|
||||||
|
*
|
||||||
|
* @return the accessTokenTimeout
|
||||||
|
*/
|
||||||
|
public Date getExpires_time() {
|
||||||
|
return expires_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.entity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类AuthorizationCodeStore.java的实现描述:
|
||||||
|
* 提供Refresh Token 和 Access Token 的存取功能,
|
||||||
|
* 记录Access Token的有限时间,有限时间之内可以直接使用,出现授权异常时,sdk会refresh token,重新获取accessToken,执行storeToken
|
||||||
|
* 当refresh Token 过期时remove掉该authorizationCode。
|
||||||
|
* @author fray.yangb Aug 21, 2012 2:44:11 PM
|
||||||
|
*/
|
||||||
|
public interface AuthorizationTokenStore {
|
||||||
|
/**
|
||||||
|
* 根据授权Code获取授权信息,主要是RefreshToken
|
||||||
|
* @param authorizationCode
|
||||||
|
* @return {@link AuthorizationToken}
|
||||||
|
*/
|
||||||
|
public AuthorizationToken getToken(String authorizationCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存授权信息
|
||||||
|
* @param authorizationCode
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
|
public void storeToken(String authorizationCode, AuthorizationToken token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从store中移除该code所对应的token
|
||||||
|
* @param authorizationCode
|
||||||
|
*/
|
||||||
|
public void removeToken(String authorizationCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存用户的token
|
||||||
|
* @param uid
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
|
public void storeAccessToken(String uid, AuthorizationToken token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的access token
|
||||||
|
* @param uid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AuthorizationToken getAccessToken(String uid);
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.entity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultAuthorizationTokenStore
|
||||||
|
*
|
||||||
|
* @author fray.yangb Aug 21, 2012 3:25:30 PM
|
||||||
|
*/
|
||||||
|
public class DefaultAuthorizationTokenStore implements AuthorizationTokenStore {
|
||||||
|
private Map<Object, Object> cache = new HashMap<Object, Object>();
|
||||||
|
|
||||||
|
public AuthorizationToken getToken(String authorizationCode) {
|
||||||
|
return (AuthorizationToken) cache.get(authorizationCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void storeToken(String authorizationCode, AuthorizationToken token) {
|
||||||
|
cache.put(authorizationCode, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeToken(String authorizationCode) {
|
||||||
|
cache.remove(authorizationCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void storeAccessToken(String uid, AuthorizationToken token) {
|
||||||
|
cache.put(uid, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken getAccessToken(String uid) {
|
||||||
|
return (AuthorizationToken) cache.get(uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ResponseStatus {
|
||||||
|
private String code;
|
||||||
|
private String message;
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ResponseWrapper<T> {
|
||||||
|
private String invokeStartTime;
|
||||||
|
private long invokeCostTime;
|
||||||
|
private ResponseStatus status;
|
||||||
|
private T result;
|
||||||
|
|
||||||
|
private String signature;
|
||||||
|
|
||||||
|
public String getInvokeStartTime() {
|
||||||
|
return invokeStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvokeStartTime(String invokeStartTime) {
|
||||||
|
this.invokeStartTime = invokeStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getInvokeCostTime() {
|
||||||
|
return invokeCostTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvokeCostTime(long invokeCostTime) {
|
||||||
|
this.invokeCostTime = invokeCostTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(ResponseStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult(T result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignature() {
|
||||||
|
return signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignature(String signature) {
|
||||||
|
this.signature = signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ocean Exception
|
||||||
|
*
|
||||||
|
* @author xiaoning.qxn
|
||||||
|
*/
|
||||||
|
public class OceanException extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -1828858210195741131L;
|
||||||
|
|
||||||
|
protected String errorCode;
|
||||||
|
|
||||||
|
protected String errorMessage;
|
||||||
|
|
||||||
|
protected String traceId;
|
||||||
|
|
||||||
|
protected String requestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取返回的error_code错误码
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getErrorCode() {
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取返回的error_message错误信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OceanException(){
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public OceanException(String message){
|
||||||
|
super(message);
|
||||||
|
this.errorMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public OceanException(String errorCode, String message){
|
||||||
|
super(message);
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.errorMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public OceanException(String errorCode, String message,Throwable e){
|
||||||
|
super(e);
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.errorMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cause
|
||||||
|
*/
|
||||||
|
public OceanException(Throwable cause){
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
* @param cause
|
||||||
|
*/
|
||||||
|
public OceanException(String message, Throwable cause){
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTraceId() {
|
||||||
|
return traceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTraceId(String traceId) {
|
||||||
|
this.traceId = traceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestId() {
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestId(String requestId) {
|
||||||
|
this.requestId = requestId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Response;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface HttpResponseBuilder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param istream
|
||||||
|
* @param httpCode
|
||||||
|
* @param contentEncoding
|
||||||
|
* @param contentType
|
||||||
|
* @param invokeContext
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Response buildResponse(InputStream istream, int httpCode, String contentEncoding, String contentType,
|
||||||
|
InvokeContext invokeContext, Collection<DeSerializerListener> deSerializerListners);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Request;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.ClientPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.RequestPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.Serializer;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.util.DateUtil;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.util.GenericsUtil;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.util.SignatureUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class HttpSupport {
|
||||||
|
public static final String METHOD_GET = "GET";
|
||||||
|
public static final String METHOD_POST = "POST";
|
||||||
|
|
||||||
|
public static final char QUERY_STRING_SEPARATOR = '?';
|
||||||
|
public static final char PARAMETER_SEPARATOR = '&';
|
||||||
|
public static final char NAME_VALUE_SEPARATOR = '=';
|
||||||
|
|
||||||
|
public static final String PARAM_NAME_SIGNATURE = "_aop_signature";
|
||||||
|
public static final String PARAM_NAME_TIMESTAMP = "_aop_timestamp";
|
||||||
|
public static final String PARAM_NAME_DATEPATTERN = "_aop_datePattern";
|
||||||
|
public static final String PARAM_NAME_RESPONSE_FORMAT = "_aop_responseFormat";
|
||||||
|
public static final String PARAM_NAME_ACCESS_TOKEY = "access_token";
|
||||||
|
|
||||||
|
public final static Map<String, String> buildHttpHeader(InvokeContext context, ClientPolicy clientPolicy) {
|
||||||
|
Map<String, String> header = new LinkedHashMap<String, String>();
|
||||||
|
header.put("Accept", "text/xml,text/javascript,application/json");
|
||||||
|
header.put("User-Agent", clientPolicy.getAgent());
|
||||||
|
if(context.getRequest()!=null && context.getRequest().getTraceId()!=null){
|
||||||
|
header.put("EagleEye-TraceId",context.getRequest().getTraceId());
|
||||||
|
if(context.getRequest().getRpcId()!=null){
|
||||||
|
header.put("EagleEye-RpcId",context.getRequest().getTraceId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param requestPolicy
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final static StringBuilder getApiRequestPath(RequestPolicy requestPolicy) {
|
||||||
|
StringBuilder path = new StringBuilder();
|
||||||
|
if (requestPolicy.isAccessPrivateApi()) {
|
||||||
|
path.append("/api");
|
||||||
|
} else {
|
||||||
|
path.append("/openapi");
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param clientPolicy
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static StringBuilder getProtocolRequestPath(InvokeContext context, ClientPolicy clientPolicy) {
|
||||||
|
StringBuilder path = new StringBuilder();
|
||||||
|
path.append(context.getPolicy().getRequestProtocol().name()).append('/');
|
||||||
|
Request request = context.getRequest();
|
||||||
|
if (request.getApiId().getVersion() < 0) {
|
||||||
|
path.append(context.getPolicy().getDefaultApiVersion());
|
||||||
|
} else {
|
||||||
|
path.append(request.getApiId().getVersion());
|
||||||
|
}
|
||||||
|
path.append('/').append(request.getApiId().getNamespace()).append('/').append(request.getApiId().getName());
|
||||||
|
if (clientPolicy.getAppKey() != null) {
|
||||||
|
path.append('/').append(clientPolicy.getAppKey());
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param serializer
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> buildParams(Serializer serializer, InvokeContext context) {
|
||||||
|
Map<String, Object> serializerMap = serializer.serialize(context.getRequest().getRequestEntity());
|
||||||
|
|
||||||
|
serializerMap.putAll(context.getRequest().getAddtionalParams());
|
||||||
|
|
||||||
|
RequestPolicy requestPolicy = context.getPolicy();
|
||||||
|
if (!requestPolicy.getRequestProtocol().equals(requestPolicy.getResponseProtocol())) {
|
||||||
|
serializerMap.put(PARAM_NAME_RESPONSE_FORMAT, requestPolicy.getResponseProtocol().name());
|
||||||
|
}
|
||||||
|
if (requestPolicy.isRequestSendTimestamp()) {
|
||||||
|
serializerMap.put(PARAM_NAME_TIMESTAMP, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestPolicy.getDateFormat() != null) {
|
||||||
|
serializerMap.put(PARAM_NAME_DATEPATTERN, requestPolicy.getDateFormat());
|
||||||
|
} else {
|
||||||
|
serializerMap.put(PARAM_NAME_DATEPATTERN, DateUtil.SIMPLE_DATE_FORMAT_STR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return serializerMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param protocolRequestPath
|
||||||
|
* @param parameters
|
||||||
|
* @param requestPolicy
|
||||||
|
* @param clientPolicy
|
||||||
|
*/
|
||||||
|
public static void signature(StringBuilder protocolRequestPath, Map<String, Object> parameters,
|
||||||
|
RequestPolicy requestPolicy, ClientPolicy clientPolicy) {
|
||||||
|
if (!requestPolicy.isUseSignture())
|
||||||
|
return;
|
||||||
|
if (GenericsUtil.isBlank(clientPolicy.getAppKey()) || clientPolicy.getSigningKey() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
byte[] sign = SignatureUtil.hmacSha1(protocolRequestPath.toString(), parameters, clientPolicy.getSigningKey());
|
||||||
|
|
||||||
|
String signedContent = SignatureUtil.encodeHexStr(sign);
|
||||||
|
parameters.put(PARAM_NAME_SIGNATURE, signedContent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static String buildQuery(Map<String, Object> params) throws IOException {
|
||||||
|
if (params == null || params.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuilder query = new StringBuilder();
|
||||||
|
Set<Entry<String, Object>> entries = params.entrySet();
|
||||||
|
boolean hasParam = false;
|
||||||
|
|
||||||
|
for (Entry<String, Object> entry : entries) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
Object value = entry.getValue();
|
||||||
|
if (value != null) {
|
||||||
|
if (hasParam) {
|
||||||
|
query.append("&");
|
||||||
|
} else {
|
||||||
|
hasParam = true;
|
||||||
|
}
|
||||||
|
query.append(name).append("=").append(URLEncoder.encode(String.valueOf(value), "utf-8"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return query.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static URL buildGetRequestUrl(ClientPolicy clientPolicy, InvokeContext context, Map<String, Object> params)
|
||||||
|
throws IOException {
|
||||||
|
String protocol = "http";
|
||||||
|
String host = clientPolicy.getServerHost();
|
||||||
|
int port = clientPolicy.getHttpPort();
|
||||||
|
if (context.getPolicy().isUseHttps()) {
|
||||||
|
protocol = "https";
|
||||||
|
port = clientPolicy.getHttpsPort();
|
||||||
|
}
|
||||||
|
StringBuilder pathSB = getApiRequestPath(context.getPolicy());
|
||||||
|
StringBuilder proptolRequestPath = getProtocolRequestPath(context, clientPolicy);
|
||||||
|
pathSB.append("/").append(proptolRequestPath.toString());
|
||||||
|
String query = buildQuery(params);
|
||||||
|
if (!GenericsUtil.isBlank(query)) {
|
||||||
|
pathSB.append("?");
|
||||||
|
pathSB.append(query);
|
||||||
|
}
|
||||||
|
return new URL(protocol, host, port, pathSB.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static URL buildPostRequestUrl(ClientPolicy clientPolicy, InvokeContext context, Map<String, Object> params)
|
||||||
|
throws IOException {
|
||||||
|
String protocol = "http";
|
||||||
|
String host = clientPolicy.getServerHost();
|
||||||
|
int port = clientPolicy.getHttpPort();
|
||||||
|
if (context.getPolicy().isUseHttps()) {
|
||||||
|
protocol = "https";
|
||||||
|
port = clientPolicy.getHttpsPort();
|
||||||
|
}
|
||||||
|
StringBuilder pathSB = getApiRequestPath(context.getPolicy());
|
||||||
|
StringBuilder proptolRequestPath = getProtocolRequestPath(context, clientPolicy);
|
||||||
|
pathSB.append("/").append(proptolRequestPath.toString());
|
||||||
|
|
||||||
|
return new URL(protocol, host, port, pathSB.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String parseResponseCharset(RequestPolicy requestPolicy, String ctype) {
|
||||||
|
String charset = requestPolicy.getContentCharset();
|
||||||
|
|
||||||
|
if (!GenericsUtil.isBlank(ctype)) {
|
||||||
|
String[] params = ctype.split(";");
|
||||||
|
for (String param : params) {
|
||||||
|
param = param.trim();
|
||||||
|
if (param.startsWith("charset")) {
|
||||||
|
String[] pair = param.split("=", 2);
|
||||||
|
if (pair.length == 2) {
|
||||||
|
if (!GenericsUtil.isBlank(pair[1])) {
|
||||||
|
charset = pair[1].trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return charset;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Request;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Response;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.ResponseWrapper;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.RequestPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment of InvokeContext
|
||||||
|
*
|
||||||
|
* @author jade
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class InvokeContext {
|
||||||
|
private Request request;
|
||||||
|
private Response response;
|
||||||
|
private RequestPolicy policy;
|
||||||
|
private Class<?> resultType;
|
||||||
|
private ResponseWrapper responseWrapper;
|
||||||
|
|
||||||
|
public InvokeContext() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Request getRequest() {
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequest(Request request) {
|
||||||
|
this.request = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response getResponse() {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setResponse(Response response) {
|
||||||
|
this.response = response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequestPolicy getPolicy() {
|
||||||
|
return policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolicy(RequestPolicy policy) {
|
||||||
|
this.policy = policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> getResultType() {
|
||||||
|
return resultType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultType(Class<?> resultType) {
|
||||||
|
this.resultType = resultType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseWrapper getResponseWrapper() {
|
||||||
|
return responseWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponseWrapper(ResponseWrapper responseWrapper) {
|
||||||
|
this.responseWrapper = responseWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void failed(Throwable exception) {
|
||||||
|
if (response == null) {
|
||||||
|
response = new Response();
|
||||||
|
}
|
||||||
|
response.setException(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http.mapi;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Response;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.HttpResponseBuilder;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.InvokeContext;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.ClientPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.Serializer;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerProvider;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.zip.DeflaterOutputStream;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类MapiHttpClient.java的实现描述:mapi专用的httpClient
|
||||||
|
*
|
||||||
|
* @author yuan.gy
|
||||||
|
*/
|
||||||
|
public class MapiHttpClient {
|
||||||
|
|
||||||
|
private SerializerProvider serializerProvider;
|
||||||
|
private HttpResponseBuilder responseBuilder;
|
||||||
|
|
||||||
|
public MapiHttpClient(SerializerProvider serializerProvider, HttpResponseBuilder responseBuilder) {
|
||||||
|
super();
|
||||||
|
this.serializerProvider = serializerProvider;
|
||||||
|
this.responseBuilder = responseBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response request(InvokeContext invokeContext, ClientPolicy clientPolicy,
|
||||||
|
Collection<SerializerListener> serializerListners, Collection<DeSerializerListener> deSerializerListners)
|
||||||
|
throws IOException {
|
||||||
|
// create the path. The pass is used when signature the request.
|
||||||
|
StringBuilder requestPath = MapiHttpSupport.getProtocolRequestPath(invokeContext, clientPolicy);
|
||||||
|
// generate the http parameters, include the system parameters.
|
||||||
|
Protocol protocol = invokeContext.getPolicy().getRequestProtocol();
|
||||||
|
Serializer serializer = serializerProvider.getSerializer(protocol.name());
|
||||||
|
for (SerializerListener serializerListener : serializerListners) {
|
||||||
|
serializer.registeSerializerListener(serializerListener);
|
||||||
|
}
|
||||||
|
Map<String, Object> parameters = MapiHttpSupport.buildParams(serializer, invokeContext);
|
||||||
|
byte[] paramBytes = getParamBytes(parameters,invokeContext);
|
||||||
|
String timeStamp = String.valueOf(System.currentTimeMillis());
|
||||||
|
String queryString = MapiHttpSupport.getQueryString(timeStamp,invokeContext);
|
||||||
|
// signature the request
|
||||||
|
String signature = MapiHttpSupport.getSignature(requestPath.toString(), queryString, paramBytes, invokeContext, clientPolicy);
|
||||||
|
//mapi 只支持POST
|
||||||
|
URL postURL = MapiHttpSupport.buildFinalRequestUrl(clientPolicy, invokeContext, requestPath.toString(), queryString);
|
||||||
|
Response response = this.doPost(postURL, paramBytes,signature, invokeContext, clientPolicy, deSerializerListners);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Response doPost(URL url, byte[] contentBody, String signature, InvokeContext invokeContext,
|
||||||
|
ClientPolicy clientPolicy, Collection<DeSerializerListener> deSerializerListners) {
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
OutputStream out = null;
|
||||||
|
Response response = null;
|
||||||
|
try {
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setDoInput(true);
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
//设置头部信息
|
||||||
|
Map<String, String> clientHttpHeader = MapiHttpSupport.buildHttpHeader(invokeContext, clientPolicy);
|
||||||
|
for (Map.Entry<String, String> entry : clientHttpHeader.entrySet()) {
|
||||||
|
conn.setRequestProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
//设置签名
|
||||||
|
conn.setRequestProperty("X-Sign-HMAC", signature);
|
||||||
|
|
||||||
|
//查询体body
|
||||||
|
out = conn.getOutputStream();
|
||||||
|
out.write(contentBody);
|
||||||
|
|
||||||
|
int httpCode = conn.getResponseCode();
|
||||||
|
String contentEncoding = conn.getContentEncoding();
|
||||||
|
String contentType = conn.getContentType();
|
||||||
|
InputStream inputStream = null;
|
||||||
|
if (httpCode >= 200 && httpCode <= 299) {
|
||||||
|
inputStream = conn.getInputStream();
|
||||||
|
} else {
|
||||||
|
inputStream = conn.getErrorStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
response = this.getResponseBuilder().buildResponse(inputStream, httpCode, contentEncoding, contentType,
|
||||||
|
invokeContext, deSerializerListners);
|
||||||
|
}catch (Exception e){
|
||||||
|
response.setException(e);
|
||||||
|
}finally {
|
||||||
|
try{
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
//ignore stream close exception
|
||||||
|
}
|
||||||
|
if (conn != null) {
|
||||||
|
conn.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] getParamBytes( Map<String, Object> parameters,InvokeContext invokeContext){
|
||||||
|
String ce = invokeContext.getPolicy().getRequestContentEncoding();
|
||||||
|
//默认返回
|
||||||
|
byte[] body = JSON.toJSONBytes(parameters);
|
||||||
|
if("gzip".equals(ce)){
|
||||||
|
return gzipCompressByte(body);
|
||||||
|
}else if("deflate".equals(ce)){
|
||||||
|
return deflateCompressByte(body);
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
//压缩
|
||||||
|
private byte[] gzipCompressByte(byte[] body){
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
GZIPOutputStream gzip;
|
||||||
|
try {
|
||||||
|
gzip = new GZIPOutputStream(out);
|
||||||
|
gzip.write(body);
|
||||||
|
gzip.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return out.toByteArray();
|
||||||
|
}
|
||||||
|
private byte[] deflateCompressByte(byte[] body){
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
DeflaterOutputStream deflate;
|
||||||
|
try {
|
||||||
|
deflate = new DeflaterOutputStream(out);
|
||||||
|
deflate.write(body);
|
||||||
|
deflate.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return out.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SerializerProvider getSerializerProvider() {
|
||||||
|
return serializerProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpResponseBuilder getResponseBuilder() {
|
||||||
|
return responseBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http.mapi;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Request;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.InvokeContext;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.ClientPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.Serializer;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.util.SignatureUtil;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类MapiHttpSupport.java的实现描述:mapi工具类
|
||||||
|
*
|
||||||
|
* @author yuan.gy on 2020/10/20 3:23 下午
|
||||||
|
*/
|
||||||
|
public class MapiHttpSupport {
|
||||||
|
|
||||||
|
public static final String HTTP_PROTOCOL = "HTTP/1.1";
|
||||||
|
public static final String METHOD_POST = "POST";
|
||||||
|
|
||||||
|
public static final String PARAM_NAME_TIMESTAMP = "_aop_timestamp";
|
||||||
|
public static final String PARAM_NAME_ACCESS_TOKEY = "access_token";
|
||||||
|
|
||||||
|
public static final Charset CHARSET_UTF_8 = Charset.forName("UTF-8");
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param clientPolicy
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static StringBuilder getProtocolRequestPath(InvokeContext context, ClientPolicy clientPolicy) {
|
||||||
|
StringBuilder path = new StringBuilder();
|
||||||
|
path.append("/mapi/");
|
||||||
|
Request request = context.getRequest();
|
||||||
|
if (request.getApiId().getVersion() < 0) {
|
||||||
|
path.append(context.getPolicy().getDefaultApiVersion());
|
||||||
|
} else {
|
||||||
|
path.append(request.getApiId().getVersion());
|
||||||
|
}
|
||||||
|
path.append('/').append(request.getApiId().getNamespace()).append('/').append(request.getApiId().getName());
|
||||||
|
if (clientPolicy.getAppKey() != null) {
|
||||||
|
path.append('/').append(clientPolicy.getAppKey());
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param serializer
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> buildParams(Serializer serializer, InvokeContext context) {
|
||||||
|
Map<String, Object> serializerMap = serializer.serialize(context.getRequest().getRequestEntity());
|
||||||
|
return serializerMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param path
|
||||||
|
* @param queryString
|
||||||
|
* @param context
|
||||||
|
* @param clientPolicy
|
||||||
|
*/
|
||||||
|
public static String getSignature(String path, String queryString, byte[] params,InvokeContext context,ClientPolicy clientPolicy) {
|
||||||
|
String httpRequestStartLine = String.format("%s %s?%s %s", METHOD_POST, path, queryString, HTTP_PROTOCOL);
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
try{
|
||||||
|
//查询url
|
||||||
|
write(httpRequestStartLine, os, "UTF-8");
|
||||||
|
//查询body
|
||||||
|
os.write(params);
|
||||||
|
String accessToken = context.getRequest().getAccessToken();
|
||||||
|
String appSecret = clientPolicy.getSigningKey();
|
||||||
|
String securityKey = getSecurityKey(appSecret,accessToken);
|
||||||
|
|
||||||
|
String expectSignature = SignatureUtil.hmacSha1ToBase64(os.toByteArray(), securityKey);
|
||||||
|
return expectSignature;
|
||||||
|
}catch (Exception e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mapi的url里,queryString暂时只支持时间戳和accessToken
|
||||||
|
*
|
||||||
|
* @param timestamp
|
||||||
|
* @param context
|
||||||
|
*/
|
||||||
|
public static String getQueryString(String timestamp,InvokeContext context){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
//需要时间戳
|
||||||
|
boolean needTimeStamp = context.getPolicy().isRequestSendTimestamp();
|
||||||
|
String accessToken = context.getRequest().getAccessToken();
|
||||||
|
if(needTimeStamp){
|
||||||
|
sb.append(PARAM_NAME_TIMESTAMP+"="+timestamp);
|
||||||
|
if(accessToken!=null){
|
||||||
|
sb.append("&");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(accessToken!=null){
|
||||||
|
sb.append(PARAM_NAME_ACCESS_TOKEY+"="+context.getRequest().getAccessToken());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mapi的头部,只接受固定值
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param clientPolicy
|
||||||
|
*/
|
||||||
|
public final static Map<String, String> buildHttpHeader(InvokeContext context, ClientPolicy clientPolicy) {
|
||||||
|
Map<String, String> header = new LinkedHashMap<String, String>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("User-Agent", clientPolicy.getAgent());
|
||||||
|
header.put("Content-Type","application/json;charset=UTF-8");
|
||||||
|
header.put("Accept-Charset","UTF-8");
|
||||||
|
header.put("X-SequenceId", UUID.randomUUID().toString());
|
||||||
|
if("gzip".equals(context.getPolicy().getRequestContentEncoding())){
|
||||||
|
header.put("Content-Encoding","gzip");
|
||||||
|
}else if("deflate".equals(context.getPolicy().getRequestContentEncoding())){
|
||||||
|
header.put("Content-Encoding","deflate");
|
||||||
|
}
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static URL buildFinalRequestUrl(ClientPolicy clientPolicy, InvokeContext context, String requestPath,String queryString)
|
||||||
|
throws IOException {
|
||||||
|
String protocol = "http";
|
||||||
|
String host = clientPolicy.getServerHost();
|
||||||
|
int port = clientPolicy.getHttpPort();
|
||||||
|
if (context.getPolicy().isUseHttps()) {
|
||||||
|
protocol = "https";
|
||||||
|
port = clientPolicy.getHttpsPort();
|
||||||
|
}
|
||||||
|
StringBuilder pathSB = new StringBuilder(requestPath);
|
||||||
|
if(queryString!=null){
|
||||||
|
pathSB.append("?"+queryString);
|
||||||
|
}
|
||||||
|
return new URL(protocol, host, port, pathSB.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSecurityKey(String appSecret,String accessToken){
|
||||||
|
if(null==accessToken||null==appSecret){
|
||||||
|
return appSecret;
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
byte[] secretBytes = appSecret.getBytes("UTF-8");
|
||||||
|
byte[] data = accessToken.getBytes(CHARSET_UTF_8);
|
||||||
|
return SignatureUtil.hmacSha1ToHexStr(data, secretBytes, 0, data.length);
|
||||||
|
}catch (Exception e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void write(String data, OutputStream output, String encoding) throws IOException {
|
||||||
|
if (data != null) {
|
||||||
|
if (encoding == null) {
|
||||||
|
write(data, output);
|
||||||
|
} else {
|
||||||
|
output.write(data.getBytes(encoding));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void write(String data, OutputStream output) throws IOException {
|
||||||
|
if (data != null) {
|
||||||
|
output.write(data.getBytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] toByteArray(InputStream input) throws IOException {
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
copy((InputStream)input, (OutputStream)output);
|
||||||
|
return output.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int copy(InputStream input, OutputStream output) throws IOException {
|
||||||
|
long count = copyLarge(input, output);
|
||||||
|
return count > 2147483647L ? -1 : (int)count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long copyLarge(InputStream input, OutputStream output) throws IOException {
|
||||||
|
return copyLarge(input, output, new byte[4096]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException {
|
||||||
|
long count = 0L;
|
||||||
|
|
||||||
|
int n;
|
||||||
|
for(boolean var5 = false; -1 != (n = input.read(buffer)); count += (long)n) {
|
||||||
|
output.write(buffer, 0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1999-2004 Alibaba.com All right reserved. This software is the confidential and proprietary information of
|
||||||
|
* Alibaba.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
|
||||||
|
* in accordance with the terms of the license agreement you entered into with Alibaba.com.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http.mapi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类MapiResult.java的实现描述:mapi result model
|
||||||
|
*
|
||||||
|
* @author yuan.gy on 2020/10/21 2:44 下午
|
||||||
|
*/
|
||||||
|
public class MapiResult<T> {
|
||||||
|
|
||||||
|
private String requestId;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
public String getRequestId() {
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestId(String requestId) {
|
||||||
|
this.requestId = requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(T data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http.mapi;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Request;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.AuthorizationToken;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.AuthorizationTokenStore;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.DefaultAuthorizationTokenStore;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.exception.OceanException;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.HttpResponseBuilder;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.InvokeContext;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.platform.DefaultHttpResponseBuilder;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.ClientPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.RequestPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerProvider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类SyncMapiClient.java的实现描述:mapi client
|
||||||
|
*
|
||||||
|
* @author yuan.gy on 2020/10/21 2:50 下午
|
||||||
|
*/
|
||||||
|
public class SyncMapiClient {
|
||||||
|
|
||||||
|
private MapiHttpClient httpClient;
|
||||||
|
private ClientPolicy clientPolicy;
|
||||||
|
private AuthorizationTokenStore authorizationTokenStore;
|
||||||
|
|
||||||
|
public SyncMapiClient(ClientPolicy clientPolicy, SerializerProvider serializerProvider) {
|
||||||
|
this(clientPolicy, serializerProvider, new DefaultAuthorizationTokenStore());
|
||||||
|
}
|
||||||
|
|
||||||
|
public SyncMapiClient(ClientPolicy clientPolicy, SerializerProvider serializerProvider,
|
||||||
|
AuthorizationTokenStore authorizationTokenStore) {
|
||||||
|
super();
|
||||||
|
this.clientPolicy = clientPolicy;
|
||||||
|
this.authorizationTokenStore = authorizationTokenStore;
|
||||||
|
HttpResponseBuilder httpResponseBuilder = new DefaultHttpResponseBuilder(clientPolicy, serializerProvider);
|
||||||
|
httpClient = new MapiHttpClient(serializerProvider, httpResponseBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public <T> T send(Request request, Class<T> resultType, RequestPolicy policy,
|
||||||
|
Collection<SerializerListener> serializerListners, Collection<DeSerializerListener> deSerializerListners)
|
||||||
|
throws OceanException {
|
||||||
|
InvokeContext invokeContext = new InvokeContext();
|
||||||
|
invokeContext.setPolicy(policy);
|
||||||
|
invokeContext.setRequest(request);
|
||||||
|
invokeContext.setResultType(resultType);
|
||||||
|
try {
|
||||||
|
httpClient.request(invokeContext, clientPolicy, serializerListners, deSerializerListners);
|
||||||
|
if (invokeContext.getResponse().getException() != null) {
|
||||||
|
Throwable responseException = invokeContext.getResponse().getException();
|
||||||
|
if (responseException instanceof OceanException) {
|
||||||
|
throw (OceanException) responseException;
|
||||||
|
} else {
|
||||||
|
throw new OceanException(responseException.getMessage(),responseException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (T) invokeContext.getResponse().getResult();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new OceanException("IOException",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> MapiResult<T> mapiSend(Request request, Class<T> resultType, RequestPolicy policy,
|
||||||
|
Collection<SerializerListener> serializerListners, Collection<DeSerializerListener> deSerializerListners)
|
||||||
|
throws OceanException {
|
||||||
|
InvokeContext invokeContext = new InvokeContext();
|
||||||
|
invokeContext.setPolicy(policy);
|
||||||
|
invokeContext.setRequest(request);
|
||||||
|
//设定返回类型是MapiResult
|
||||||
|
invokeContext.setResultType(new MapiResult<T>().getClass());
|
||||||
|
try {
|
||||||
|
httpClient.request(invokeContext, clientPolicy, serializerListners, deSerializerListners);
|
||||||
|
if (invokeContext.getResponse().getException() != null) {
|
||||||
|
Throwable responseException = invokeContext.getResponse().getException();
|
||||||
|
if (responseException instanceof OceanException) {
|
||||||
|
throw (OceanException) responseException;
|
||||||
|
} else {
|
||||||
|
throw new OceanException(responseException.getMessage(),responseException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (MapiResult<T>) invokeContext.getResponse().getResult();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new OceanException("IOException",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void start() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken getToken(String code) throws OceanException {
|
||||||
|
|
||||||
|
Request request = new Request("system.oauth2", "getToken");
|
||||||
|
request.addAddtionalParams("code", code);
|
||||||
|
request.addAddtionalParams("grant_type", "authorization_code");
|
||||||
|
request.addAddtionalParams("need_refresh_token", true);
|
||||||
|
request.addAddtionalParams("client_id", clientPolicy.getAppKey());
|
||||||
|
request.addAddtionalParams("client_secret", clientPolicy.getSigningKey());
|
||||||
|
request.addAddtionalParams("redirect_uri", "default");
|
||||||
|
RequestPolicy oauthPolicy = RequestPolicy.getAuthPolicy();
|
||||||
|
|
||||||
|
return this.send(request, AuthorizationToken.class, oauthPolicy, new ArrayList<SerializerListener>(),
|
||||||
|
new ArrayList<DeSerializerListener>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorizationToken refreshToken(String refreshToken) throws OceanException {
|
||||||
|
Request request = new Request("system.oauth2", "getToken");
|
||||||
|
request.addAddtionalParams("refreshToken", refreshToken);
|
||||||
|
request.addAddtionalParams("grant_type", "refresh_token");
|
||||||
|
request.addAddtionalParams("client_id", clientPolicy.getAppKey());
|
||||||
|
request.addAddtionalParams("client_secret", clientPolicy.getSigningKey());
|
||||||
|
RequestPolicy oauthPolicy = RequestPolicy.getAuthPolicy();
|
||||||
|
return this.send(request, AuthorizationToken.class, oauthPolicy, new ArrayList<SerializerListener>(),
|
||||||
|
new ArrayList<DeSerializerListener>());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http.platform;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Response;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.ResponseWrapper;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.HttpResponseBuilder;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.HttpSupport;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.InvokeContext;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.ClientPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializer;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerProvider;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.util.LoggerHelper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DefaultHttpResponseBuilder implements HttpResponseBuilder {
|
||||||
|
private static final String HEADER_NAME_CONTENT_ENCODING = "Content-Encoding";
|
||||||
|
protected static final String CONTENT_ENCODING_GZIP = "gzip";
|
||||||
|
private static final String HEADER_NAME_CONTENT_TYPE = "Content-Type";
|
||||||
|
private static final String HEADER_FLAG_CONTENT_TYPE_CHARSET = ";charset=";
|
||||||
|
private static final int HEADER_FLAG_LENGTH_CONTENT_TYPE_CHARSET = HEADER_FLAG_CONTENT_TYPE_CHARSET.length();
|
||||||
|
protected ClientPolicy clientPolicy;
|
||||||
|
private SerializerProvider serializerProvider;
|
||||||
|
|
||||||
|
public DefaultHttpResponseBuilder(ClientPolicy clientPolicy, SerializerProvider serializerProvider) {
|
||||||
|
super();
|
||||||
|
this.clientPolicy = clientPolicy;
|
||||||
|
this.serializerProvider = serializerProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <T> T parseBody(InputStream istream, Class<T> resultType, InvokeContext invokeContext,
|
||||||
|
Collection<DeSerializerListener> deSerializerListners) throws IOException, ParseException {
|
||||||
|
Protocol protocol = invokeContext.getPolicy().getResponseProtocol();
|
||||||
|
if (protocol == null) {
|
||||||
|
protocol = invokeContext.getPolicy().getRequestProtocol();
|
||||||
|
}
|
||||||
|
DeSerializer deSerializer = serializerProvider.getDeSerializer(protocol.name());
|
||||||
|
for (DeSerializerListener srializerListener : deSerializerListners) {
|
||||||
|
deSerializer.registeDeSerializerListener(srializerListener);
|
||||||
|
}
|
||||||
|
ResponseWrapper<T> responseWrapper = deSerializer.deSerialize(istream, resultType, invokeContext.getResponse()
|
||||||
|
.getCharset());
|
||||||
|
invokeContext.setResponseWrapper(responseWrapper);
|
||||||
|
return responseWrapper.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected Throwable buildException(InputStream istream, int statusCode, InvokeContext invokeContext,
|
||||||
|
Collection<DeSerializerListener> deSerializerListners) throws IOException, ParseException {
|
||||||
|
Protocol protocol = invokeContext.getPolicy().getResponseProtocol();
|
||||||
|
if (protocol == null) {
|
||||||
|
protocol = invokeContext.getPolicy().getRequestProtocol();
|
||||||
|
}
|
||||||
|
DeSerializer deSerializer = serializerProvider.getDeSerializer(protocol.name());
|
||||||
|
if (deSerializer == null) {
|
||||||
|
throw new RuntimeException("The Protocol[" + protocol.name()
|
||||||
|
+ "] is not supported when parse the response.");
|
||||||
|
}
|
||||||
|
for (DeSerializerListener srializerListener : deSerializerListners) {
|
||||||
|
deSerializer.registeDeSerializerListener(srializerListener);
|
||||||
|
}
|
||||||
|
Throwable rhrowable = deSerializer
|
||||||
|
.buildException(istream, statusCode, invokeContext.getResponse().getCharset());
|
||||||
|
return rhrowable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response buildResponse(InputStream istream, int httpCode, String contentEncoding, String contentType,
|
||||||
|
InvokeContext invokeContext, Collection<DeSerializerListener> deSerializerListners) {
|
||||||
|
LoggerHelper.getClientLogger().finer("--Start init Response--");
|
||||||
|
final Response response = new Response();
|
||||||
|
invokeContext.setResponse(response);
|
||||||
|
response.setStatusCode(httpCode);
|
||||||
|
if (contentEncoding != null) {
|
||||||
|
response.setEncoding(contentEncoding);
|
||||||
|
}
|
||||||
|
if (contentType == null) {
|
||||||
|
response.setException(new IllegalStateException("response need content type"));
|
||||||
|
} else {
|
||||||
|
String charset = HttpSupport.parseResponseCharset(invokeContext.getPolicy(), contentType);
|
||||||
|
response.setCharset(charset);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (CONTENT_ENCODING_GZIP.equalsIgnoreCase(response.getEncoding())) {
|
||||||
|
LoggerHelper.getClientLogger().finer(" translate InputStream to GZIPInputStream ");
|
||||||
|
istream = new GZIPInputStream(istream);
|
||||||
|
}
|
||||||
|
LoggerHelper.getClientLogger().finer("Response status code :" + response.getStatusCode());
|
||||||
|
if (response.getStatusCode() >= 200 && response.getStatusCode() <= 399) {
|
||||||
|
Object result = parseBody(istream, invokeContext.getResultType(), invokeContext, deSerializerListners);
|
||||||
|
response.setResult(result);
|
||||||
|
} else {
|
||||||
|
Throwable exception = buildException(istream, response.getStatusCode(), invokeContext,
|
||||||
|
deSerializerListners);
|
||||||
|
response.setException(exception);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
response.setException(e);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
response.setException(e);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
response.setException(e);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientPolicy getClientPolicy() {
|
||||||
|
return clientPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.http.platform;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.Response;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.AbstractHttpClient;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.HttpResponseBuilder;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.HttpSupport;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.http.InvokeContext;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.ClientPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.SerializerProvider;
|
||||||
|
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HttpURLConnectionClient extends AbstractHttpClient {
|
||||||
|
|
||||||
|
public HttpURLConnectionClient(SerializerProvider serializerProvider, HttpResponseBuilder responseBuilder) {
|
||||||
|
super(serializerProvider, responseBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Response doMultipartPost(URL url, Map<String, Object> parameters, InvokeContext invokeContext,
|
||||||
|
ClientPolicy clientPolicy, Collection<DeSerializerListener> deSerializerListners) throws IOException {
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
Response response = null;
|
||||||
|
String BOUNDARY = "---------------------------123821742118716";
|
||||||
|
OutputStream out = null;
|
||||||
|
try {
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setDoInput(true);
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
Map<String, String> clientHttpHeader = HttpSupport.buildHttpHeader(invokeContext, clientPolicy);
|
||||||
|
for (Map.Entry<String, String> entry : clientHttpHeader.entrySet()) {
|
||||||
|
conn.setRequestProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
|
||||||
|
|
||||||
|
out = new DataOutputStream(conn.getOutputStream());
|
||||||
|
|
||||||
|
StringBuffer strBuf = new StringBuffer();
|
||||||
|
Iterator<Map.Entry<String, Object>> iter = parameters.entrySet().iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Map.Entry<String, Object> entry = iter.next();
|
||||||
|
String inputName = (String) entry.getKey();
|
||||||
|
Object inputValue = entry.getValue();
|
||||||
|
if (inputValue == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (inputValue.getClass().isAssignableFrom(byte[].class)
|
||||||
|
|| inputValue.getClass().isAssignableFrom(Byte[].class)) {
|
||||||
|
strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n");
|
||||||
|
strBuf.append("Content-Disposition: form-data; name=\"" + inputName + "\"" + "\"\r\n");
|
||||||
|
strBuf.append("Content-Type:" + "application/x-www-form-urlencoded" + "\r\n\r\n");
|
||||||
|
out.write(strBuf.toString().getBytes());
|
||||||
|
if (inputValue instanceof byte[]) {
|
||||||
|
byte[] inputBytes = (byte[]) inputValue;
|
||||||
|
out.write(inputBytes);
|
||||||
|
}
|
||||||
|
if (inputValue instanceof Byte[]) {
|
||||||
|
Byte[] inputBytes = (Byte[]) inputValue;
|
||||||
|
for (Byte b : inputBytes) {
|
||||||
|
out.write(b.byteValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n");
|
||||||
|
strBuf.append("Content-Disposition: form-data; name=\"" + inputName + "\"\r\n\r\n");
|
||||||
|
strBuf.append(inputValue);
|
||||||
|
out.write(strBuf.toString().getBytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int httpCode = conn.getResponseCode();
|
||||||
|
String contentEncoding = conn.getContentEncoding();
|
||||||
|
String contentType = conn.getContentType();
|
||||||
|
String requestId=conn.getHeaderField("RequestId");
|
||||||
|
String traceId=conn.getHeaderField("EagleEye-TraceId");
|
||||||
|
InputStream inputStream = null;
|
||||||
|
if (httpCode >= 200 && httpCode <= 299) {
|
||||||
|
inputStream = conn.getInputStream();
|
||||||
|
} else {
|
||||||
|
inputStream = conn.getErrorStream();
|
||||||
|
}
|
||||||
|
response = this.getResponseBuilder().buildResponse(inputStream, httpCode, contentEncoding, contentType,
|
||||||
|
invokeContext, deSerializerListners);
|
||||||
|
response.setRequestId(requestId);
|
||||||
|
response.setTraceId(traceId);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
if (conn != null) {
|
||||||
|
conn.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Response doPost(URL url, Map<String, Object> parameters, InvokeContext invokeContext,
|
||||||
|
ClientPolicy clientPolicy, Collection<DeSerializerListener> deSerializerListners) throws IOException {
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
OutputStream out = null;
|
||||||
|
Response response = null;
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
Proxy proxy = clientPolicy.getProxy();
|
||||||
|
if (proxy != null) {
|
||||||
|
conn = (HttpURLConnection) url.openConnection(proxy);
|
||||||
|
} else {
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
}
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setDoInput(true);
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
Map<String, String> clientHttpHeader = HttpSupport.buildHttpHeader(invokeContext, clientPolicy);
|
||||||
|
for (Map.Entry<String, String> entry : clientHttpHeader.entrySet()) {
|
||||||
|
conn.setRequestProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String query = HttpSupport.buildQuery(parameters);
|
||||||
|
byte[] content = {};
|
||||||
|
if (query != null) {
|
||||||
|
content = query.getBytes(invokeContext.getPolicy().getContentCharset());
|
||||||
|
}
|
||||||
|
out = conn.getOutputStream();
|
||||||
|
out.write(content);
|
||||||
|
|
||||||
|
int httpCode = conn.getResponseCode();
|
||||||
|
String contentEncoding = conn.getContentEncoding();
|
||||||
|
String contentType = conn.getContentType();
|
||||||
|
String requestId=conn.getHeaderField("RequestId");
|
||||||
|
String traceId=conn.getHeaderField("EagleEye-TraceId");
|
||||||
|
InputStream inputStream = null;
|
||||||
|
if (httpCode >= 200 && httpCode <= 299) {
|
||||||
|
inputStream = conn.getInputStream();
|
||||||
|
} else {
|
||||||
|
inputStream = conn.getErrorStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
response = this.getResponseBuilder().buildResponse(inputStream, httpCode, contentEncoding, contentType,
|
||||||
|
invokeContext, deSerializerListners);
|
||||||
|
response.setRequestId(requestId);
|
||||||
|
response.setTraceId(traceId);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
if (conn != null) {
|
||||||
|
conn.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Response doGet(URL url, Map<String, Object> parameters,InvokeContext invokeContext,
|
||||||
|
ClientPolicy clientPolicy, Collection<DeSerializerListener> deSerializerListners) throws IOException {
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
OutputStream out = null;
|
||||||
|
Response response = null;
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
Proxy proxy = clientPolicy.getProxy();
|
||||||
|
if (proxy != null) {
|
||||||
|
conn = (HttpURLConnection) url.openConnection(proxy);
|
||||||
|
} else {
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
}
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setDoInput(true);
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
Map<String, String> clientHttpHeader = HttpSupport.buildHttpHeader(invokeContext, clientPolicy);
|
||||||
|
for (Map.Entry<String, String> entry : clientHttpHeader.entrySet()) {
|
||||||
|
conn.setRequestProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
int httpCode = conn.getResponseCode();
|
||||||
|
String contentEncoding = conn.getContentEncoding();
|
||||||
|
String contentType = conn.getContentType();
|
||||||
|
String requestId=conn.getHeaderField("RequestId");
|
||||||
|
String traceId=conn.getHeaderField("EagleEye-TraceId");
|
||||||
|
InputStream inputStream = null;
|
||||||
|
if (httpCode >= 200 && httpCode <= 299) {
|
||||||
|
inputStream = conn.getInputStream();
|
||||||
|
} else {
|
||||||
|
inputStream = conn.getErrorStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
response = this.getResponseBuilder().buildResponse(inputStream, httpCode, contentEncoding, contentType,
|
||||||
|
invokeContext, deSerializerListners);
|
||||||
|
response.setRequestId(requestId);
|
||||||
|
response.setTraceId(traceId);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
if (conn != null) {
|
||||||
|
conn.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HttpRequestSerializer extends AbstractParamRequestSerializer {
|
||||||
|
|
||||||
|
public String supportedContentType() {
|
||||||
|
return Protocol.http.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String processNestedParameter(Object value) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"The param protocol does not support Nested parameters.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.parser.ParserConfig;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.ResponseWrapper;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.util.ExceptionParser;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Json2Deserializer extends AbstractJsonDeserializer {
|
||||||
|
|
||||||
|
private Map<Class<? extends DeSerializerListener>, DeSerializerListener> listnerList = new LinkedHashMap<Class<? extends DeSerializerListener>, DeSerializerListener>();
|
||||||
|
|
||||||
|
public String supportedContentType() {
|
||||||
|
return Protocol.json2.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> ResponseWrapper<T> deSerialize(String content, Class<T> resultType) {
|
||||||
|
for (DeSerializerListener deSerializerListener : listnerList.values()) {
|
||||||
|
deSerializerListener.onResponseDeSerialized(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
//更换日期转换为开放平台的日期类型反序列化类
|
||||||
|
ParserConfig config=ParserConfig.getGlobalInstance();
|
||||||
|
config.putDeserializer(java.util.Date.class, OpenPlatformDateCodec.instance);
|
||||||
|
T result = JSON.parseObject(content,resultType,config,null,JSON.DEFAULT_PARSER_FEATURE);
|
||||||
|
|
||||||
|
//JSONObject json = JSON.parseObject(content);
|
||||||
|
//T result = this.parseResult(json, resultType);
|
||||||
|
ResponseWrapper<T> responseWrapper = new ResponseWrapper<T>();
|
||||||
|
responseWrapper.setResult(result);
|
||||||
|
return responseWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Throwable buildException(String content, int statusCode) {
|
||||||
|
for (DeSerializerListener deSerializerListener : listnerList.values()) {
|
||||||
|
deSerializerListener.onResponseExceptioned(content);
|
||||||
|
}
|
||||||
|
Map result = JSON.parseObject(content, Map.class);
|
||||||
|
return ExceptionParser.buildException4Json2(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registeDeSerializerListener(DeSerializerListener listner) {
|
||||||
|
if (!listnerList.containsKey(listner.getClass())) {
|
||||||
|
listnerList.put(listner.getClass(), listner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.ParserConfig;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.ResponseStatus;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.ResponseWrapper;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.util.ExceptionParser;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class JsonDeserializer extends AbstractJsonDeserializer {
|
||||||
|
|
||||||
|
public String supportedContentType() {
|
||||||
|
return Protocol.json.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> ResponseWrapper<T> deSerialize(String content, Class<T> resultType) {
|
||||||
|
ResponseWrapper<T> responseWrapper = new ResponseWrapper<T>();
|
||||||
|
JSONObject rootJson = JSON.parseObject(content);
|
||||||
|
|
||||||
|
responseWrapper.setInvokeStartTime(rootJson.getString("InvokeStartTime"));
|
||||||
|
responseWrapper.setInvokeCostTime(rootJson.getLongValue("InvokeCostTime"));
|
||||||
|
JSONObject statusJson = rootJson.getJSONObject("Status");
|
||||||
|
ResponseStatus responseStatus = this.parseResult(statusJson, ResponseStatus.class);
|
||||||
|
responseWrapper.setStatus(responseStatus);
|
||||||
|
|
||||||
|
JSONArray jsonResponseArray = rootJson.getJSONArray("Responses");
|
||||||
|
JSONObject jsonResponseObject = jsonResponseArray.getJSONObject(0);
|
||||||
|
|
||||||
|
ParserConfig config=ParserConfig.getGlobalInstance();
|
||||||
|
////更换日期转换为开放平台的日期类型反序列化类
|
||||||
|
config.putDeserializer(java.util.Date.class, OpenPlatformDateCodec.instance);
|
||||||
|
T result = JSON.parseObject(jsonResponseObject.toJSONString(),resultType,config,null,JSON.DEFAULT_PARSER_FEATURE);
|
||||||
|
//T result = this.parseResult(jsonResponseObject, resultType);
|
||||||
|
responseWrapper.setResult(result);
|
||||||
|
|
||||||
|
return responseWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Throwable buildException(String content, int statusCode) {
|
||||||
|
Map result = JSON.parseObject(content, Map.class);
|
||||||
|
return ExceptionParser.buildException4Json2(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registeDeSerializerListener(DeSerializerListener listner) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONException;
|
||||||
|
import com.alibaba.fastjson.parser.DefaultJSONParser;
|
||||||
|
import com.alibaba.fastjson.parser.JSONScanner;
|
||||||
|
import com.alibaba.fastjson.serializer.DateCodec;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.util.DateUtil;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xingming.zhaoxm
|
||||||
|
* @date 2018/10/26
|
||||||
|
*/
|
||||||
|
public class OpenPlatformDateCodec extends DateCodec {
|
||||||
|
|
||||||
|
public static final OpenPlatformDateCodec instance = new OpenPlatformDateCodec();
|
||||||
|
|
||||||
|
public OpenPlatformDateCodec() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T cast(DefaultJSONParser parser, Type clazz, Object fieldName, Object val) {
|
||||||
|
if (val == null) {
|
||||||
|
return null;
|
||||||
|
} else if (val instanceof Date) {
|
||||||
|
return (T)val;
|
||||||
|
} else if (val instanceof Number) {
|
||||||
|
return (T)new Date(((Number)val).longValue());
|
||||||
|
} else if (!(val instanceof String)) {
|
||||||
|
throw new JSONException("parse error");
|
||||||
|
} else {
|
||||||
|
String strVal = (String)val;
|
||||||
|
if (strVal.length() == 0) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
JSONScanner dateLexer = new JSONScanner(strVal);
|
||||||
|
|
||||||
|
label346: {
|
||||||
|
Date var8;
|
||||||
|
try {
|
||||||
|
if (!dateLexer.scanISO8601DateIfMatch(false)) {
|
||||||
|
break label346;
|
||||||
|
}
|
||||||
|
|
||||||
|
Calendar calendar = dateLexer.getCalendar();
|
||||||
|
if (clazz == Calendar.class) {
|
||||||
|
Calendar var28 = calendar;
|
||||||
|
return (T)var28;
|
||||||
|
}
|
||||||
|
|
||||||
|
var8 = calendar.getTime();
|
||||||
|
} finally {
|
||||||
|
dateLexer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T)var8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strVal.length() == parser.getDateFomartPattern().length() || strVal.length() == 22 && parser.getDateFomartPattern().equals("yyyyMMddHHmmssSSSZ")) {
|
||||||
|
DateFormat dateFormat = parser.getDateFormat();
|
||||||
|
|
||||||
|
try {
|
||||||
|
return (T)dateFormat.parse(strVal);
|
||||||
|
} catch (ParseException var21) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strVal.startsWith("/Date(") && strVal.endsWith(")/")) {
|
||||||
|
String dotnetDateStr = strVal.substring(6, strVal.length() - 2);
|
||||||
|
strVal = dotnetDateStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!"0000-00-00".equals(strVal) && !"0000-00-00T00:00:00".equalsIgnoreCase(strVal) && !"0001-01-01T00:00:00+08:00".equalsIgnoreCase(strVal)) {
|
||||||
|
int index = strVal.lastIndexOf(124);
|
||||||
|
if (index > 20) {
|
||||||
|
String tzStr = strVal.substring(index + 1);
|
||||||
|
TimeZone timeZone = TimeZone.getTimeZone(tzStr);
|
||||||
|
if (!"GMT".equals(timeZone.getID())) {
|
||||||
|
String subStr = strVal.substring(0, index);
|
||||||
|
dateLexer = new JSONScanner(subStr);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (dateLexer.scanISO8601DateIfMatch(false)) {
|
||||||
|
Calendar calendar = dateLexer.getCalendar();
|
||||||
|
calendar.setTimeZone(timeZone);
|
||||||
|
if (clazz == Calendar.class) {
|
||||||
|
Calendar var30 = calendar;
|
||||||
|
return (T)var30;
|
||||||
|
}
|
||||||
|
|
||||||
|
Date var12 = calendar.getTime();
|
||||||
|
return (T)var12;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
dateLexer.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//---support openplatform Date format:20190424145905000+0800
|
||||||
|
if(22==strVal.length() && (strVal.lastIndexOf("-")>0||strVal.lastIndexOf("+")>0)){
|
||||||
|
//index = strVal.lastIndexOf("-");
|
||||||
|
//if(index<0) {
|
||||||
|
// index=strVal.lastIndexOf("+");
|
||||||
|
//}
|
||||||
|
//String tzStr = strVal.substring(index);
|
||||||
|
//String tmStr = strVal.substring(0,index);
|
||||||
|
//TimeZone timeZone = TimeZone.getTimeZone("GMT"+tzStr);
|
||||||
|
//SimpleDateFormat format=new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||||
|
//format.setTimeZone(timeZone);
|
||||||
|
try {
|
||||||
|
Date d= DateUtil.parse(strVal);
|
||||||
|
return (T)d;
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new JSONException("parse error",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long longVal = Long.parseLong(strVal);
|
||||||
|
return (T)new Date(longVal);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Param2Deserializer extends Json2Deserializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String supportedContentType() {
|
||||||
|
return Protocol.param2.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Param2RequestSerializer extends AbstractParamRequestSerializer {
|
||||||
|
|
||||||
|
|
||||||
|
public String supportedContentType() {
|
||||||
|
return Protocol.param2.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String processNestedParameter(Object value) {
|
||||||
|
|
||||||
|
return JSON.toJSONString(value);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ParamDeserializer extends JsonDeserializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String supportedContentType() {
|
||||||
|
return Protocol.param.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ParamRequestSerializer extends AbstractParamRequestSerializer {
|
||||||
|
|
||||||
|
public String supportedContentType() {
|
||||||
|
return Protocol.param.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String processNestedParameter(Object value) {
|
||||||
|
throw new RuntimeException("The param protocol does not support Nested parameters.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.imp.serialize;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.ResponseWrapper;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.Protocol;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializer;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.serialize.DeSerializerListener;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.util.LoggerHelper;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Xml2Deserializer implements DeSerializer {
|
||||||
|
|
||||||
|
public String supportedContentType() {
|
||||||
|
return Protocol.xml2.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> ResponseWrapper<T> deSerialize(InputStream istream, Class<T> resultType, String charSet)
|
||||||
|
throws IOException, ParseException {
|
||||||
|
LoggerHelper.getClientLogger().finer("Parse body by xml2.");
|
||||||
|
try {
|
||||||
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||||
|
Document document = documentBuilder.parse(istream);
|
||||||
|
NodeList nodeList = document.getChildNodes();
|
||||||
|
Node root = nodeList.item(0);
|
||||||
|
|
||||||
|
if (Map.class.isAssignableFrom(resultType)) {
|
||||||
|
Map result = new LinkedHashMap();
|
||||||
|
deserializeMap(root, result);
|
||||||
|
ResponseWrapper<T> responseWrapper = new ResponseWrapper<T>();
|
||||||
|
responseWrapper.setResult((T) result);
|
||||||
|
return responseWrapper;
|
||||||
|
} else if (List.class.isAssignableFrom(resultType)) {
|
||||||
|
List result = new ArrayList();
|
||||||
|
deserializeList(root, result);
|
||||||
|
ResponseWrapper<T> responseWrapper = new ResponseWrapper<T>();
|
||||||
|
responseWrapper.setResult((T) result);
|
||||||
|
return responseWrapper;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(supportedContentType() + " only supported Map and List as result type.");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new RuntimeException("Exception occured when parse response.", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deserializeList(Node propertyNode, List result) throws IOException, ParseException {
|
||||||
|
NodeList childrenNodeList = propertyNode.getChildNodes();
|
||||||
|
for (int i = 0; i < childrenNodeList.getLength(); i++) {
|
||||||
|
Node child = childrenNodeList.item(i);
|
||||||
|
Object object = deserialize(propertyNode);
|
||||||
|
result.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deserializeMap(Node propertyNode, Map result) throws IOException, ParseException {
|
||||||
|
NodeList childrenNodeList = propertyNode.getChildNodes();
|
||||||
|
for (int i = 0; i < childrenNodeList.getLength(); i++) {
|
||||||
|
Node child = childrenNodeList.item(i);
|
||||||
|
Object object = deserialize(propertyNode);
|
||||||
|
Object extObject = result.get(child.getLocalName());
|
||||||
|
if (extObject != null) {
|
||||||
|
if (extObject instanceof List) {
|
||||||
|
List extOjbectList = (List) extObject;
|
||||||
|
extOjbectList.add(object);
|
||||||
|
} else {
|
||||||
|
List extOjbectList = new ArrayList();
|
||||||
|
extOjbectList.add(extObject);
|
||||||
|
extOjbectList.add(object);
|
||||||
|
result.put(child.getLocalName(), extOjbectList);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.put(child.getLocalName(), object);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object deserialize(Node propertyNode) throws IOException, ParseException {
|
||||||
|
if (propertyNode.hasChildNodes()) {
|
||||||
|
Node child = propertyNode.getFirstChild();
|
||||||
|
if (isOceanXMLRootArray(child)) {
|
||||||
|
List result = new ArrayList();
|
||||||
|
deserializeList(propertyNode, result);
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
Map result = new LinkedHashMap();
|
||||||
|
deserializeMap(propertyNode, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String nodeValue = propertyNode.getNodeValue();
|
||||||
|
return nodeValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isOceanXMLRootArray(Node node) {
|
||||||
|
return "list".equals(node.getLocalName()) || "item".equals(node.getLocalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Throwable buildException(InputStream inputStream, int statusCode, String charSet) throws IOException,
|
||||||
|
ParseException {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registeDeSerializerListener(DeSerializerListener listner) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.policy;
|
||||||
|
|
||||||
|
import java.net.Proxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端级访问策略
|
||||||
|
* <p>
|
||||||
|
* 定义域名、端口、appKey、秘钥等客户端级信息
|
||||||
|
* <p>
|
||||||
|
* 参考<code>RequestPolicy</code>
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @author jade
|
||||||
|
*/
|
||||||
|
public class ClientPolicy implements Cloneable {
|
||||||
|
|
||||||
|
private static Integer DEFAULT_HTTP_PORT = 80;
|
||||||
|
private static Integer DEFAULT_HTTPS_PORT = 443;
|
||||||
|
|
||||||
|
private static final ClientPolicy CBU_POLICY = new ClientPolicy("gw.open.1688.com");
|
||||||
|
|
||||||
|
private String serverHost;
|
||||||
|
private int httpPort = DEFAULT_HTTP_PORT;
|
||||||
|
private int httpsPort = DEFAULT_HTTPS_PORT;
|
||||||
|
private String appKey;
|
||||||
|
private String signingKey;
|
||||||
|
private int defaultTimeout = 5000;
|
||||||
|
private String defaultContentCharset = "UTF-8";
|
||||||
|
private boolean defaultUseHttps = false;
|
||||||
|
private String agent = "Ocean-SDK-Client";
|
||||||
|
|
||||||
|
private Proxy proxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成默认的ClientPolicy实例,包括默认的http(80),https(443)端口,默认的域名gw.open.1688.com,
|
||||||
|
* 以及默认的api版本为1
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ClientPolicy getDefaultChinaAlibabaPolicy() {
|
||||||
|
return CBU_POLICY.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拷贝生成新的对象
|
||||||
|
*/
|
||||||
|
public ClientPolicy clone() {
|
||||||
|
ClientPolicy newObj = newPolicy();
|
||||||
|
newObj.httpPort = httpPort;
|
||||||
|
newObj.httpsPort = httpsPort;
|
||||||
|
newObj.defaultTimeout = defaultTimeout;
|
||||||
|
newObj.defaultContentCharset = defaultContentCharset;
|
||||||
|
newObj.defaultUseHttps = defaultUseHttps;
|
||||||
|
|
||||||
|
newObj.appKey = appKey;
|
||||||
|
newObj.signingKey = signingKey;
|
||||||
|
newObj.agent = agent;
|
||||||
|
return newObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ClientPolicy newPolicy() {
|
||||||
|
return new ClientPolicy(serverHost);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定开放平台服务地址来生成ClientPolicy
|
||||||
|
*
|
||||||
|
* @param serverHost
|
||||||
|
* 开放平台服务ip地址或者域名
|
||||||
|
*/
|
||||||
|
public ClientPolicy(String serverHost) {
|
||||||
|
if (serverHost == null || serverHost.length() < 1) {
|
||||||
|
throw new IllegalArgumentException("serverHost can not be empty");
|
||||||
|
}
|
||||||
|
this.serverHost = serverHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取http端口
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getHttpPort() {
|
||||||
|
return httpPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取https端口
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getHttpsPort() {
|
||||||
|
return httpsPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取开放平台服务ip地址或者域名
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getServerHost() {
|
||||||
|
return serverHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置http端口
|
||||||
|
*
|
||||||
|
* @param httpPort
|
||||||
|
* 端口
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public ClientPolicy setHttpPort(Integer httpPort) {
|
||||||
|
this.httpPort = httpPort;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置https端口
|
||||||
|
*
|
||||||
|
* @param httpsPort
|
||||||
|
* 端口
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public ClientPolicy setHttpsPort(Integer httpsPort) {
|
||||||
|
this.httpsPort = httpsPort;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppKey() {
|
||||||
|
return appKey;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置app key
|
||||||
|
*
|
||||||
|
* @param appKey
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public ClientPolicy setAppKey(String appKey) {
|
||||||
|
this.appKey = appKey;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSigningKey() {
|
||||||
|
return signingKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置秘钥
|
||||||
|
*
|
||||||
|
* @param signingKey
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public ClientPolicy setSigningKey(String signingKey) {
|
||||||
|
this.signingKey = signingKey;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultTimeout() {
|
||||||
|
return defaultTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientPolicy setDefaultTimeout(int defaultTimeout) {
|
||||||
|
this.defaultTimeout = defaultTimeout;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultContentCharset() {
|
||||||
|
return defaultContentCharset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientPolicy setDefaultContentCharset(String defaultContentCharset) {
|
||||||
|
this.defaultContentCharset = defaultContentCharset;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDefaultUseHttps() {
|
||||||
|
return defaultUseHttps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientPolicy setDefaultUseHttps(boolean defaultUseHttps) {
|
||||||
|
this.defaultUseHttps = defaultUseHttps;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAgent() {
|
||||||
|
return agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Proxy getProxy() {
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientPolicy setProxy(Proxy proxy) {
|
||||||
|
this.proxy = proxy;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.policy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数传递的格式协议
|
||||||
|
* @author jade
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum Protocol {
|
||||||
|
/**
|
||||||
|
* 默认推荐的协议格式,同http请求的get/post请求格式
|
||||||
|
*/
|
||||||
|
param2,
|
||||||
|
/**
|
||||||
|
* 请求参数通过json串的方式传递,默认格式_data_={"key":"value"}
|
||||||
|
*/
|
||||||
|
json2,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 请求参数通过xml的方式传递,默认格式_data_=<test>data</test>
|
||||||
|
*/
|
||||||
|
xml2,
|
||||||
|
param,
|
||||||
|
json,
|
||||||
|
xml,
|
||||||
|
http
|
||||||
|
}
|
||||||
@@ -0,0 +1,332 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.policy;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.ErrorHandler;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.util.DateUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求级访问策略
|
||||||
|
* <p>
|
||||||
|
* 定义是否使用签名、是否使用https、是否加入授权信息、超时设置、http方法设置等请求级别信息
|
||||||
|
* <p>
|
||||||
|
* 参考<code>ClientPolicy</code>
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @author jade
|
||||||
|
* @author xiaoning.qxn
|
||||||
|
*/
|
||||||
|
public class RequestPolicy implements Cloneable {
|
||||||
|
|
||||||
|
private boolean requestSendTimestamp = false;
|
||||||
|
private boolean useHttps = false;
|
||||||
|
private Protocol requestProtocol = Protocol.param2;
|
||||||
|
private Protocol responseProtocol = Protocol.json2;
|
||||||
|
private boolean responseCompress = true;
|
||||||
|
private int requestCompressThreshold = -1; // 默认不开启
|
||||||
|
//请求头header里的content-encoding,设置是否压缩,填gzip,deflate,或不填(不填表示不压缩,该字段只在mapi里生效
|
||||||
|
private String requestContentEncoding;
|
||||||
|
|
||||||
|
private int timeout = 5000; // 5秒
|
||||||
|
private HttpMethodPolicy httpMethod = HttpMethodPolicy.POST;
|
||||||
|
private String queryStringCharset = "GB18030"; // Request URL query string
|
||||||
|
// encoder
|
||||||
|
private String contentCharset = "UTF-8"; // Request body encoder
|
||||||
|
private boolean useSignture = true;
|
||||||
|
private boolean needAuthorization = false;
|
||||||
|
private boolean accessPrivateApi = false;
|
||||||
|
private int defaultApiVersion = 1;
|
||||||
|
private ErrorHandler errorHandler;
|
||||||
|
private String dateFormat = DateUtil.SIMPLE_DATE_FORMAT_STR;
|
||||||
|
|
||||||
|
public static RequestPolicy authPolicy = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局的授权请求的request policy,用户可能需要设置超时时间,其他不用变
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static RequestPolicy getAuthPolicy() {
|
||||||
|
if (authPolicy == null) {
|
||||||
|
authPolicy = new RequestPolicy().setHttpMethod(HttpMethodPolicy.POST).setRequestProtocol(Protocol.param2).setUseHttps(true)
|
||||||
|
.setNeedAuthorization(false);
|
||||||
|
}
|
||||||
|
return authPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequestPolicy clone() {
|
||||||
|
RequestPolicy newObj = newPolicy();
|
||||||
|
newObj.requestSendTimestamp = requestSendTimestamp;
|
||||||
|
newObj.useHttps = useHttps;
|
||||||
|
newObj.requestProtocol = requestProtocol;
|
||||||
|
newObj.responseProtocol = responseProtocol;
|
||||||
|
newObj.responseCompress = responseCompress;
|
||||||
|
newObj.requestContentEncoding = requestContentEncoding;
|
||||||
|
newObj.requestCompressThreshold = requestCompressThreshold;
|
||||||
|
newObj.timeout = timeout;
|
||||||
|
newObj.httpMethod = httpMethod;
|
||||||
|
newObj.queryStringCharset = queryStringCharset;
|
||||||
|
newObj.contentCharset = contentCharset;
|
||||||
|
newObj.useSignture = useSignture;
|
||||||
|
newObj.accessPrivateApi = accessPrivateApi;
|
||||||
|
newObj.defaultApiVersion = defaultApiVersion;
|
||||||
|
return newObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected RequestPolicy newPolicy() {
|
||||||
|
return new RequestPolicy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置是否使用时间戳
|
||||||
|
*
|
||||||
|
* @param requestSendTimestamp
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setRequestSendTimestamp(boolean requestSendTimestamp) {
|
||||||
|
this.requestSendTimestamp = requestSendTimestamp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRequestSendTimestamp() {
|
||||||
|
return requestSendTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUseHttps() {
|
||||||
|
return useHttps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置是否使用https访问
|
||||||
|
*
|
||||||
|
* @param useHttps
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setUseHttps(boolean useHttps) {
|
||||||
|
this.useHttps = useHttps;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置访问协议,默认为推荐的param2
|
||||||
|
*
|
||||||
|
* @param protocol
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setRequestProtocol(Protocol protocol) {
|
||||||
|
if (protocol == null) {
|
||||||
|
throw new IllegalArgumentException("protocol can not be null");
|
||||||
|
}
|
||||||
|
this.requestProtocol = protocol;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Protocol getRequestProtocol() {
|
||||||
|
return requestProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isResponseCompress() {
|
||||||
|
return responseCompress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* response是否压缩
|
||||||
|
*
|
||||||
|
* @param responseCompress
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
private RequestPolicy setResponseCompress(boolean responseCompress) {
|
||||||
|
this.responseCompress = responseCompress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRequestCompressThreshold() {
|
||||||
|
return requestCompressThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置请求压缩的阀值,超过这个阀值就进行压缩,默认值为-1不开启,建议1K,即1024
|
||||||
|
*
|
||||||
|
* @param requestCompressThreshold
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RequestPolicy setRequestCompressThreshold(int requestCompressThreshold) {
|
||||||
|
this.requestCompressThreshold = requestCompressThreshold;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestContentEncoding() {
|
||||||
|
return requestContentEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestContentEncoding(String requestContentEncoding) {
|
||||||
|
this.requestContentEncoding = requestContentEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeout() {
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置超时时间,默认5s
|
||||||
|
*
|
||||||
|
* @param timeout
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setTimeout(int timeout) {
|
||||||
|
this.timeout = timeout;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置http方法,默认为自动(ATOU),当request中有参数时,使用post,否则get
|
||||||
|
*
|
||||||
|
* @param httpMethod
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setHttpMethod(HttpMethodPolicy httpMethod) {
|
||||||
|
this.httpMethod = httpMethod;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpMethodPolicy getHttpMethod() {
|
||||||
|
return httpMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQueryStringCharset() {
|
||||||
|
return queryStringCharset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置request编码,默认为UTF-8
|
||||||
|
*
|
||||||
|
* @param queryStringCharset
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setQueryStringCharset(String queryStringCharset) {
|
||||||
|
this.queryStringCharset = queryStringCharset;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContentCharset() {
|
||||||
|
return contentCharset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置cotent编码,默认为UTF-8
|
||||||
|
*
|
||||||
|
* @param contentCharset
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setContentCharset(String contentCharset) {
|
||||||
|
this.contentCharset = contentCharset;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置response协议,默认为推荐的json
|
||||||
|
*
|
||||||
|
* @param responseProtocol
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setResponseProtocol(Protocol responseProtocol) {
|
||||||
|
if (requestProtocol == null) {
|
||||||
|
throw new IllegalArgumentException("response protocol can not be null");
|
||||||
|
}
|
||||||
|
this.responseProtocol = responseProtocol;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Protocol getResponseProtocol() {
|
||||||
|
return responseProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求HTTP方法策略
|
||||||
|
*
|
||||||
|
* @author jade
|
||||||
|
*/
|
||||||
|
public static enum HttpMethodPolicy {
|
||||||
|
/**
|
||||||
|
* 总是使用post
|
||||||
|
*/
|
||||||
|
POST,
|
||||||
|
/**
|
||||||
|
* 总是使用get
|
||||||
|
*/
|
||||||
|
GET;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorHandler getErrorHandler() {
|
||||||
|
return errorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置error handler
|
||||||
|
*
|
||||||
|
* @param errorHandler
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setErrorHandler(ErrorHandler errorHandler) {
|
||||||
|
this.errorHandler = errorHandler;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUseSignture() {
|
||||||
|
return useSignture;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否使用签名,取决于api要求
|
||||||
|
*
|
||||||
|
* @param useSignture
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setUseSignture(boolean useSignture) {
|
||||||
|
this.useSignture = useSignture;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNeedAuthorization() {
|
||||||
|
return needAuthorization;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否加入授权信息,取决于api要求
|
||||||
|
*
|
||||||
|
* @param needAuthorization
|
||||||
|
* @return a reference to this object
|
||||||
|
*/
|
||||||
|
public RequestPolicy setNeedAuthorization(boolean needAuthorization) {
|
||||||
|
this.needAuthorization = needAuthorization;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAccessPrivateApi() {
|
||||||
|
return accessPrivateApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否在访问私有api,默认为false. 即访问url以http://host:port/api/...方式
|
||||||
|
*
|
||||||
|
* @param accessPrivateApi
|
||||||
|
*/
|
||||||
|
public RequestPolicy setAccessPrivateApi(boolean accessPrivateApi) {
|
||||||
|
this.accessPrivateApi = accessPrivateApi;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultApiVersion() {
|
||||||
|
return defaultApiVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDateFormat() {
|
||||||
|
return dateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequestPolicy setDateFormat(String dateFormat) {
|
||||||
|
this.dateFormat = dateFormat;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.serialize;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.entity.ResponseWrapper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface DeSerializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回该反序列化接口支持的数据协议.
|
||||||
|
*
|
||||||
|
* @see com.alibaba.openapi.client.policy.Protocol
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String supportedContentType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把istream反序列化为一个ResponseWrapper对象
|
||||||
|
*
|
||||||
|
* @param istream
|
||||||
|
* @param resultType
|
||||||
|
* @param charSet
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ParseException
|
||||||
|
*/
|
||||||
|
public <T> ResponseWrapper<T> deSerialize(InputStream istream, Class<T> resultType, String charSet)
|
||||||
|
throws IOException, ParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把istream反序列化为一个异常对象
|
||||||
|
*
|
||||||
|
* @param inputStream
|
||||||
|
* @param statusCode
|
||||||
|
* @param charSet
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ParseException
|
||||||
|
*/
|
||||||
|
public Throwable buildException(InputStream inputStream, int statusCode, String charSet) throws IOException,
|
||||||
|
ParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param listner
|
||||||
|
*/
|
||||||
|
public void registeDeSerializerListener(DeSerializerListener listner);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.serialize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface DeSerializerListener {
|
||||||
|
|
||||||
|
public void onResponseDeSerialized(String response);
|
||||||
|
|
||||||
|
public void onResponseExceptioned(String response);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.serialize;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface Serializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回该反序列化接口支持的数据协议.
|
||||||
|
*
|
||||||
|
* @see com.alibaba.openapi.client.policy.Protocol
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String supportedContentType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 序列化方法
|
||||||
|
*
|
||||||
|
* @param serializer
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String, Object> serialize(Object serializer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param listner
|
||||||
|
*/
|
||||||
|
public void registeSerializerListener(SerializerListener listner);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.serialize;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface SerializerListener {
|
||||||
|
public void onRequestSerialized(Map<String, Object> serializedRequest);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.serialize;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SerializerProvider {
|
||||||
|
|
||||||
|
private Map<String, Serializer> serializerStore = new LinkedHashMap<String, Serializer>();
|
||||||
|
|
||||||
|
public Serializer getSerializer(String contentType) {
|
||||||
|
return serializerStore.get(contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(Serializer serializer) {
|
||||||
|
serializerStore.put(serializer.supportedContentType(), serializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, DeSerializer> deSerializerStore = new LinkedHashMap<String, DeSerializer>();
|
||||||
|
|
||||||
|
public DeSerializer getDeSerializer(String contentType) {
|
||||||
|
return deSerializerStore.get(contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(DeSerializer deSerializer) {
|
||||||
|
deSerializerStore.put(deSerializer.supportedContentType(), deSerializer);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.util;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.exception.OceanException;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.util.GenericsUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build <code>Exception</code> for all kinds of
|
||||||
|
* {@link com.alibaba.ocean.rawsdk.client.policy.Protocol}, base on the exption
|
||||||
|
* string which got from <code>Reader</code>
|
||||||
|
*
|
||||||
|
* @author xiaoning.qxn
|
||||||
|
*/
|
||||||
|
public class ExceptionParser {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* for Protocol.Json2
|
||||||
|
*
|
||||||
|
* @param exption
|
||||||
|
* @return the new exception
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Throwable buildException4Json2(Map exption) {
|
||||||
|
Map<String, Object> m = exption;
|
||||||
|
|
||||||
|
String errorCodeStr = (String) m.get("error_code");
|
||||||
|
String errorMesage = (String) m.get("error_message");
|
||||||
|
|
||||||
|
if (errorCodeStr == null) {
|
||||||
|
errorCodeStr = (String) m.get("errorCode");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorMesage == null) {
|
||||||
|
errorMesage = (String) m.get("errorMessage");
|
||||||
|
}
|
||||||
|
|
||||||
|
// if null ,then just return the result
|
||||||
|
if (GenericsUtil.isBlank(errorMesage)) {
|
||||||
|
errorMesage = "Unknow message defined in response.";
|
||||||
|
}
|
||||||
|
return buildException(errorCodeStr, errorMesage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Throwable buildException4OAuth2(Object exption) {
|
||||||
|
Map<String, Object> m = (Map<String, Object>) exption;
|
||||||
|
int errorCode = 401;
|
||||||
|
String errorMesage = (String) m.get("error_description");
|
||||||
|
return buildException(errorCode, errorMesage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Throwable buildException(int errorCode, String errorMesage) {
|
||||||
|
|
||||||
|
return new OceanException(String.valueOf(errorCode), errorMesage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Throwable buildException(String errorCode, String errorMesage) {
|
||||||
|
return new OceanException(errorCode, errorMesage);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Project: ocean.client.java.basic
|
||||||
|
*
|
||||||
|
* File Created at 2011-11-23
|
||||||
|
* $Id: LoggerHelper.java 410052 2015-05-06 08:18:05Z hongbang.hb $
|
||||||
|
*
|
||||||
|
* Copyright 2008 Alibaba.com Croporation Limited.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is the confidential and proprietary information of
|
||||||
|
* Alibaba Company. ("Confidential Information"). You shall not
|
||||||
|
* disclose such Confidential Information and shall use it only in
|
||||||
|
* accordance with the terms of the license agreement you entered into
|
||||||
|
* with Alibaba.com.
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.util;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment of LoggerHelper
|
||||||
|
*
|
||||||
|
* @author jade
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class LoggerHelper {
|
||||||
|
private static Logger logger = Logger.getLogger("com.alibaba.openapi.client");
|
||||||
|
|
||||||
|
public static Logger getClientLogger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LoggerHelper() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* Project: ocean.client.java.basic
|
||||||
|
*
|
||||||
|
* File Created at 2011-10-25
|
||||||
|
* $Id: NamedThreadFactory.java 311300 2013-12-23 06:15:28Z yichun.wangyc $
|
||||||
|
*
|
||||||
|
* Copyright 2008 Alibaba.com Croporation Limited.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is the confidential and proprietary information of
|
||||||
|
* Alibaba Company. ("Confidential Information"). You shall not
|
||||||
|
* disclose such Confidential Information and shall use it only in
|
||||||
|
* accordance with the terms of the license agreement you entered into
|
||||||
|
* with Alibaba.com.
|
||||||
|
*/
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.client.util;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment of NamedThreadFactory
|
||||||
|
* @author jade
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NamedThreadFactory implements ThreadFactory {
|
||||||
|
|
||||||
|
static final AtomicInteger poolNumber = new AtomicInteger(1);
|
||||||
|
|
||||||
|
final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||||
|
final ThreadGroup group;
|
||||||
|
final String namePrefix;
|
||||||
|
final boolean isDaemon;
|
||||||
|
|
||||||
|
public NamedThreadFactory() {
|
||||||
|
this("timor.pool");
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamedThreadFactory(String name) {
|
||||||
|
this(name, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamedThreadFactory(String preffix, boolean daemon) {
|
||||||
|
SecurityManager s = System.getSecurityManager();
|
||||||
|
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
||||||
|
namePrefix = preffix + "-" + poolNumber.getAndIncrement() + "-thread-";
|
||||||
|
isDaemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Thread newThread(Runnable r) {
|
||||||
|
Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
|
||||||
|
t.setDaemon(isDaemon);
|
||||||
|
if (t.getPriority() != Thread.NORM_PRIORITY) {
|
||||||
|
t.setPriority(Thread.NORM_PRIORITY);
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.common;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class SDKResult<T> {
|
||||||
|
|
||||||
|
private String errorCode;
|
||||||
|
private String errorMessage;
|
||||||
|
private String requestId;
|
||||||
|
private String traceId;
|
||||||
|
private T result;
|
||||||
|
|
||||||
|
public SDKResult(String code, String message) {
|
||||||
|
super();
|
||||||
|
this.errorCode = code;
|
||||||
|
this.errorMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SDKResult(String requestId,String code, String message) {
|
||||||
|
super();
|
||||||
|
this.requestId=requestId;
|
||||||
|
this.errorCode = code;
|
||||||
|
this.errorMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SDKResult(T result) {
|
||||||
|
super();
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SDKResult(String requestId,T result) {
|
||||||
|
super();
|
||||||
|
this.requestId=requestId;
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SDKResult() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.example;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.ApiExecutor;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.APIId;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.client.policy.RequestPolicy;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.SDKResult;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.example.param.ExampleFamilyGetParam;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.example.param.ExampleFamilyGetResult;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.example.param.ExampleFamilyPostParam;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.example.param.ExampleFamilyPostResult;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.util.DateUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class RawSdkExample {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is an example to simulate the request without accessToken. In this
|
||||||
|
* example, the result is a complex object. You need not care if the
|
||||||
|
* signature is required, the signature is handled by SDK automatically.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void exampleFamilyGet(ApiExecutor apiExecutor) {
|
||||||
|
ExampleFamilyGetParam exampleFamilyGetParam = new ExampleFamilyGetParam();
|
||||||
|
|
||||||
|
APIId oceanApiId = new APIId("api.example", "example.family.get", 1);
|
||||||
|
exampleFamilyGetParam.setOceanApiId(oceanApiId);
|
||||||
|
|
||||||
|
RequestPolicy oceanRequestPolicy = new RequestPolicy();
|
||||||
|
oceanRequestPolicy.setHttpMethod(RequestPolicy.HttpMethodPolicy.POST).setNeedAuthorization(false)
|
||||||
|
.setRequestSendTimestamp(false).setUseHttps(false).setUseSignture(true).setAccessPrivateApi(false);
|
||||||
|
exampleFamilyGetParam.setOceanRequestPolicy(oceanRequestPolicy);
|
||||||
|
|
||||||
|
exampleFamilyGetParam.setFamilyNumber(1);
|
||||||
|
SDKResult<ExampleFamilyGetResult> exampleFamilyGetResult = apiExecutor.execute(exampleFamilyGetParam);
|
||||||
|
|
||||||
|
System.out.println("ExampleFamilyGet call, family information of Result:" + exampleFamilyGetResult.getResult());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is an example to simulate the request which require accessToken. In
|
||||||
|
* this example, HouseImg is a byte array which simulate the feature of
|
||||||
|
* upload image. You need not care if the signature is required, the
|
||||||
|
* signature is handled by SDK automatically.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void exampleFamilyPost(ApiExecutor apiExecutor, String accessToken) {
|
||||||
|
ExampleFamilyPostParam exampleFamilyPostParam = new ExampleFamilyPostParam();
|
||||||
|
|
||||||
|
// Indicate the API Id, api.example:example.family.post-1 is an API
|
||||||
|
// created already in system.
|
||||||
|
// Please refer to
|
||||||
|
// http://ohz.alibaba-inc.com/isp/apifactory/api/view.htm?namespace=api.example&name=example.family.post&version=1&isDraft=true
|
||||||
|
APIId oceanApiId = new APIId("api.example", "example.family.post", 1);
|
||||||
|
exampleFamilyPostParam.setOceanApiId(oceanApiId);
|
||||||
|
|
||||||
|
// Then setup the request policy for calling API.
|
||||||
|
// You must understand below property for the request policy even there
|
||||||
|
// are default value exist.
|
||||||
|
// Below property were depending on the the configuration in server
|
||||||
|
// side, you can contact Ocean Team for detail.
|
||||||
|
RequestPolicy oceanRequestPolicy = new RequestPolicy();
|
||||||
|
oceanRequestPolicy.setHttpMethod(RequestPolicy.HttpMethodPolicy.POST).setNeedAuthorization(false)
|
||||||
|
.setRequestSendTimestamp(false).setUseHttps(false).setUseSignture(true).setAccessPrivateApi(false)
|
||||||
|
.setDateFormat(DateUtil.SIMPLE_DATE_FORMAT_STR);
|
||||||
|
exampleFamilyPostParam.setOceanRequestPolicy(oceanRequestPolicy);
|
||||||
|
|
||||||
|
// This example help us to understand how to send an complex request to
|
||||||
|
// Ocean.
|
||||||
|
exampleFamilyPostParam.setComments("Example for SDK");
|
||||||
|
// it is a complex request, SDK help us to create Json Object
|
||||||
|
// automatically.
|
||||||
|
exampleFamilyPostParam.setFamily(RawSdkExampleData.createFirstFamily());
|
||||||
|
// Also, if you need send some byte array information like image.
|
||||||
|
exampleFamilyPostParam.setHouseImg(RawSdkExampleData.getPicture("example.png"));
|
||||||
|
// Calling and get the result.
|
||||||
|
SDKResult<ExampleFamilyPostResult> exampleFamilyPostResult = apiExecutor.execute(exampleFamilyPostParam,
|
||||||
|
accessToken);
|
||||||
|
|
||||||
|
System.out.println("ExampleFamilyPost call, Family information of Result:"
|
||||||
|
+ exampleFamilyPostResult.getResult().getResult());
|
||||||
|
System.out.println("ExampleFamilyPost call, Desc of Result:"
|
||||||
|
+ exampleFamilyPostResult.getResult().getResultDesc());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String APP_KEY = "2970712";
|
||||||
|
|
||||||
|
private static final String SEC_KEY = "Jo1tglPzXSKh";
|
||||||
|
|
||||||
|
private static final String ACCESS_TOKEN = "a2dc9284-4f86-45f6-a055-83a24ac38dc7";
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiExecutor apiExecutor = new ApiExecutor(APP_KEY, SEC_KEY);
|
||||||
|
|
||||||
|
//分类列表查询
|
||||||
|
// AlibabaCategoryGetParam alibabaCategoryGetParam = new AlibabaCategoryGetParam();
|
||||||
|
// alibabaCategoryGetParam.setCategoryID(0L);
|
||||||
|
// SDKResult<AlibabaCategoryGetResult> categoryGetResultSDKResult = apiExecutor.execute(alibabaCategoryGetParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(categoryGetResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//精选商品标签查询
|
||||||
|
// JxhyProductFilterGetParam jxhyProductFilterGetParam = new JxhyProductFilterGetParam();
|
||||||
|
// SDKResult<JxhyProductFilterGetResult> jxhyProductFilterGetResultSDKResult = apiExecutor.execute(jxhyProductFilterGetParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(jxhyProductFilterGetResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//商品列表
|
||||||
|
// JxhyProductGetPageListParam jxhyProductGetPageListParam = new JxhyProductGetPageListParam();
|
||||||
|
// String[] filter = {"jxhy","noReason7DReturn"};
|
||||||
|
// jxhyProductGetPageListParam.setFilters(filter);
|
||||||
|
// jxhyProductGetPageListParam.setKeyword("免手洗拖把");
|
||||||
|
// jxhyProductGetPageListParam.setPageSize(50);
|
||||||
|
// jxhyProductGetPageListParam.setPageNum(1);
|
||||||
|
// SDKResult<JxhyProductGetPageListResult> jxhyProductGetPageListResultSDKResult = apiExecutor.execute(jxhyProductGetPageListParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(jxhyProductGetPageListResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//关注商品
|
||||||
|
// AlibabaProductFollowParam alibabaProductFollowParam = new AlibabaProductFollowParam();
|
||||||
|
// alibabaProductFollowParam.setProductId(662817120131L);
|
||||||
|
// SDKResult<AlibabaProductFollowResult> productFollowResultSDKResult = apiExecutor.execute(alibabaProductFollowParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(productFollowResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//取消关注商品
|
||||||
|
// AlibabaProductUnfollowCrossborderParam alibabaProductUnfollowCrossborderParam = new AlibabaProductUnfollowCrossborderParam();
|
||||||
|
// alibabaProductUnfollowCrossborderParam.setProductId(662817120131L);
|
||||||
|
// SDKResult<AlibabaProductUnfollowCrossborderResult> alibabaProductUnfollowCrossborderResultSDKResult = apiExecutor.execute(alibabaProductUnfollowCrossborderParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(alibabaProductUnfollowCrossborderResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//商品详情
|
||||||
|
// AlibabaPifatuanProductDetailListParam alibabaPifatuanProductDetailListParam = new AlibabaPifatuanProductDetailListParam();
|
||||||
|
// alibabaPifatuanProductDetailListParam.setOfferIds(new long[]{662817120131L});
|
||||||
|
// SDKResult<AlibabaPifatuanProductDetailListResult> pifatuanProductDetailListResultSDKResult = apiExecutor.execute(alibabaPifatuanProductDetailListParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(pifatuanProductDetailListResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//运费查询
|
||||||
|
// AlibabaLogisticsMyFreightTemplateListGetParam alibabaLogisticsMyFreightTemplateListGetParam = new AlibabaLogisticsMyFreightTemplateListGetParam();
|
||||||
|
// alibabaLogisticsMyFreightTemplateListGetParam.setTemplateId(16449681L);
|
||||||
|
// alibabaLogisticsMyFreightTemplateListGetParam.setQueryRate(true);
|
||||||
|
// SDKResult<AlibabaLogisticsMyFreightTemplateListGetResult> logisticsMyFreightTemplateListGetResultSDKResult = apiExecutor.execute(alibabaLogisticsMyFreightTemplateListGetParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(logisticsMyFreightTemplateListGetResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//下单预览
|
||||||
|
// AlibabaCreateOrderPreviewParam alibabaCreateOrderPreviewParam = new AlibabaCreateOrderPreviewParam();
|
||||||
|
// AlibabaTradeFastAddress address = new AlibabaTradeFastAddress();
|
||||||
|
// address.setAddress("四川省成都市武侯区下一站都市B座613");
|
||||||
|
// address.setDistrictCode("510107");
|
||||||
|
// address.setMobile("13370065231");
|
||||||
|
// address.setFullName("刘先生");
|
||||||
|
// alibabaCreateOrderPreviewParam.setAddressParam(address);
|
||||||
|
// AlibabaTradeFastCargo cargo = new AlibabaTradeFastCargo();
|
||||||
|
// cargo.setSpecId("4ce2c13e01be2460299431431af52c2a");
|
||||||
|
// cargo.setOfferId(662817120131L);
|
||||||
|
// cargo.setQuantity(1.0);
|
||||||
|
// AlibabaTradeFastCargo[] cargoArray= {cargo};
|
||||||
|
// alibabaCreateOrderPreviewParam.setCargoParamList(cargoArray);
|
||||||
|
// SDKResult<AlibabaCreateOrderPreviewResult> alibabaCreateOrderPreviewResultSDKResult = apiExecutor.execute(alibabaCreateOrderPreviewParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(alibabaCreateOrderPreviewResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//下单
|
||||||
|
// AlibabaTradeFastCreateOrderParam alibabaTradeFastCreateOrderParam = new AlibabaTradeFastCreateOrderParam();
|
||||||
|
// alibabaTradeFastCreateOrderParam.setFlow("boutiquepifa");
|
||||||
|
// alibabaTradeFastCreateOrderParam.setAddressParam(address);
|
||||||
|
// alibabaTradeFastCreateOrderParam.setCargoParamList(cargoArray);
|
||||||
|
// SDKResult<AlibabaTradeFastCreateOrderResult> alibabaTradeFastCreateOrderResultSDKResult = apiExecutor.execute(alibabaTradeFastCreateOrderParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(alibabaTradeFastCreateOrderResultSDKResult));
|
||||||
|
|
||||||
|
//订单列表
|
||||||
|
// AlibabaTradeGetBuyerOrderListParam alibabaTradeGetBuyerOrderListParam = new AlibabaTradeGetBuyerOrderListParam();
|
||||||
|
// alibabaTradeGetBuyerOrderListParam.setPage(1);
|
||||||
|
// alibabaTradeGetBuyerOrderListParam.setPageSize(10);
|
||||||
|
// SDKResult<AlibabaTradeGetBuyerOrderListResult> alibabaTradeGetBuyerOrderListResultSDKResult = apiExecutor.execute(alibabaTradeGetBuyerOrderListParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(alibabaTradeGetBuyerOrderListResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
//退款
|
||||||
|
// AlibabaTradeCreateRefundParam alibabaTradeCreateRefundParam = new AlibabaTradeCreateRefundParam();
|
||||||
|
// alibabaTradeCreateRefundParam.setOrderId(3852437870339459000L);
|
||||||
|
// alibabaTradeCreateRefundParam.setOrderEntryIds(new long[]{3852437870339459000L});
|
||||||
|
// alibabaTradeCreateRefundParam.setDisputeRequest("refund");
|
||||||
|
|
||||||
|
//取消交易
|
||||||
|
// AlibabaTradeCancelParam alibabaTradeCancelParam = new AlibabaTradeCancelParam();
|
||||||
|
// alibabaTradeCancelParam.setWebSite("1688");
|
||||||
|
// alibabaTradeCancelParam.setTradeID(3853060419838459119L);
|
||||||
|
// alibabaTradeCancelParam.setCancelReason("buyerCancel");
|
||||||
|
// SDKResult<AlibabaTradeCancelResult> alibabaTradeCancelResultSDKResult = apiExecutor.execute(alibabaTradeCancelParam, ACCESS_TOKEN);
|
||||||
|
// System.out.println(JSON.toJSONString(alibabaTradeCancelResultSDKResult.getResult()));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
|
||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.example;
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.example.param.ExampleCar;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.example.param.ExampleFamily;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.example.param.ExampleHouse;
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.example.param.ExamplePerson;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongbang.hb
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RawSdkExampleData {
|
||||||
|
|
||||||
|
public static final String DATE_FORMAT_STR = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
private static final ThreadLocal<DateFormat> DEFAULT_FORMAT = new ThreadLocal<DateFormat>() {
|
||||||
|
@Override
|
||||||
|
protected DateFormat initialValue() {
|
||||||
|
return new SimpleDateFormat(DATE_FORMAT_STR);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public static ExampleFamily createFirstFamily() {
|
||||||
|
ExampleFamily family = new ExampleFamily();
|
||||||
|
|
||||||
|
ExamplePerson father = new ExamplePerson();
|
||||||
|
father.setAge(38);
|
||||||
|
father.setBirthday(createDate("1978-03-12 10:10:10"));
|
||||||
|
father.setMobileNumber("27088888888");
|
||||||
|
father.setName("张进则");
|
||||||
|
family.setFather(father);
|
||||||
|
|
||||||
|
ExamplePerson mother = new ExamplePerson();
|
||||||
|
mother.setAge(33);
|
||||||
|
mother.setBirthday(createDate("1983-06-17 10:10:10"));
|
||||||
|
mother.setMobileNumber("27099999999");
|
||||||
|
mother.setName("周煜清");
|
||||||
|
family.setMother(mother);
|
||||||
|
|
||||||
|
ExamplePerson xiaoming = new ExamplePerson();
|
||||||
|
xiaoming.setBirthday(createDate("2010-10-17 10:10:10"));
|
||||||
|
xiaoming.setName("张小明");
|
||||||
|
|
||||||
|
ExamplePerson xiaogang = new ExamplePerson();
|
||||||
|
xiaogang.setBirthday(createDate("2010-10-17 10:20:10"));
|
||||||
|
xiaogang.setName("张小刚");
|
||||||
|
ExamplePerson[] children = new ExamplePerson[] { xiaoming, xiaogang };
|
||||||
|
family.setChildren(children);
|
||||||
|
|
||||||
|
family.setFamilyNumber(1);
|
||||||
|
|
||||||
|
family.setMyHouse(createHouse("中国上海市浦东新区", false));
|
||||||
|
|
||||||
|
ExampleCar[] ownedCars = new ExampleCar[] { createCar("BMW", 370000.12), createCar("Ford", 150000.27) };
|
||||||
|
family.setOwnedCars(ownedCars);
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExampleFamily createSecondFamily() {
|
||||||
|
ExampleFamily family = new ExampleFamily();
|
||||||
|
|
||||||
|
ExamplePerson mother = new ExamplePerson();
|
||||||
|
mother.setAge(33);
|
||||||
|
mother.setBirthday(createDate("1983-06-17 10:10:10"));
|
||||||
|
mother.setMobileNumber("27099999999");
|
||||||
|
mother.setName("叶涵");
|
||||||
|
family.setMother(mother);
|
||||||
|
|
||||||
|
ExamplePerson xiaoming = new ExamplePerson();
|
||||||
|
xiaoming.setBirthday(createDate("2010-10-17 10:10:10"));
|
||||||
|
xiaoming.setName("叶子涵");
|
||||||
|
xiaoming.setAge(6);
|
||||||
|
|
||||||
|
ExamplePerson[] children = new ExamplePerson[] { xiaoming };
|
||||||
|
family.setChildren(children);
|
||||||
|
|
||||||
|
family.setFamilyNumber(2);
|
||||||
|
|
||||||
|
family.setMyHouse(createHouse("中国浙江省杭州市滨江区", null));
|
||||||
|
|
||||||
|
ExampleCar[] ownedCars = new ExampleCar[] { createCar("XXXX", 1370000.12) };
|
||||||
|
family.setOwnedCars(ownedCars);
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExampleCar createCar(String name, Double price) {
|
||||||
|
ExampleCar car = new ExampleCar();
|
||||||
|
car.setBoughtDate(createDate("2008-10-17 10:20:10"));
|
||||||
|
car.setBuiltArea("中国");
|
||||||
|
car.setBuiltDate(createDate("2007-10-17 10:20:10"));
|
||||||
|
car.setCarNumber("HZ-H-9875");
|
||||||
|
car.setName(name);
|
||||||
|
car.setPrice(price);
|
||||||
|
car.setSeats(4);
|
||||||
|
return car;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExampleHouse createHouse(String address, Boolean rent) {
|
||||||
|
ExampleHouse house = new ExampleHouse();
|
||||||
|
house.setAreaSize(120);
|
||||||
|
house.setLocation(address);
|
||||||
|
house.setRent(rent);
|
||||||
|
return house;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date createDate(String input) {
|
||||||
|
try {
|
||||||
|
SimpleDateFormat format = (SimpleDateFormat)DEFAULT_FORMAT.get().clone();
|
||||||
|
return format.parse(input);
|
||||||
|
} catch (Exception e) {
|
||||||
|
//exception use default null
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] getPicture(String fileName) {
|
||||||
|
URL fatherURL = RawSdkExampleData.class.getClassLoader().getResource(fileName);
|
||||||
|
try {
|
||||||
|
InputStream inputStream = fatherURL.openStream();
|
||||||
|
byte[] bs = new byte[1024 * 1024];
|
||||||
|
int readCount = inputStream.read(bs);
|
||||||
|
byte[] content = new byte[readCount];
|
||||||
|
System.arraycopy(bs, 0, content, 0, readCount);
|
||||||
|
return content;
|
||||||
|
} catch (IOException e) {
|
||||||
|
// ignore ioexception
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.example;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author qiuwu [qiuwu.sjl@alibaba-inc.com].
|
||||||
|
* @date Created at 2023/7/31 2:10 PM.
|
||||||
|
*/
|
||||||
|
public class RawSdkProxyExample {
|
||||||
|
private static final int PROXY_PORT = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("{host}", PROXY_PORT));
|
||||||
|
// ApiExecutor apiExecutor = new ApiExecutor("{appKey}", "{appSecret}", proxy);
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.example.param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class ExampleCar {
|
||||||
|
|
||||||
|
private Date builtDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Date getBuiltDate() {
|
||||||
|
return builtDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setBuiltDate(Date builtDate) {
|
||||||
|
this.builtDate = builtDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Date boughtDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Date getBoughtDate() {
|
||||||
|
return boughtDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setBoughtDate(Date boughtDate) {
|
||||||
|
this.boughtDate = boughtDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String builtArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getBuiltArea() {
|
||||||
|
return builtArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setBuiltArea(String builtArea) {
|
||||||
|
this.builtArea = builtArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String carNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getCarNumber() {
|
||||||
|
return carNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setCarNumber(String carNumber) {
|
||||||
|
this.carNumber = carNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Double price;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Double getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setPrice(Double price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer seats;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer getSeats() {
|
||||||
|
return seats;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setSeats(Integer seats) {
|
||||||
|
this.seats = seats;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ExampleCar [builtDate=" + builtDate + ", boughtDate=" + boughtDate + ", name=" + name + ", builtArea=" + builtArea + ", carNumber=" + carNumber
|
||||||
|
+ ", price=" + price + ", seats=" + seats + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.example.param;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
||||||
|
public class ExampleFamily {
|
||||||
|
|
||||||
|
private Integer familyNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 家庭编号
|
||||||
|
*/
|
||||||
|
public Integer getFamilyNumber() {
|
||||||
|
return familyNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置家庭编号 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*/
|
||||||
|
public void setFamilyNumber(Integer familyNumber) {
|
||||||
|
this.familyNumber = familyNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExamplePerson father;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 父亲对象,可以为空
|
||||||
|
*/
|
||||||
|
public ExamplePerson getFather() {
|
||||||
|
return father;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置父亲对象,可以为空 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setFather(ExamplePerson father) {
|
||||||
|
this.father = father;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExamplePerson mother;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 母亲对象,可以为空
|
||||||
|
*/
|
||||||
|
public ExamplePerson getMother() {
|
||||||
|
return mother;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置母亲对象,可以为空 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMother(ExamplePerson mother) {
|
||||||
|
this.mother = mother;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExamplePerson[] children;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 孩子列表
|
||||||
|
*/
|
||||||
|
public ExamplePerson[] getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置孩子列表 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setChildren(ExamplePerson[] children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExampleCar[] ownedCars;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 拥有的汽车信息
|
||||||
|
*/
|
||||||
|
public ExampleCar[] getOwnedCars() {
|
||||||
|
return ownedCars;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置拥有的汽车信息 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setOwnedCars(ExampleCar[] ownedCars) {
|
||||||
|
this.ownedCars = ownedCars;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExampleHouse myHouse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 所住的房屋信息
|
||||||
|
*/
|
||||||
|
public ExampleHouse getMyHouse() {
|
||||||
|
return myHouse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置所住的房屋信息 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setMyHouse(ExampleHouse myHouse) {
|
||||||
|
this.myHouse = myHouse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ExampleFamily [familyNumber=" + familyNumber + ", father=" + father + ", mother=" + mother + ", children=" + Arrays.toString(children)
|
||||||
|
+ ", ownedCars=" + Arrays.toString(ownedCars) + ", myHouse=" + myHouse + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package org.springblade.modules.alibaba.ocean.rawsdk.example.param;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springblade.modules.alibaba.ocean.rawsdk.common.AbstractAPIRequest;
|
||||||
|
|
||||||
|
public class ExampleFamilyGetParam extends AbstractAPIRequest<ExampleFamilyGetResult> {
|
||||||
|
|
||||||
|
private Integer familyNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 可接受参数1或者2,其余参数无法找到family对象
|
||||||
|
*/
|
||||||
|
public Integer getFamilyNumber() {
|
||||||
|
return familyNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置可接受参数1或者2,其余参数无法找到family对象 * 参数示例:
|
||||||
|
*
|
||||||
|
* <pre></pre>
|
||||||
|
*
|
||||||
|
* 此参数必填
|
||||||
|
*/
|
||||||
|
public void setFamilyNumber(Integer familyNumber) {
|
||||||
|
this.familyNumber = familyNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user