Skip to content

[#48] FEAT: 파트너 일·월별 품목 통계 조회 API 구현, 'TradeItem'에 netPayloadWeight 컬럼 추가 및 관련사항 리팩토링, '파트너 통계 조회 API' 권한을 파트너와 관리자로 분리, Flyway 설정 및 문서/스킬 통합#75

Merged
Hwan0518 merged 6 commits intodevelopfrom
feature/stats/user
Jan 30, 2026

Conversation

@Hwan0518
Copy link
Contributor

Issue ✨

변경점 👍

  • 파트너 일·월별 품목 통계 조회 API 구현
  • 'TradeItem'에 netPayloadWeight 컬럼 추가 및 관련사항 리팩토링
  • '파트너 통계 조회 API' 권한을 파트너와 관리자로 분리
  • Flyway 설정 및 문서/스킬 통합

Copilot AI review requested due to automatic review settings January 30, 2026 08:37
Copy link

Copilot AI left a 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 implements comprehensive partner statistics APIs (daily, monthly, and total) for item-level data, adds a netPayloadWeight column to the TradeItem entity with proper database migration, refactors partner statistics access control to separate Admin and Partner permissions (removing Agency access), and establishes Flyway for database schema management with detailed documentation.

Changes:

  • Added netPayloadWeight column to trade_item table with safe Flyway migration (nullable → backfill → NOT NULL)
  • Implemented partner daily/monthly/total item statistics query APIs with QueryDSL
  • Refactored partner statistics API permissions: Admin can view any partner, Partners can only view their own statistics, Agency access removed
  • Set up Flyway with auto-repair for dev/test environments and comprehensive Korean/English documentation

Reviewed changes

Copilot reviewed 52 out of 68 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/resources/db/migration/V20260129__add_trade_item_net_payload_weight.sql Flyway migration adding netPayloadWeight column with safe backfill pattern
src/main/java/greenfirst/be/trade/adapter/out/persistence/entity/TradeItemEntity.java Added netPayloadWeight NOT NULL column to entity
src/main/java/greenfirst/be/trade/domain/command/create/CreateTradeItemCommand.java Added validation ensuring netPayloadWeight = weight - weightLoss
src/main/java/greenfirst/be/trade/domain/service/CarbonReductionCalculator.java Updated to use netPayloadWeight with fallback calculation
src/main/java/greenfirst/be/stats/application/service/*/ Implemented daily/monthly/total statistics services with permission checks
src/main/java/greenfirst/be/stats/adapter/out/persistence/querydsl/*/ QueryDSL repository implementations for statistics aggregation using netPayloadWeight
src/main/java/greenfirst/be/stats/adapter/in/web/controller/*/ REST controllers with separate Admin and Partner endpoints
src/main/java/greenfirst/be/global/config/flyway/FlywayConfig.java Auto-repair configuration for local/test/test-dev profiles only
src/main/resources/application.yml Added Flyway baseline-on-migrate and graceful shutdown configuration
build.gradle Added Flyway dependencies and plugin configuration
.claude/skills/flyway/SKILL.md Comprehensive Flyway skill documentation (English & Korean)
md-ko-ver/flyway-guide.ko.md User-facing Flyway usage guide in Korean
Test files Comprehensive test coverage for all new features with fixture updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (netWeight == null && data.getWeight() != null) {
netWeight = data.getWeightLoss() == null ? data.getWeight() : data.getWeight().subtract(data.getWeightLoss());
}
BigDecimal itemCarbonReduction = netWeight.multiply(factor.getEmissionFactorKgCo2ePerKg()); // 품목별 탄소 저감량
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

Variable netWeight may be null at this access as suggested by this null guard.

Copilot uses AI. Check for mistakes.
@Hwan0518 Hwan0518 merged commit bd857d0 into develop Jan 30, 2026
@Hwan0518 Hwan0518 deleted the feature/stats/user branch January 30, 2026 09:02
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.

1 participant