Appearance
外部标准库接口(Legalstar)
网关前缀:/standard(StripPrefix=1 后转发到 muotai-standard-biz)
服务直连(开发):http://{host}:6064
鉴权:Bearer Token(与其它 standard 接口一致)
统一响应:{ "code": 0, "msg": null, "data": ... }(导出接口除外,直接返回 xlsx 文件流)
数据来源:legalstar 库(国标 / 行业标准 / 地方标准 / 下载日志),只读为主,也支持 CRUD 与 Excel 导入导出。
一、模块与基础路径
| 模块 | Base 路径(网关完整路径) |
|---|---|
| 国标基础 | /standard/externalStandard/country |
| 国标详情 | /standard/externalStandard/country/details |
| 行业标准基础 | /standard/externalStandard/industry |
| 行业标准详情 | /standard/externalStandard/industry/details |
| 地方标准基础 | /standard/externalStandard/regional |
| 地方标准详情 | /standard/externalStandard/regional/details |
| 下载日志 | /standard/externalStandard/downloadLog |
各模块接口形态一致,下文以 国标基础 为例说明;详情与其它模块仅路径、字段名不同。
二、公共查询参数(page / list / export)
Query 参数,适用于 GET .../page、GET .../list、GET .../export:
| 参数 | 类型 | 说明 |
|---|---|---|
| current | Long | 页码,默认 1(仅 page 有效) |
| size | Long | 每页条数,默认 20(仅 page 有效) |
| keyword | String | 关键字,模糊匹配编号/名称 |
| status | String | 标准状态精确匹配 |
| stdCode | String | 标准编号精确匹配 |
| bizKey | String | 业务主键:国标用 stdId,行标/地标用 pk |
| stdType | String | 仅下载日志:标准类型,如 regional_standards |
| success | Integer | 仅下载日志:是否成功 0 / 1 |
示例:
GET /standard/externalStandard/country/page?current=1&size=20&keyword=GB/T&status=现行
GET /standard/externalStandard/downloadLog/page?stdType=industry_standards&success=0分页 data 结构(MyBatis-Plus):
json
{
"records": [ /* 实体数组 */ ],
"total": 1000,
"size": 20,
"current": 1,
"pages": 50
}三、通用增删改查接口(每个模块相同)
以 {base} 表示上表中的 Base 路径。
| 用途 | 方法 | 路径 | 说明 |
|---|---|---|---|
| 详情 | GET | {base}/detail | Query 传实体非空字段作为条件 |
| 分页 | GET | {base}/page | 见第二节公共查询参数 |
| 列表 | GET | {base}/list | 不分页,慎用大数据量 |
| 新增 | POST | {base}/save | Body JSON |
| 修改 | POST | {base}/update | Body JSON,需带主键 |
| 新增或修改 | POST | {base}/submit | Body JSON,按主键 upsert |
| 删除 | POST | {base}/remove?ids= | 见下方删除说明 |
| 导出 | GET | {base}/export | 返回 xlsx,Query 同 page |
| 导出模板 | GET | {base}/export-template | 空模板 xlsx |
| 导入 | POST | {base}/import | multipart/form-data,字段名 file |
新增时主键补全(服务端)
前端 新增 可不传业务主键,服务端在写入 legalstar 库前自动补全:
| 模块 | 业务主键 | 必填字段 | 补全规则 |
|---|---|---|---|
| 国标基础 | stdId | stdCode | 按 stdCode 查主表已有则复用 stdId;否则生成 UUID |
| 国标详情 | stdId(非表主键) | stdCode | 按 stdCode 查主表/详情已有则复用;否则生成 UUID;表主键 id 自增 |
| 行标/地标基础 | pk | code | 按 code 查主表已有则复用 pk;否则生成 UUID |
| 行标/地标详情 | pk | standardNumber 或 pk | 按标准号查主表/详情已有则复用;否则生成 UUID |
| 下载日志 | — | stdType、pk、stdCode | 三项必填;导入时按 stdType+pk 匹配已有记录做 upsert |
修改(/update):国标需能定位记录(传 stdId 或 stdCode 匹配已有);行标/地标详情需传自增 id 或能匹配的 pk/标准号。
JSON 字段支持驼峰与下划线别名(如 std_id、std_code)。
删除 ids 说明
| 模块 | ids 含义 |
|---|---|
| 国标基础 | stdId 逗号分隔,如 id1,id2 |
| 国标/行标/地标详情 | 自增 id 逗号分隔,如 1,2,3 |
| 行业标准/地方标准基础 | 自增 id 逗号分隔 |
| 下载日志 | 自增 id 逗号分隔 |
四、字段说明
4.1 国标基础 country_standards
| 字段 | 类型 | 说明 |
|---|---|---|
| stdId | String | 主键,新增可选(见上文补全规则) |
| stdCode | String | 标准编号,新增必填,如 GB/T 12345-2020 |
| isRef | Integer | 是否引用标准:0 否,1 是 |
| nameCn | String | 中文名称 |
| status | String | 状态,如 现行、废止 |
| pubDate | String | 发布日期 yyyy-MM-dd |
| implDate | String | 实施日期 yyyy-MM-dd |
| createdAt | String | 创建时间(一般只读) |
详情查询示例:
GET /standard/externalStandard/country/detail?stdId=xxx
GET /standard/externalStandard/country/detail?stdCode=GB/T%2012345-20204.2 国标详情 country_standards_details
| 字段 | 类型 | 说明 |
|---|---|---|
| id | Integer | 自增主键,新增勿传 |
| stdId | String | 关联国标 stdId,新增可选(按 stdCode 补全) |
| stdCode | String | 标准编号,新增必填 |
| isRef | Integer | 是否引用标准 |
| nameCn | String | 中文名称 |
| status | String | 状态 |
| pubDate / implDate | String | 发布/实施日期 |
| nameEn | String | 英文名称 |
| allowPreview | Integer | 允许预览 0/1 |
| allowDownload | Integer | 允许下载 0/1 |
| ccs | String | 中国标准分类号 |
| ics | String | 国际标准分类号 |
| maintenanceDepat | String | 归口管理单位 |
| centralizedDepat | String | 主管部门 |
| pubDepat | String | 发布单位 |
| comment | String | 备注 |
| createTime / updateTime | String | 时间戳 |
详情路径前缀:/standard/externalStandard/country/details
GET /standard/externalStandard/country/details/detail?stdCode=GB/T%2012345-2020
GET /standard/externalStandard/country/details/page?bizKey={stdId}¤t=1&size=204.3 行业标准基础 industry_standards
| 字段 | 类型 | 说明 |
|---|---|---|
| id | Integer | 自增主键 |
| pk | String | 平台唯一主键,新增可选(按 code 补全) |
| code | String | 标准编号,新增必填 |
| chName | String | 中文名称 |
| industry | String | 行业 |
| chargeDept | String | 主管部门 |
| status | String | 状态 |
| issueDate | String | 发布日期 |
| actDate | String | 实施日期 |
| recordDate | String | 备案日期 |
| recordNo | String | 备案号 |
| reviseStdCodes | String | 被代替标准 |
| rawData | String | 原始 JSON 字符串 |
| createTime / updateTime | String | 时间戳 |
查询时 bizKey 传 pk,stdCode 传 code。
4.4 行业标准详情 industry_standards_details
| 字段 | 类型 | 说明 |
|---|---|---|
| id | Integer | 自增主键 |
| pk | String | 平台主键 |
| standardNumber | String | 标准号 |
| releaseDate | String | 发布日期 |
| implementationDate | String | 实施日期 |
| revisionType | String | 制修订:制定/修订 |
| replacedStandard | String | 代替标准 |
| approvalDepartment | String | 批准发布部门 |
| industryClassification | String | 行业分类 |
| standardCategory | String | 标准类别 |
| chinaStandardClassification | String | 中国标准分类号 |
| internationalStandardClassification | String | 国际标准分类号 |
| technicalCommittee | String | 技术归口单位 |
| filingNumber | String | 备案号 |
| filingDate | String | 备案日期 |
| applicableRange | String | 适用范围 |
| draftingUnit | String | 起草单位 |
| drafter | String | 起草人 |
| downHerf | String | 下载链接 |
| createTime / updateTime | String | 时间戳 |
路径前缀:/standard/externalStandard/industry/details
4.5 地方标准基础 regional_standards
字段与行业标准基础相同,其中 industry 表示 省市。
路径前缀:/standard/externalStandard/regional
4.6 地方标准详情 regional_standards_details
字段与行业标准详情相同。
路径前缀:/standard/externalStandard/regional/details
4.7 下载日志 std_download_log
| 字段 | 类型 | 说明 |
|---|---|---|
| id | Long | 自增主键 |
| stdType | String | 标准类型,如 regional_standards、national_standards |
| pk | String | 业务主键 |
| stdCode | String | 标准编号 |
| success | Integer | 是否下载成功 0/1 |
| errorMessage | String | 失败原因 |
| createdAt | String | 记录时间 |
路径前缀:/standard/externalStandard/downloadLog
五、请求示例
5.1 国标分页
http
GET /standard/externalStandard/country/page?current=1&size=20&keyword=GB/T&status=现行
Authorization: Bearer {token}5.2 国标新增
http
POST /standard/externalStandard/country/save
Content-Type: application/json
{
"stdId": "abc123",
"stdCode": "GB/T 12345-2020",
"isRef": 0,
"nameCn": "示例标准名称",
"status": "现行",
"pubDate": "2020-01-01",
"implDate": "2020-07-01"
}5.3 行业标准删除
http
POST /standard/externalStandard/industry/remove?ids=1,2,35.4 导入 Excel
http
POST /standard/externalStandard/country/import
Content-Type: multipart/form-data
file: (xlsx 文件,列头与 export-template 一致)导入规则:国标基础按 stdId upsert;国标详情按 stdCode upsert;行标/地标基础按 pk upsert;详情按 pk upsert;下载日志按 stdType + pk upsert。
5.5 导出
http
GET /standard/externalStandard/country/export?keyword=GB/T&status=现行浏览器或 axios 需以 blob 接收,响应头 Content-Disposition: attachment;filename=*.xlsx。
六、前端对接建议
- 列表页:优先用
/page,搜索框映射keyword,状态筛选映射status。 - 详情页:基础信息用
/detail?stdId=或/detail?pk=;扩展字段调对应/details/detail。 - 国标与行标/地标:国标主键是字符串
stdId;行标/地标主键是pk(字符串)+ 自增id(删除用)。 - 导出/导入:先调
/export-template下载模板,填完后/import上传;导出带当前筛选条件即可。 - 下载日志:用
stdType+success筛选未完成下载的标准,便于补采任务展示。
七、Swagger 文档
服务启动后可访问 Knife4j 文档,分组名:
- 外部标准-国标
- 外部标准-行业标准
- 外部标准-地方标准
- 外部标准-下载日志