Create menu get api for menu.

pull/146/head
ruibaby 2019-04-26 00:29:25 +08:00
parent d7aebebf18
commit 473f17c257
3 changed files with 32 additions and 2 deletions

View File

@ -44,6 +44,18 @@ public class MenuController {
return menuService.listAsTree(sort);
}
/**
* Get menu by menuId.
*
* @param menuId menuId
* @return MenuDTO
*/
@GetMapping("{menuId:\\d+}")
@ApiOperation("Get menu detail by id")
public MenuDTO getBy(@PathVariable("menuId") Integer menuId) {
return new MenuDTO().convertFrom(menuService.getById(menuId));
}
@PostMapping
@ApiOperation("Creates a menu")
public MenuDTO createBy(@RequestBody @Valid MenuParam menuParam) {

View File

@ -75,7 +75,21 @@ public class PhotoController {
}
@PostMapping
public Photo createBy(@Valid @RequestBody PhotoParam photoParam) {
return photoService.createBy(photoParam);
public PhotoDTO createBy(@Valid @RequestBody PhotoParam photoParam) {
return new PhotoDTO().convertFrom(photoService.createBy(photoParam));
}
@PutMapping("{photoId:\\d+}")
@ApiOperation("Updates a photo")
public PhotoDTO updateBy(@PathVariable("photoId") Integer photoId,
@RequestBody @Valid PhotoParam photoParam) {
// Get the photo
Photo photo = photoService.getById(photoId);
// Update changed properties of the photo
photoParam.update(photo);
// Update menu in database
return new PhotoDTO().convertFrom(photoService.update(photo));
}
}

View File

@ -24,4 +24,8 @@ public class PhotoDTO implements OutputConverter<PhotoDTO, Photo> {
private String url;
private String team;
private String location;
private String description;
}