作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含 Products、Prices 和 PricedProducts 的简单应用程序。
当我请求 PricedProducts 列表时,我希望内联价格和产品。我用@RestResource(exported = false) 标记了我的价格存储库,因此对于这个存储库,它可以正常工作。但是,产品需要是独立实体(例如,我需要能够使用相同的产品构建多个 PricedProducts)。
我为 PricedProduct 创建了一个投影,将其添加为 excerptProjection,然后一个 GET 到/priceProducts 返回:
{
"_embedded": {
"pricedProducts": [
{
"price": {
"value": "100.50",
"currency": "EUR"
},
"product": {
"name": "Poatato",
"description": null,
"pictureUrl": null
},
"_links": {
"self": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1"
},
"pricedProduct": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1{?projection}",
"templated": true
},
"product": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1/product"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:4200/api/v1.0/pricedProducts"
},
"profile": {
"href": "http://localhost:4200/api/v1.0/profile/pricedProducts"
}
}
}
{
"_embedded": {
"pricedProducts": [
{
"price": {
"value": "100.50",
"currency": "EUR"
},
"product": {
"pictureUrl": null,
"description": null,
"name": "Potato",
"_links": {
"self": {
"href": "http://localhost:4200/api/v1.0/products/1{?projection}",
"templated": true
}
}
},
"_links": {
"self": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1"
},
"pricedProduct": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1{?projection}",
"templated": true
},
"product": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1/product"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:4200/api/v1.0/pricedProducts"
},
"profile": {
"href": "http://localhost:4200/api/v1.0/profile/pricedProducts"
}
}
}
{
"_embedded": {
"pricedProducts": [
{
"price": {
"value": "100.50",
"currency": "RON"
},
"product": {
"pictureUrl": null,
"description": null,
"name": "Potato",
"_links": {
"self": {
"href": "http://localhost:4200/api/v1.0/products/1
}
}
},
"_links": {
"self": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1"
},
"pricedProduct": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1{?projection}",
"templated": true
},
"product": {
"href": "http://localhost:4200/api/v1.0/pricedProducts/1/product"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:4200/api/v1.0/pricedProducts"
},
"profile": {
"href": "http://localhost:4200/api/v1.0/profile/pricedProducts"
}
}
}
最佳答案
我认为最简单、更正确的做法是使用子投影并在客户端解析自链接。
关于spring - 在 spring 数据休息中添加自链接到投影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37077137/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!