我尝试使用 JDL 创建多个菜单类别。在一个 CategoryItem 中有 parentID。
我已经创建了 JDL,例如:
microservice * with Category
entity CategoryItem{
name String required
}
relationship ManyToOne{
CategoryItem{parrent} to CategoryItem
}
service * with serviceClass
paginate CategoryItem with pagination
如果客户端调用一个方法findAll。我可以像这样返回 JSON 格式吗:
[
{
"id": 1,
"name": "car",
"CategoryItem": [
{
"id": 2,
"name": "red car"
},
{
"id": 3,
"name": "blue car"
}
]
},
{
"id": 4,
"name": "bike",
"CategoryItem": []
}
]