[241114 TIL] AI 검증 비즈니스 프로젝트
카테고리, 가게, 리뷰 CRUD API 구현
- 코드리뷰 수정사항 반영
- Soft Delete 수정
- 리뷰 CRUD 추가 기능 구현
코드리뷰 수정사항 반영
✔️ 카테고리 아이디 null 체크 부분 ➡️ 공백값도 같이 체크 가능하게 변경
- 수정 전
if (categoryId == null)
- 수정 후
if (!StringUtils.hasText(String.valueOf(categoryId)))
StringUtils.hasText 이용
내부 로직
public static boolean hasText(@Nullable String str) {
return str != null && !str.isEmpty() && containsText(str);
}
private static boolean containsText(CharSequence str) {
int strLen = str.length();
for(int i = 0; i < strLen; ++i) {
if (!Character.isWhitespace(str.charAt(i))) {
return true;
}
}
return false;
}
- str 이 null 인가
- str이 빈 문자열 ("")인가
- str이 공백으로만(whitespace) 이루어져 있는가

'[내일배움캠프] AI 를 활용한 백엔드 아카데미 심화 과정 > TIL' 카테고리의 다른 글
[Spring] Soft Delete 적용 - IsDeletedFalse 활용 (2) | 2024.11.18 |
---|---|
EC2 + Docker + Github Action 이용해서 자동 배포 (0) | 2024.11.15 |
[트러블슈팅] 중복된 값이 삽입 시 발생 오류 해결 (1) | 2024.11.13 |
[트러블슈팅] POSTMAN POST (0) | 2024.11.12 |
[Github] IntelliJ 에서 Git Branch 생성하고 Merge 하기 (0) | 2024.11.11 |