Skip to content

Feat/#198 univ data search#200

Open
yeongsinkeem wants to merge 2 commits intodev_tempfrom
feat/#198-univ-data-search
Open

Feat/#198 univ data search#200
yeongsinkeem wants to merge 2 commits intodev_tempfrom
feat/#198-univ-data-search

Conversation

@yeongsinkeem
Copy link
Collaborator

@yeongsinkeem yeongsinkeem commented Feb 26, 2026

이슈 번호

#198

작업 내용

  • 동아리 생성 시 대학 데이터 검색 기능 구현(초성으로 검색해도 가능하도록)
  • School -> University로 변경
  • 동아리/소모임 생성 시 응답 데이터 반환(학교명, 동아리 명 등)

@gemini-code-assist
Copy link

Summary of Changes

Hello @yeongsinkeem, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 시스템의 학교 관련 데이터 모델을 'School'에서 'University'로 전면 개편하고, 지역 정보를 위한 'Region' 엔티티를 도입합니다. 이를 통해 공공데이터 기반의 대학 정보 초기화 및 관리 기능을 강화하며, 사용자에게 대학 이름 및 초성 검색 기능을 제공하여 조직 생성 및 검색 경험을 개선합니다. 전반적인 데이터 구조의 현대화와 기능 확장을 목표로 합니다.

Highlights

  • 데이터 모델 마이그레이션: 기존의 'School' 엔티티와 관련 로직을 'University' 엔티티로 전환하고, 지역 정보를 관리하는 'Region' 엔티티를 새로 도입했습니다.
  • 대학 데이터 초기화 및 관리: 공공데이터를 활용하여 대량의 대학 데이터를 초기화하는 로직을 구현했으며, 'BranchType' enum을 통해 본교/분교 구분을 명확히 했습니다.
  • 한글 초성 검색 기능: 대학 이름 검색 시 한글 초성 검색을 지원하는 기능을 추가하여 사용자 편의성을 높였습니다.
  • 조직 생성 로직 업데이트: 조직(동아리/소모임) 생성 시 'University' 엔티티를 사용하도록 관련 컨트롤러, DTO, 서비스 및 리포지토리 로직을 업데이트했습니다.
