Skip to content

Commit

Permalink
add POST 添加属性值
Browse files Browse the repository at this point in the history
  • Loading branch information
na57 committed May 27, 2024
1 parent 396fa2b commit 6bc7ea9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "triples-api",
"version": "1.9.0",
"version": "1.10.0",
"description": "对triples进行操作的Restful API",
"main": "index.js",
"type": "module",
Expand All @@ -13,8 +13,8 @@
"cors": "^2.8.5",
"express": "^4.19.2",
"express-jwt": "^8.4.1",
"nagu-owl": "^1.11.4",
"nagu-owl-types": "^1.3.0",
"nagu-owl": "^1.11.5",
"nagu-owl-types": "^1.4.1",
"nagu-triples": "^2.0.2"
}
}
22 changes: 21 additions & 1 deletion src/rdf/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,35 @@ const getPropertyValues = async (req, res) => {
const { piri } = req.params;
const resource = res.resource as IRdfsResource;
const vs = await resource.getPropertyValues(piri);
console.log('vs::', vs);
const data = await Promise.all(vs.map(v => v.getAnnotations()));
res.json({
data,
});
}
const setPropertyValue = async (req, res) => {
const { piri } = req.params;
const { value } = req.body;
const resource = res.resource as IRdfsResource;
try {
const data = await resource.setPropertyValue(piri, value);
res.json({
data,
});
} catch (error) {
res.status(500).json({
error,
});
}
}


router.get('/:iri', getOrCreateResource, getAnnotations);
router.put('/:iri', getOrCreateResource, setAnnotations);
router.post('/:iri', getOrCreateResource, setAnnotations);
router.get('/:iri/property/:piri/value', getOrCreateResource, getPropertyValues);
/**
* 设置属性值
*/
router.post('/:iri/property/:piri', getOrCreateResource, setPropertyValue);

export default router;

0 comments on commit 6bc7ea9

Please sign in to comment.