Skip to content

Commit

Permalink
Merge pull request #14 from BCSDLab/hotfix/search_null
Browse files Browse the repository at this point in the history
handle exception if search query is null && fix typo on grant check
  • Loading branch information
knight7024 authored Feb 9, 2020
2 parents a569812 + f88e416 commit c8bee4e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ ResponseEntity deleteLostItemComment(@ApiParam(required = true) @PathVariable(va
@RequestMapping(value = "/lost/lostItems/grant/check", method = RequestMethod.POST)
public @ResponseBody
ResponseEntity checkGrantEditItem(@ApiParam(required = true) @RequestBody Map<String, Integer> lostItem_id) throws Exception {
if (lostItem_id == null || !lostItem_id.containsKey("article_id"))
if (lostItem_id == null || !lostItem_id.containsKey("lostItem_id"))
throw new PreconditionFailedException(new ErrorMessage("올바르지 않은 데이터입니다.", 0));

return new ResponseEntity<Map<String, Boolean>>(lostAndFoundService.checkGrantEditLostItem(lostItem_id.get("lostItem_id")), HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ ResponseEntity deleteItemComment(@ApiParam(required = true) @PathVariable(value
@RequestMapping(value = "/market/items/grant/check", method = RequestMethod.POST)
public @ResponseBody
ResponseEntity checkGrantEditItem(@ApiParam(required = true) @RequestBody Map<String, Integer> item_id) throws Exception {
if (item_id == null || !item_id.containsKey("article_id"))
if (item_id == null || !item_id.containsKey("item_id"))
throw new PreconditionFailedException(new ErrorMessage("올바르지 않은 데이터입니다.", 0));

return new ResponseEntity<Map<String, Boolean>>(marketPlaceService.checkGrantEditItem(item_id.get("item_id")), HttpStatus.OK);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/koreatech/in/service/SearchServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import koreatech.in.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -27,7 +28,7 @@ public class SearchServiceImpl implements SearchService {
private SearchMapper searchMapper;

public Map<String, Object> searchShop(SearchCriteria searchCriteria) throws Exception {
if (searchCriteria.getQuery().isEmpty())
if (!StringUtils.hasText(searchCriteria.getQuery()))
throw new PreconditionFailedException(new ErrorMessage("공백으로는 검색할 수 없습니다.", 0));

Map<String, Object> map = new HashMap<>();
Expand Down Expand Up @@ -81,7 +82,7 @@ public Map<String, Object> searchShop(SearchCriteria searchCriteria) throws Exce
}

public Map<String, Object> searchCommunity(SearchCriteria searchCriteria) throws Exception {
if (searchCriteria.getQuery().isEmpty())
if (!StringUtils.hasText(searchCriteria.getQuery()))
throw new PreconditionFailedException(new ErrorMessage("공백으로는 검색할 수 없습니다.", 0));

Map<String, Object> map = new HashMap<>();
Expand Down

0 comments on commit c8bee4e

Please sign in to comment.