PostMapping ⁇ PutMapping ⁇
PostMapping - 일반적으로 새로운 리소스를 생성할 때 + 멱등성 X
PutMapping - 일반적으로 업데이트할 때 사용됨 + 멱등성 O
PostMapping는 요청 마다 새로운 리서스가 생성되고, PutMapping은 요청 마다 같은 리소스를 반환한다. public boolean matchFinished(Integer id) {
MatchPost matchPost = matchPostRepository.findById(id).orElseThrow(() ->
new IllegalArgumentException("존재하지않는 게시물입니다." + id));
if (matchPost.getMatchStatus().equals("매칭중")) {
log.info("매칭 마감으로 변경");
matchPost.setMatchStatus("매칭 마감");
} else if (matchPost.getMatchStatus().equals("매칭 마감")) {
log.info("매칭중으로 변경");
matchPost.setMatchStatus("매칭중");
}
matchPostRepository.save(matchPost);
return true;
}
public boolean matchFinished(Integer id) {
MatchPost matchPost = matchPostRepository.findById(id).orElseThrow(() ->
new IllegalArgumentException("존재하지않는 게시물입니다." + id));
String str = matchPost.getMatchStatus().equals("매칭중") ? "매칭 마감" : "매칭중";
log.info(str);
try {
matchPost.setMatchStatus(str);
matchPostRepository.save(matchPost);
return true;
} catch (Exception e) {
log.info(String.valueOf(e));
return false;
}
}
Api.js
InquiryApi.js
MatchApi.js
TeamApi.js
UserApi.js
+
@ResponseBody