Skip to content

Conversation

@jucheonsu
Copy link
Contributor

@jucheonsu jucheonsu commented Aug 22, 2025

Issue 📌


🏛️ Entity

  • ActivityHistoryActivity

  • Section


🔗Repository

  • ActivityHistoryRepositoryActivityRepository

  • SectionRepository


📄 DTO

  • ActivityHistoryRequestDtoActivityRequestDto

  • ActivityHistoryResponseDtoActivityResponseDto

  • GroupedActivityHistoryDtoActivityItemDto SectionItemDto


🧠 Service

  • ActivityHistoryServiceActivityService

  • ActivityHistoryServiceImplActivityServiceImpl


🌐 Controller

  • AdminActivityHistoryControllerAdminActivityController

  • ActivityHistoryControllerActivityController


✅ Test

  • ActivityHistoryServiceTestActivityServiceTest

🔨 Setting

  • application.yml
server:
  port: 8080 // 8081에서 변경
spring:
  application:
    profiles:  // 삭제
      active: credentials  // 삭제

⚙️ 주요 변경 사항

  • 날짜 필드 추가

    • activityDate
  • 활동 목록 정렬 (오름차순)

    • 연도 → 섹션 ID → 활동 날짜
  • 엔티티 분리

    • ActivityActivity Section

📷 Image


  • Postman


포스트맨 생성 --- 포스트맨 조회 --- 포스트맨 수정 --- 포스트맨 삭제
  • IntelliJ


수정 테스트 성공 활동 테이블 섹션 테이블

@jucheonsu jucheonsu self-assigned this Aug 22, 2025
@jucheonsu jucheonsu linked an issue Aug 22, 2025 that may be closed by this pull request
@jucheonsu jucheonsu changed the title [feat] 활동 연혁 CRUD 기능 구현 및 테스트 추가 [feat] 활동 연혁 CRUD 기능 구현 및 테스트 Aug 22, 2025
@jucheonsu jucheonsu force-pushed the feat/DASOMBE-15-activity-history branch from 38e795b to 181ed4e Compare August 22, 2025 15:43
@jucheonsu jucheonsu changed the title [feat] 활동 연혁 CRUD 기능 구현 및 테스트 [feat] 활동 연혁 CRUD 기능 구현 및 테스트 (DASOMBE-15) Aug 22, 2025
@jucheonsu jucheonsu changed the title [feat] 활동 연혁 CRUD 기능 구현 및 테스트 (DASOMBE-15) [feat] 활동 연혁 CRUD 기능 구현 및 테스트 Aug 22, 2025
@jucheonsu jucheonsu changed the base branch from main to dev August 23, 2025 04:22
@@ -1,8 +1,10 @@
server:
port: 8080
port: 8081
Copy link
Member

Choose a reason for hiding this comment

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

포트번호 8080로 원복해주세요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 확인헀습니다

Comment on lines 6 to 7
profiles:
active: credentials # 추가 (제외시키면 application-credentials.yml 못 찾음)
Copy link
Member

Choose a reason for hiding this comment

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

프로파일 설정은 실행명령으로 설정해주세요

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 확인했습니다

Comment on lines 18 to 20
private String section;
private String title;
private String award;
Copy link
Member

Choose a reason for hiding this comment

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

ActivityHistoryRequestDto에 필드 크기 제약조건을 설정했다면 그를 저장하는 속성의 크기도 그에 맞게 설정해주세요.
length 설정이 없으면 기본적으로 길이가 255로 설정되기 때문에 의도치 않게 길이가 긴 항목도 저장될 수 있습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 확인했습니다 수정하겠습니다

Comment on lines 23 to 32
@Getter @Builder
@Schema(name = "SectionItemDto", description = "섹션별 활동 목록")
public static class SectionItemDto {

@Schema(description = "활동 섹션", example = "교내 경진대회")
private final String section;

@Schema(description = "활동 목록")
private final List<ActivityItemDto> activities;
}
Copy link
Member

Choose a reason for hiding this comment

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

이너 클래스 대신 외부로 분리해주세요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 확인했습니다 수정하겠습니다

Comment on lines 34 to 53
@Getter @Builder
@Schema(name = "ActivityItemDto", description = "개별 활동 목록")
public static class ActivityItemDto {

@Schema(description = "활동 연혁 고유 ID", example = "1")
private final Long id;

@Schema(description = "활동 제목", example = "컴퓨터 공학부 경진대회")
private final String title;

@Schema(description = "수상 내역", example = "최우수상")
private final String award;

public static ActivityItemDto toDto(ActivityHistory history) {
return ActivityItemDto.builder()
.id(history.getId()).title(history.getTitle())
.award(history.getAward())
.build();
}
}
Copy link
Member

Choose a reason for hiding this comment

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