Changelog
  • src/main/java/org/example/tackit/config/CommonDataInitializer.java
    • 기존의 관리자 및 단일 학교 초기화 로직이 제거되었습니다.
  • src/main/java/org/example/tackit/config/DataInitializer.java
    • 새로운 데이터 초기화 클래스가 추가되었습니다.
    • 지역 데이터, 대학 데이터, 관리자 계정 초기화를 순차적으로 수행합니다.
    • JSON 파일을 통해 대학 데이터를 로드하고, 대학원 데이터를 필터링하며, 초성 정보를 저장합니다.
  • src/main/java/org/example/tackit/domain/entity/Org/BranchType.java
    • 본교와 분교를 구분하는 새로운 enum이 추가되었습니다.
    • 설명(description)을 통해 enum 값을 찾을 수 있는 유틸리티 메서드가 포함되었습니다.
  • src/main/java/org/example/tackit/domain/entity/Org/Organization.java
    • 조직 엔티티의 'school' 필드가 'university' 필드로 변경되었고, 조인 컬럼 이름도 'university_id'로 업데이트되었습니다.
  • src/main/java/org/example/tackit/domain/entity/Org/Region.java
    • 지역 ID, 지역 이름, 시도 코드를 포함하는 새로운 'Region' 엔티티가 추가되었습니다.
  • src/main/java/org/example/tackit/domain/entity/Org/School.java
    • 기존의 'School' 엔티티가 제거되었습니다.
  • src/main/java/org/example/tackit/domain/entity/Org/SchoolType.java
    • 기존의 'SchoolType' enum이 제거되었습니다.
  • src/main/java/org/example/tackit/domain/entity/Org/University.java
    • 학교 정보를 나타내는 새로운 'University' 엔티티가 추가되었습니다.
    • 대학 이름, 초성, 본분교 타입, 지역, 주소 필드를 포함하며, 이름과 초성 검색을 위한 인덱스가 정의되었습니다.
  • src/main/java/org/example/tackit/domain/organization/controller/OrganizationController.java
    • 조직 생성 API의 응답 타입이 'OrgRespDto'로 변경되었습니다.
    • 인증 실패 시 응답 본문이 제거되고 HTTP 상태 코드만 반환하도록 수정되었습니다.
  • src/main/java/org/example/tackit/domain/organization/dto/req/OrgCreateReqDto.java
    • 조직 생성 요청 DTO에서 'schoolId' 필드가 'universityId'로 변경되었습니다.
    • 'toEntity' 메서드가 'School' 대신 'University' 객체를 받도록 업데이트되었습니다.
  • src/main/java/org/example/tackit/domain/organization/dto/resp/OrgRespDto.java
    • 조직 생성 성공 시 반환될 응답 DTO가 정의되었습니다.
    • 조직 ID, 이름, 타입, 대학 이름, 생성일 필드를 포함하며, 엔티티로부터 DTO를 생성하는 'of' 메서드가 추가되었습니다.
  • src/main/java/org/example/tackit/domain/organization/repository/OrganizationRepository.java
    • 조직 중복 확인 메서드가 'School' 대신 'University' 엔티티를 사용하도록 변경되었습니다.
    • 존재 여부 확인을 위한 'existsByNameAndUniversityAndType', 'existsByNameAndType', 'existsById' 메서드가 추가되었습니다.
  • src/main/java/org/example/tackit/domain/organization/repository/SchoolRepository.java
    • 기존의 'SchoolRepository'가 제거되었습니다.
  • src/main/java/org/example/tackit/domain/organization/service/OrganizationService.java
    • 조직 생성 서비스 로직이 'University' 엔티티와 새로운 리포지토리를 사용하도록 업데이트되었습니다.
    • 중복 확인 로직이 'exists' 메서드를 활용하도록 변경되었고, 생성 후 'OrgRespDto'를 반환하도록 수정되었습니다.
  • src/main/java/org/example/tackit/domain/university/controller/UniversityController.java
    • 대학 검색 API를 제공하는 새로운 REST 컨트롤러가 추가되었습니다.
    • '/api/universities/search' 엔드포인트를 통해 검색어를 받아 대학 목록을 반환합니다.
  • src/main/java/org/example/tackit/domain/university/dto/UniversityRawDto.java
    • JSON 형식의 원시 대학 데이터를 파싱하기 위한 DTO가 추가되었습니다.
    • 'JsonProperty' 어노테이션을 사용하여 한글 필드명을 매핑합니다.
  • src/main/java/org/example/tackit/domain/university/dto/UniversityRespDto.java
    • 대학 검색 결과 응답을 위한 DTO가 추가되었습니다.
    • 대학 ID, 이름, 지역 이름을 포함하며, 엔티티로부터 DTO를 생성하는 'from' 메서드가 제공됩니다.
  • src/main/java/org/example/tackit/domain/university/repository/RegionRepository.java
    • 'Region' 엔티티를 위한 JPA 리포지토리가 추가되었습니다.
    • 시도 코드로 지역 정보를 찾는 메서드가 포함되었습니다.
  • src/main/java/org/example/tackit/domain/university/repository/UniversityRepository.java
    • 'University' 엔티티를 위한 JPA 리포지토리가 추가되었습니다.
    • 대학 이름 및 초성으로 검색하는 메서드와 존재 여부를 확인하는 메서드가 포함되었습니다.
  • src/main/java/org/example/tackit/domain/university/service/UniversityService.java
    • 대학 검색 비즈니스 로직을 처리하는 새로운 서비스가 추가되었습니다.
    • 검색어가 초성인지 여부를 판단하여 적절한 검색 메서드를 호출하고, 결과를 'UniversityRespDto' 목록으로 반환합니다.
  • src/main/java/org/example/tackit/global/utils/HangulUtils.java
    • 한글 문자열에서 초성만 추출하는 유틸리티 클래스가 추가되었습니다.
Activity
  • 이 Pull Request에 대한 특정 활동은 제공되지 않았습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 기존 School 엔티티를 UniversityRegion 엔티티로 재구성하고, 대학 데이터를 초기화하며, 대학 검색 기능을 추가합니다. 또한, 조직 생성 로직을 업데이트하여 새로운 University 엔티티를 사용하고, 응답 DTO를 도입하여 API 응답을 개선했습니다. 전반적으로 잘 구성된 변경 사항이지만, 예외 처리의 일관성을 개선할 여지가 있습니다.


// commandLineRunner의 run 메서드는 String... args로 유지 (String[] args와 유사) -> 스프링 부트 공식 문서 참고
// args를 꼭 배열로 넘겨야 하는 건 아니고 가변적으로 받을 수 있다는 의도를 나타냄
@Override

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

