@CrossOrigin
@RequestMapping(value = "/{id}/users/{userId}", method = RequestMethod.POST)
@ApiOperation(value = "Create a relation between user and organization")
@ApiResponses(value = { @ApiResponse(code = 404, message = "ID of organization or user invalid") })
// TODO: Replace explicit user{id} with AuthN user id.
public ResponseEntity<?> createUserOrganization(
@ApiParam(value = "ID of user", required = true) @PathVariable("userId") Integer userId,
@ApiParam(value = "ID of organization", required = true) @PathVariable("id") Integer organizationId) {
System.out.println("************** OrganizationController.createUserOrganization()"
+ ": userId=" + userId
+ "; organizationId=" + organizationId
+ " **************");
try {
organizationService.saveUserOrganization(userId, organizationId);
URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}/users/{userId}")
.buildAndExpand(organizationId, userId).toUri();
return ResponseEntity.created(location).build();
} catch (NullPointerException | UserOrganizationException e) {
throw new NotFoundException("ID of organization or user invalid, or relationship already exist");
}
}
OrganizationController.java 文件源码
java
阅读 43
收藏 0
点赞 0
评论 0
项目:c4sg-services
作者:
评论列表
文章目录