-
Notifications
You must be signed in to change notification settings - Fork 0
[✨feat] CompanyCategory 구현 #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/#48
Are you sure you want to change the base?
Conversation
Internship 도메인에서 기업 유형을 나타내는 CompanyCategory Enum을 정의했습니다. categoryId와 description 필드를 통해 의미 있는 도메인 값을 표현하며, 정적 팩토리 메서드 from을 통해 유효한 ID 기반 조회를 지원합니다. 유효하지 않은 값에 대해서는 InternshipException을 발생시킵니다.
CompanyCategory Enum의 유효하지 않은 입력 처리를 위해 INVALID_COMPANY_CATEGORY 에러 코드를 정의했습니다. 도메인 예외 처리 일관성을 유지하기 위한 목적입니다.
유효한 categoryId에 대해 올바른 CompanyCategory가 반환되는지 검증하고, 잘못된 categoryId 입력 시 InternshipException이 발생하는지를 확인하는 파라미터 기반 테스트를 추가했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces the CompanyCategory enum to represent different types of companies in the internship domain by defining meaningful fields (categoryId, description) and a static factory method to map integer values to enum instances. It also adds a corresponding error code to InternshipErrorCode and provides comprehensive tests for both valid mappings and exception handling.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/main/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/CompanyCategory.kt | Added the CompanyCategory enum with a companion object to map an integer to an enum value, throwing an exception for invalid input. |
src/main/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/InternshipErrorCode.kt | Added the INVALID_COMPANY_CATEGORY entry to manage error codes. |
src/test/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/CompanyCategoryTest.kt | Created tests that verify both successful enum mapping and proper exception handling for invalid inputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
항상 테스트코드까지 꼼꼼하게 작성해 주셔서 많이 배워가는 것 같아요~ 수고하셨어요!
LARGE_AND_MEDIUM_COMPANIES(0, "대기업/중견기업"), | ||
SMALL_COMPANIES(1, "중소기업"), | ||
PUBLIC_INSTITUTIONS(2, "공공기관/공기업"), | ||
FOREIGN_COMPANIES(3, "외국계기업"), | ||
STARTUPS(4, "스타트업"), | ||
NON_PROFIT_ORGANIZATIONS(5, "비영리단체/재단"), | ||
OTHERS(6, "기타"), | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 부분은 제가 알기로 공고상세페이지 화면에서 기업의 종류를 나타내는 부분인 것 같아요!
이는 공고 더미를 쌓을 때 적용되는 부분이에요..!
그래서 클라이언트 통신과는 상관이 없는 걸로 알고 있는데 맞을까요..?! (다른 서버통신은 문자열로 하도록 바뀐 걸로 압니당)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
따라서 categoryId
는 서버 안에서만 사용될 것으로 보이는데 정수로 기업을 구분하는 것이 위험하다고 판단이 된다면 description
으로 분류하는 것도 괜찮을 것 같다는 생각입니다..!
📄 Work Description
CompanyCategory
Enum을 정의했습니다.categoryId
와description
을 갖고, 정적 팩터리 메서드from(Int)
를 통해 매핑됩니다.InternshipException
과INVALID_COMPANY_CATEGORY
를 활용한 예외 처리를 적용했습니다.InternshipErrorCode
에 항목을 추가해 관리합니다.💭 Thoughts
기존 자바 Enum에서 코틀린 Enum으로 이관하면서, 도메인에 맞는 의미 있는 필드명(
categoryId
,description
)으로 개선했습니다.매핑 메서드는 하나의
from(Int)
로 통일하고, 문자열 기반 매핑은 제거하여 책임을 명확히 했습니다.테스트는 파라미터 기반으로 구성해 가독성과 커버리지를 동시에 확보했습니다.
다만 현재는 레거시 시스템과의 호환을 위해
0
,1
,2
처럼 숫자 기반의 식별자를 클라이언트에서 그대로 받고 있습니다.이 구조는 잠깐 보기엔 단순하고 편해 보일 수 있지만, 실제로는 꽤 위험한 방식이에요.
예를 들어,
0 = 대기업
,1 = 중소기업
으로 의미가 정해져 있다가 새로운 항목이 추가되거나 순서를 바꾸게 되면클라이언트와 서버 모두에서 큰 혼란이 생길 수 있어요.
숫자 값은 그 자체로는 아무 의미도 없기 때문에, 나중에 코드를 보는 사람에게도 의도를 전달하기 어렵고요.
처음 자바 + 스프링 기반으로 프로젝트를 시작할 때도 이런 숫자 기반 매핑보다는
명확한 이름이나 문자열 값(description 등)을 기반으로 통신하자고 강조했던 기억이 납니다.
지금은 마이그레이션 과정이라 기존 구조를 따르되,
앞으로는 클라이언트와의 통신에서도 의미 있는 값을 주고받는 방향으로 리팩터링하는 것이 더 안전하고 유지보수에 유리하다고 다시 한번 강조하고 싶어요. 🙏
✅ Testing Result
🗂 Related Issue