여기서 RuntimeException을 사용하는 대신, OrganizationService에서 사용되는 MemberNotFoundException과 같이 더 구체적인 예외를 사용하거나, ErrorCode를 포함하는 커스텀 예외를 사용하는 것이 좋습니다. 이는 애플리케이션 전반의 예외 처리 일관성을 높이고 클라이언트가 오류를 더 쉽게 이해할 수 있도록 돕습니다.

            .orElseThrow(() -> new MemberNotFoundException(ErrorCode.MEMBER_NOT_FOUND));

initializeRegions();

// 2. University 대학 데이터
initializeUniversities();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

마찬가지로, RuntimeException 대신 UniversityNotFoundException과 같이 더 구체적인 예외를 정의하고 사용하는 것이 좋습니다. 이는 오류의 의미를 명확히 하고 디버깅을 용이하게 합니다.

            .orElseThrow(() -> new UniversityNotFoundException(ErrorCode.UNIVERSITY_NOT_FOUND)); // 예시


// 3. 테스트/관리자 데이터
initializeAdmin();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이곳에서도 RuntimeException 대신 DuplicateOrganizationException과 같이 비즈니스 로직에 맞는 구체적인 예외를 사용하는 것이 좋습니다. 이는 예외 처리 계층을 명확히 하고, 클라이언트에게 더 의미 있는 오류 메시지를 전달할 수 있게 합니다.

            throw new DuplicateOrganizationException(ErrorCode.DUPLICATE_CLUB_NAME_IN_UNIVERSITY); // 예시

private void initializeRegions() {
if (regionRepository.count() == 0) {
List<Region> regions = new ArrayList<>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 경우에도 RuntimeException 대신 DuplicateOrganizationException과 같은 구체적인 예외를 사용하는 것이 좋습니다. 이는 오류 유형을 명확히 하고, 애플리케이션의 견고성을 높입니다.

            throw new DuplicateOrganizationException(ErrorCode.DUPLICATE_COMMUNITY_NAME); // 예시

Comment on lines +48 to +49
if (organizationRepository.existsByNameAndUniversityAndType(dto.getOrgName(), university, OrgType.CLUB)) {
throw new RuntimeException("해당 학교에 이미 동일한 이름의 동아리가 존재합니다.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

여기서도 RuntimeException 대신 DuplicateOrganizationException과 같이 비즈니스 로직에 특화된 예외를 사용하는 것이 좋습니다. 이는 오류 처리 로직을 더 세분화하고, 클라이언트에게 더 정확한 오류 정보를 제공할 수 있게 합니다.

        throw new DuplicateOrganizationException(ErrorCode.DUPLICATE_CLUB_NAME_IN_UNIVERSITY); // 예시

Comment on lines +53 to +54
if (organizationRepository.existsByNameAndType(dto.getOrgName(), OrgType.COMMUNITY)) {
throw new RuntimeException("이미 동일한 이름의 소모임이 존재합니다.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 경우에도 RuntimeException 대신 DuplicateOrganizationException과 같은 구체적인 예외를 사용하는 것이 좋습니다. 이는 오류의 원인을 명확히 하고, 향후 유지보수 및 확장을 용이하게 합니다.

        throw new DuplicateOrganizationException(ErrorCode.DUPLICATE_COMMUNITY_NAME); // 예시

Copy link
Collaborator

@tishakong tishakong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

내용 확인했습니다~ 로직에서 이해 안되는 부분은 없습니다.
제미나이 리뷰들도 대부분 응답값 반환 형식 통일 관련 멘트인데, 지금 수정하실 여력이 있으시면 수정하시고, 아니면 머지해도 될 것 같습니다!

private Long orgId;
private String orgName;
private String orgType;
private String universityName; // CLUB일 때만 값이 있고, COMMUNITY면 "연합/소모임" 등으로 표시
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COMMUNITY면 "연합/소모임" 등으로 표시한다는 게, universityName 의 값으로 연합/소모임을 반환한다는 걸까요? 아래 코드를 보니까 null을 반환하는 거 같긴 한데 null 반환이 맞다면 주석이 조금 모호해서 수정하면 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정되어야 할 것 같습니다 !
연합 동아리라면
regionId = 0,
universityName = "연합" 이렇게 되는 게 깔끔할 것 같습니다 !
확인 감사합니다 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants