Skip to content

WEB - 관리자 통계 API 추가 및 프론트와 연결#337

Merged
ongsttt52 merged 20 commits intodevelopfrom
feat/admin-statistic-api
May 13, 2025
Merged

WEB - 관리자 통계 API 추가 및 프론트와 연결#337
ongsttt52 merged 20 commits intodevelopfrom
feat/admin-statistic-api

Conversation

@ongsttt52
Copy link
Collaborator

#️⃣연관된 이슈

#315

📝작업 내용

관리자 통계 API 추가 및 프론트와 연결했습니다.

프론트도 PR 올렸습니다

@ongsttt52 ongsttt52 changed the base branch from main to develop May 12, 2025 08:03
Copy link
Collaborator

@Tojaman Tojaman left a comment

Choose a reason for hiding this comment

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

고생하셨습니다.

int month,
int driveCount
) {
// public static List<AdminBizMonthlyResponse> toDto(List<MonthlyStatisticEntity> monthlyStatisticEntities) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

p1
사용하지 않는 주석은 지워주시면 감사하겠습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

p1 사용하지 않는 주석은 지워주시면 감사하겠습니다!

수정했습니다


if (response == null)
return new AdminBizStatisticResponse(0, 0, 0);
else
Copy link
Collaborator

Choose a reason for hiding this comment

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

p5
else는 없는 게 가독성이 더 좋을 것 같습니다!
참고만 해주세요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

p5 else는 없는 게 가독성이 더 좋을 것 같습니다! 참고만 해주세요!

수정했습니다

int month,
int driveCount
) {
// public static List<AdminBizMonthlyResponse> toDto(List<MonthlyStatisticEntity> monthlyStatisticEntities) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

필요 없는 코드면 지워도 좋을 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

필요 없는 코드면 지워도 좋을 것 같습니다!

수정했습니다

.toResponse(carCountWithBizName, carTypeCount, operationRateWithBizName, nonOperatedCarWithBizName));
}

private Long mapToBizId(String bizName) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 함수는 bizProvider에 있어도 좋을것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

해당 함수는 bizProvider에 있어도 좋을것 같습니다.

수정했습니다

) {
Long bizId = mapToBizId(adminStatisticRequest.bizName());

return ApiResponse.success(HourlyGraphResponse
Copy link
Collaborator

Choose a reason for hiding this comment

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

	return ApiResponse.success(HourlyGraphResponse
		.toResultList(adminStatisticProvider
			.getAdminBizHourlyDriveCount(bizId, adminStatisticRequest.selectedDate())));

코드를 파악하기 조금 어려운 것 같아요
개인 취향이지만, 저는 이런식으로 작성합니다

	return ApiResponse.success(
                  HourlyGraphResponse.toResultList(
                    adminStatisticProvider.getAdminBizHourlyDriveCount(
                       bizId, adminStatisticRequest.selectedDate()
                     )
                   )
                );

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

	return ApiResponse.success(HourlyGraphResponse
		.toResultList(adminStatisticProvider
			.getAdminBizHourlyDriveCount(bizId, adminStatisticRequest.selectedDate())));

코드를 파악하기 조금 어려운 것 같아요 개인 취향이지만, 저는 이런식으로 작성합니다

	return ApiResponse.success(
                  HourlyGraphResponse.toResultList(
                    adminStatisticProvider.getAdminBizHourlyDriveCount(
                       bizId, adminStatisticRequest.selectedDate()
                     )
                   )
                );

좋은 방법인 것 같습니다 파악하기도 좋고 실수도 적어지겠네요

List<AdminBizMonthlyResponse> response = adminStatisticRepository.getTotalDriveCountInOneYear(bizId,
selectedDate);

if (response == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

값이 없다면
return new AdminBizStatisticResponse(0, 0, 0);
위 코드처럼 기본값을 내려주거나, 예외를 던져주는게 프론트측에서 처리하는 데 일관성이 생길 것 같은데, 어떻게 생각하시나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

값이 없다면 return new AdminBizStatisticResponse(0, 0, 0); 위 코드처럼 기본값을 내려주거나, 예외를 던져주는게 프론트측에서 처리하는 데 일관성이 생길 것 같은데, 어떻게 생각하시나요?

프론트에서는 map으로 배열을 처리하도록 되어있어서 List.of()로 빈 배열을 내려도 별다른 문제가 생기지 않는걸로 알고 있습니다
빈 배열과 0,0,0 기본값 모두 그래프에서는 동일하게 표현되어서 이대로 유지해도 괜찮을 것 같습니다

Copy link
Collaborator

Choose a reason for hiding this comment

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

배열이라 빈값이 가도 확실히 괜찮겠네요
좋습니다!

))
.from(monthlyStatisticEntity)
.where(
(bizId != null
Copy link
Collaborator

Choose a reason for hiding this comment

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

bizId가 null이면 자연스럽게 True 처리되는거로 알고있는데, 같이 테스트해보고 검증하면 좋을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bizId가 null이면 자연스럽게 True 처리되는거로 알고있는데, 같이 테스트해보고 검증하면 좋을 것 같습니다.

null일 경우 500을 뱉는걸로 기억하고 있는데 내일 한 번 다시 테스트해보겠습니다

return bizDomainRepository.existsByBizRegNum(bizRegNum);
}

public BizEntity getBizByBizName(String bizName) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Long GetBizIdByBizName으로 처리해도 좋을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Long GetBizIdByBizName으로 처리해도 좋을 것 같습니다.

위에서 mapToBizId가 provider로 넘어가면서 사용하지 않는 메서드가 되었습니다. 이 메서드는 삭제 후 올리겠습니다

@PostMapping("/create-daily")
public String createDaily() {
schedulerService.monthlyStatistic(LocalDate.now().minusDays(1));
return "ok";
Copy link
Collaborator

Choose a reason for hiding this comment

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

공통 응답 객체를 사용 안하신 이유가 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

공통 응답 객체를 사용 안하신 이유가 있나요?

테스트용 메서드였는데 같이 딸려 올라간 것 같습니다 수정해서 올렸습니다

@ongsttt52 ongsttt52 force-pushed the feat/admin-statistic-api branch from 59593a0 to 1824bcd Compare May 13, 2025 02:07
@ongsttt52 ongsttt52 merged commit dac8abc into develop May 13, 2025
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.

4 participants