Skip to content

Commit

Permalink
Refactor ApiGalleryController
Browse files Browse the repository at this point in the history
  • Loading branch information
johnniang committed Feb 20, 2019
1 parent 87dddd8 commit 2f40994
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ public class ApiGalleryController {
* @return JsonResult
*/
@GetMapping
public JsonResult galleries() {
final List<Gallery> galleries = galleryService.listAll();
if (null != galleries && galleries.size() > 0) {
return new JsonResult(ResponseStatusEnum.SUCCESS.getCode(), ResponseStatusEnum.SUCCESS.getMsg(), galleries);
} else {
return new JsonResult(ResponseStatusEnum.EMPTY.getCode(), ResponseStatusEnum.EMPTY.getMsg());
}
public List<Gallery> galleries() {
return galleryService.listAll();
}

/**
Expand Down Expand Up @@ -89,12 +84,7 @@ public JsonResult galleries() {
* @return JsonResult
*/
@GetMapping(value = "/{id}")
public JsonResult galleries(@PathVariable("id") Long id) {
final Optional<Gallery> gallery = galleryService.fetchById(id);
if (gallery.isPresent()) {
return new JsonResult(ResponseStatusEnum.SUCCESS.getCode(), ResponseStatusEnum.SUCCESS.getMsg(), gallery.get());
} else {
return new JsonResult(ResponseStatusEnum.NOTFOUND.getCode(), ResponseStatusEnum.NOTFOUND.getMsg());
}
public Gallery galleries(@PathVariable("id") Long id) {
return galleryService.getById(id);
}
}

0 comments on commit 2f40994

Please sign in to comment.