이너 클래스 대신 외부로 분리해주세요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 확인했습니다 수정하겠습니다

Comment on lines 26 to 27
List<ActivityHistory> histories = historyRepository.findAll();
return GroupedActivityHistoryDto.groupedActivityHistoryDto(histories);
Copy link
Member

Choose a reason for hiding this comment

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

조회와 반환을 한 줄로 합쳐서 정리해주세요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 확인했습니다 수정하겠습니다

}

@Override
public ActivityHistoryResponseDto createHistory(ActivityHistoryRequestDto requestDto) {
Copy link
Member

Choose a reason for hiding this comment

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

생성 메소드에서 반환값이 필수가 아니라면 리턴 타입을 void 로 설정해도 무방할 것 같습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 수정하겠습니다

}

@Override
public ActivityHistoryResponseDto updateHistory(Long id, ActivityHistoryRequestDto requestDto) {
Copy link
Member

Choose a reason for hiding this comment

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

갱신 메소드에서 반환값이 필수가 아니라면 리턴 타입을 void 로 설정해도 무방할 것 같습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 수정하겠습니다

Comment on lines 32 to 33
ActivityHistory history = requestDto.toEntity();
ActivityHistory savedHistory = historyRepository.save(history);
Copy link
Member

Choose a reason for hiding this comment

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

dto 파싱과 저장을 한 줄로 합쳐서 정리해주세요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 수정하겠습니다

Comment on lines 34 to 41
public ActivityHistory toEntity() {
return ActivityHistory.builder()
.year(this.year)
.section(this.section)
.title(this.title)
.award(this.award)
.build();
}
Copy link
Member

Choose a reason for hiding this comment

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

ActivieyHistory의 팩토리 메소드를 ActivieyHistory 클래스 내부로 옮기고 Service 계층에서 Dto -> Entity 로 변환할 때 ActivieyHistory.create() 를 호출해서 객체 인스턴스를 생성/초기화 하도록 구성해주세요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 수정하겠습니다

@ysw789
Copy link
Member

ysw789 commented Aug 24, 2025

작업 고생하셨습니다~ 추가적인 피드백 드리겠습니다!

  1. GroupedActivityHistoryDto 클래스의 경우를 보시다시피 여러 DTO를 중첩 초기화하는 과정에서 코드가 장황해질 수 있습니다.
    이를 개선하기 위해 각 DTO 클래스 내부에 팩토리 메소드를 만들어두고, 루트 DTO에서는 해당 메소드를 호출해 초기화하도록 구성하는 것이 좋습니다. 이렇게 하면 객체 생성 로직이 DTO 내부로 캡슐화되어 외부에서는 메소드 호출만으로 객체를 만들 수 있고, 클래스 구조 변경에도 영향이 최소화됩니다. 이 방법은 객체지향 설계의 기본적인 원칙(캡슐화, 책임 분리)에도 부합하는 방법입니다!

  2. 활동 연혁에 대한 정렬 기준이 필요하다면 ActivieyHistory 엔티티에 sortOrder(정렬 기준) 필드를 추가해 프론트엔드에서 해당 값을 기준으로 정렬하도록 제공해줘도 좋을 것 같습니다. 이 부분은 회의 때 논의해보세용

@jucheonsu
Copy link
Contributor Author

상세한 피드백 감사합니다! 빠르게 고쳐서 다시 올리겠습니다!

@jucheonsu jucheonsu force-pushed the feat/DASOMBE-15-activity-history branch from c4ea801 to a3827a0 Compare August 26, 2025 05:38
@jucheonsu jucheonsu force-pushed the feat/DASOMBE-15-activity-history branch from a3827a0 to 87a1187 Compare August 26, 2025 06:06
@jucheonsu jucheonsu closed this Aug 26, 2025
@jucheonsu jucheonsu deleted the feat/DASOMBE-15-activity-history branch August 26, 2025 06:07
@jucheonsu jucheonsu restored the feat/DASOMBE-15-activity-history branch August 26, 2025 06:10
@jucheonsu jucheonsu deleted the feat/DASOMBE-15-activity-history branch August 26, 2025 06:11
@jucheonsu jucheonsu restored the feat/DASOMBE-15-activity-history branch August 26, 2025 06:12
@jucheonsu jucheonsu reopened this Aug 26, 2025
@jucheonsu jucheonsu requested a review from ysw789 August 26, 2025 07:00
@jucheonsu
Copy link
Contributor Author

수정 완료했습니다 확인 부탁드리겠습니다!

@dohy-eon
Copy link
Member

확인했습니다 @jucheonsu

@jucheonsu
Copy link
Contributor Author

네 감사합니다

@jucheonsu jucheonsu merged commit adf631c into dev Aug 26, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 활동 연혁 API 생성

5 participants