数据表:
biz_information_category(DDL/种子见sql/biz_information_category.sql)。
后端包:com.ruoyi.web.modules.category;Controller:BizInformationCategoryController。
前端 API:ruoyi-ui/src/api/category/informationCategory.js。
本文描述 只读查询 接口。JSON 字段名统一为英文 code、name(不再使用 编号、名称)。
| 库字段 | 含义 | 接口字段 |
|---|---|---|
category_code |
类别编码(业务唯一) | code |
category_name |
类别名称 | name |
parent_code |
上级编码,指向父节点 category_code |
建树用,平铺接口不返回 |
category_type |
类型(同父下分子组时使用,如养殖标准 1~5) | categoryType(仅树节点) |
module_id |
模块:01 养殖资讯、02 畜牧资源、03 农技课堂 |
/tree 支持按 moduleId 筛选;树节点响应字段 moduleId |
visible |
1 可见、0 不可见 |
仅 /tree 只返回 visible=1;/children 不按 visible 过滤 |
del_flag |
0 有效,2 逻辑删除 |
已删除记录不出现在接口结果中 |
根节点 code |
name |
子节点说明 |
|---|---|---|
001 |
养殖标准 | category_type 1~5 分组,叶子 001001~001013 |
002 |
科技项目指南 | 叶子 002001~002004,子项 category_type 多为 NULL |
003 |
产业政策 | 叶子 003001~003004,子项 category_type 多为 NULL |
叶子 code 示例 |
业务用途 |
|---|---|
001001~001004 |
养殖标准(繁育/饲养等,parentCode=001,categoryType=1) |
001005~001006 |
饲喂标准(categoryType=2) |
001007~001010 |
设备实施作业标准(categoryType=3) |
001011~001012 |
生长与出栏标准(categoryType=4) |
001013 |
疾病决策(categoryType=5,visible=0,不出现在 /tree) |
002001~002004 |
科技项目指南 project_type |
003001~003004 |
产业政策宣传/补贴/共富等固定类型;亦用于 v_farming_news 中政策类资讯 |
移动端「养殖资讯」列表按 type 筛选时,type 取值与上述叶子 code 一致(见 sql/biz_v_farming_news.sql)。
| 项 | 说明 |
|---|---|
| Base Path | /category/informationCategory(与项目 context-path 拼接) |
| 鉴权 | 与若依登录态一致;须携带有效 Token(与业务后台其它 GET 接口相同) |
| 响应封装 | RuoYi AjaxResult:code(HTTP 业务码,如 200)、msg、data |
| 排序 | 库表查询按 category_code 升序;树内各级子节点同样按 code 升序 |
| 错误 | parentCode 为空时,/children 返回 msg:「上级编码不能为空」 |
仅返回 del_flag=0 且 visible=1 的类别;不可见节点(如 001013 疾病决策)不会出现在树中。若某节点的父级不可见或未命中筛选条件,该节点会作为根节点出现在 data 中(与建树逻辑一致)。
| 项 | 值 |
|---|---|
| Method | GET |
| URI | /category/informationCategory/tree |
Query 参数(均可选)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
categoryType |
string | 否 | 仅加载 category_type 等于该值的记录后再组装树 |
moduleId |
string | 否 | 仅加载指定模块:01 养殖资讯、02 畜牧资源、03 农技课堂 |
示例:
GET /category/informationCategory/tree
GET /category/informationCategory/tree?moduleId=01
GET /category/informationCategory/tree?categoryType=1&moduleId=01
data类型:InformationCategoryTreeVo[],森林(多个根节点)。单节点字段:
| 字段 | 类型 | 说明 |
|---|---|---|
code |
string | 类别编码 |
name |
string | 类别名称 |
categoryType |
string | 类型,根节点常为 null |
children |
array | 子节点列表,结构同父节点;无子节点时可省略或 [] |
示例(节选)
{
"code": 200,
"msg": "操作成功",
"data": [
{
"code": "001",
"name": "养殖标准",
"moduleId": "01",
"children": [
{
"code": "001001",
"name": "繁育作业",
"categoryType": "1",
"moduleId": "01"
},
{
"code": "001002",
"name": "饲养工作",
"categoryType": "1"
}
]
},
{
"code": "002",
"name": "科技项目指南",
"children": [
{ "code": "002001", "name": "高新技术" },
{ "code": "002002", "name": "农业科技" }
]
}
]
}
moduleId=01(养殖资讯仅含 001~003 及其可见子节点)。categoryType 下的子树时,可叠加 categoryType。/children,不要用 /tree。返回 del_flag=0 的全部直接下级,不按 visible 过滤(例如 parentCode=001&categoryType=5 可返回 001013)。
| 项 | 值 |
|---|---|
| Method | GET |
| URI | /category/informationCategory/children |
Query 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
parentCode |
string | 是 | 上级编码,如 001、002、003 |
categoryType |
string | 否 | 传入时增加 category_type 精确匹配 |
示例:
GET /category/informationCategory/children?parentCode=001&categoryType=1
GET /category/informationCategory/children?parentCode=002
GET /category/informationCategory/children?parentCode=003
data类型:InformationCategoryItemVo[],仅直接下级(不含孙子节点)。
| 字段 | 类型 | 说明 |
|---|---|---|
code |
string | 类别编码 |
name |
string | 类别名称 |
示例
{
"code": 200,
"msg": "操作成功",
"data": [
{ "code": "001001", "name": "繁育作业" },
{ "code": "001002", "name": "饲养工作" },
{ "code": "001003", "name": "免疫程序" },
{ "code": "001004", "name": "环境调控" }
]
}
| 模块 | parentCode |
categoryType |
叶子编码示例 |
|---|---|---|---|
| 养殖标准 | 001 |
1 |
001001~001004 |
| 饲喂标准 | 001 |
2 |
001005、001006 |
| 设备实施作业标准 | 001 |
3 |
001007~001010 |
| 生长与出栏标准 | 001 |
4 |
001011、001012 |
| 疫病诊疗标准 | 001 |
5 |
001013(种子 visible=0,/tree 不展示,/children 仍返回) |
| 科技项目指南 | 002 |
省略 | 002001~002004 |
| 产业政策(资讯展示) | 003 |
省略 | 003001~003004 |
后端保存校验(*TypeValidator)以本接口(或等价 Service)返回的 code 集合为准;非法编码返回「标准/项目类型无效,请选择资讯类别中的类型」类提示。
文件:ruoyi-ui/src/api/category/informationCategory.js
import {
listInformationCategoryTree,
listInformationCategoryChildren
} from '@/api/category/informationCategory'
// 树(仅 visible=1;养殖资讯模块示例)
listInformationCategoryTree({ moduleId: '01', categoryType: '1' }).then((res) => {
const tree = res.data || []
})
// 下拉选项(常见)
listInformationCategoryChildren('001', '1').then((res) => {
const options = (res.data || []).map((item) => ({
value: item.code,
label: item.name
}))
})
注意:勿再使用 item['编号']、item['名称']。
| 接口 | 说明 |
|---|---|
GET /app/farmingNews/list?type={code} |
按资讯类别编码分页查询 v_farming_news(pageNum/pageSize,默认 1/10,上限 50);响应 rows、total,字段见 养殖资讯接口说明 |
GET /app/livestockResource/list?type={code} |
按资源类型编码分页查询 v_livestock_resource(004002/004006/004007/004008);字段见 畜牧资源接口说明 |
GET /app/agriculturalCourse/list?type={code} |
按类型编码分页查询 v_agricultural_course(005001–005004 或 006001–006004);见 农技课堂接口说明 |
| 各标准/项目 CRUD | 表字段 standard_type / project_type 存叶子 code,与本文 children 返回值一致 |
| 日期 | 说明 |
|---|---|
| 2026-05-20 | 初版:/tree、/children 接口说明;JSON 字段统一为 code、name |
| 2026-05-20 | 补充种子层级、业务模块参数对照及前端调用示例 |
| 2026-05-20 | 关联养殖资讯列表文档(视图 cover_file_url / content_file_url) |
| 2026-05-20 | 养殖资讯列表接口补充分页说明 |
| 2026-05-20 | 表增 module_id、visible;/tree 仅 visible=1 且支持 moduleId;/children 不按 visible 过滤 |
| 2026-05-20 | 关联畜牧资源列表文档(v_livestock_resource、/app/livestockResource/list) |