diff --git a/src/main/java/com/dduckddak/domain/data/controller/FacilityController.java b/src/main/java/com/dduckddak/domain/data/facility/controller/FacilityController.java similarity index 85% rename from src/main/java/com/dduckddak/domain/data/controller/FacilityController.java rename to src/main/java/com/dduckddak/domain/data/facility/controller/FacilityController.java index e71d39f..5dcd89d 100644 --- a/src/main/java/com/dduckddak/domain/data/controller/FacilityController.java +++ b/src/main/java/com/dduckddak/domain/data/facility/controller/FacilityController.java @@ -1,9 +1,9 @@ -package com.dduckddak.domain.data.controller; +package com.dduckddak.domain.data.facility.controller; -import com.dduckddak.domain.data.dto.FacilityByDistrictResponse; -import com.dduckddak.domain.data.dto.FacilityDto; -import com.dduckddak.domain.data.service.FacilityService; +import com.dduckddak.domain.data.facility.dto.FacilityByDistrictResponse; +import com.dduckddak.domain.data.facility.dto.FacilityDto; +import com.dduckddak.domain.data.facility.service.FacilityService; import com.dduckddak.global.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/dduckddak/domain/data/dto/FacilityByDistrictResponse.java b/src/main/java/com/dduckddak/domain/data/facility/dto/FacilityByDistrictResponse.java similarity index 92% rename from src/main/java/com/dduckddak/domain/data/dto/FacilityByDistrictResponse.java rename to src/main/java/com/dduckddak/domain/data/facility/dto/FacilityByDistrictResponse.java index 763131d..9ca65d0 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/FacilityByDistrictResponse.java +++ b/src/main/java/com/dduckddak/domain/data/facility/dto/FacilityByDistrictResponse.java @@ -1,7 +1,6 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.facility.dto; -import com.dduckddak.domain.data.model.Facility; import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/dduckddak/domain/data/dto/FacilityDto.java b/src/main/java/com/dduckddak/domain/data/facility/dto/FacilityDto.java similarity index 90% rename from src/main/java/com/dduckddak/domain/data/dto/FacilityDto.java rename to src/main/java/com/dduckddak/domain/data/facility/dto/FacilityDto.java index e6b792c..bc2f702 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/FacilityDto.java +++ b/src/main/java/com/dduckddak/domain/data/facility/dto/FacilityDto.java @@ -1,10 +1,9 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.facility.dto; -import com.dduckddak.domain.data.model.Facility; +import com.dduckddak.domain.data.facility.model.Facility; import lombok.Builder; import lombok.Getter; -import lombok.NoArgsConstructor; @Getter @Builder diff --git a/src/main/java/com/dduckddak/domain/data/model/Facility.java b/src/main/java/com/dduckddak/domain/data/facility/model/Facility.java similarity index 98% rename from src/main/java/com/dduckddak/domain/data/model/Facility.java rename to src/main/java/com/dduckddak/domain/data/facility/model/Facility.java index 7b4ad3a..ef866e4 100644 --- a/src/main/java/com/dduckddak/domain/data/model/Facility.java +++ b/src/main/java/com/dduckddak/domain/data/facility/model/Facility.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.model; +package com.dduckddak.domain.data.facility.model; import com.dduckddak.domain.town.model.Town; import jakarta.persistence.*; diff --git a/src/main/java/com/dduckddak/domain/data/repository/FacilityBulkRepository.java b/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityBulkRepository.java similarity index 95% rename from src/main/java/com/dduckddak/domain/data/repository/FacilityBulkRepository.java rename to src/main/java/com/dduckddak/domain/data/facility/repository/FacilityBulkRepository.java index b9d3aac..dddd1f9 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/FacilityBulkRepository.java +++ b/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityBulkRepository.java @@ -1,7 +1,6 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.facility.repository; -import com.dduckddak.domain.data.model.Facility; -import com.dduckddak.domain.data.model.Sales; +import com.dduckddak.domain.data.facility.model.Facility; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/src/main/java/com/dduckddak/domain/data/repository/FacilityRepository.java b/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepository.java similarity index 54% rename from src/main/java/com/dduckddak/domain/data/repository/FacilityRepository.java rename to src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepository.java index 95e84c2..ecee951 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/FacilityRepository.java +++ b/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepository.java @@ -1,7 +1,6 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.facility.repository; -import com.dduckddak.domain.data.model.Facility; -import com.dduckddak.domain.data.model.Finance; +import com.dduckddak.domain.data.facility.model.Facility; import org.springframework.data.jpa.repository.JpaRepository; public interface FacilityRepository extends JpaRepository, FacilityRepositoryCustom { diff --git a/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepositoryCustom.java b/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepositoryCustom.java new file mode 100644 index 0000000..21d4b07 --- /dev/null +++ b/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepositoryCustom.java @@ -0,0 +1,11 @@ +package com.dduckddak.domain.data.facility.repository; + +import com.dduckddak.domain.data.facility.dto.FacilityByDistrictResponse; +import com.dduckddak.domain.data.facility.model.Facility; + +public interface FacilityRepositoryCustom { + + Facility findByTownCodeAndQuarter(String code); + + FacilityByDistrictResponse findRecentByDistrict(String district); +} diff --git a/src/main/java/com/dduckddak/domain/data/repository/FacilityRepositoryImpl.java b/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepositoryImpl.java similarity index 80% rename from src/main/java/com/dduckddak/domain/data/repository/FacilityRepositoryImpl.java rename to src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepositoryImpl.java index 2854f79..715d5c9 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/FacilityRepositoryImpl.java +++ b/src/main/java/com/dduckddak/domain/data/facility/repository/FacilityRepositoryImpl.java @@ -1,20 +1,14 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.facility.repository; -import com.dduckddak.domain.data.dto.FacilityByDistrictResponse; -import com.dduckddak.domain.data.dto.QFacilityByDistrictResponse; -import com.dduckddak.domain.data.dto.QPopulationByDistrictResponse; -import com.dduckddak.domain.data.model.Facility; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.model.PopulationType; +import com.dduckddak.domain.data.facility.dto.FacilityByDistrictResponse; +import com.dduckddak.domain.data.facility.dto.QFacilityByDistrictResponse; +import com.dduckddak.domain.data.facility.model.Facility; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; -import java.util.List; - -import static com.dduckddak.domain.data.model.QFacility.facility; -import static com.dduckddak.domain.data.model.QPopulation.population; +import static com.dduckddak.domain.data.facility.model.QFacility.facility; import static com.dduckddak.domain.town.model.QTown.town; @RequiredArgsConstructor diff --git a/src/main/java/com/dduckddak/domain/data/service/FacilityService.java b/src/main/java/com/dduckddak/domain/data/facility/service/FacilityService.java similarity index 62% rename from src/main/java/com/dduckddak/domain/data/service/FacilityService.java rename to src/main/java/com/dduckddak/domain/data/facility/service/FacilityService.java index 2e0f7f4..d4e3893 100644 --- a/src/main/java/com/dduckddak/domain/data/service/FacilityService.java +++ b/src/main/java/com/dduckddak/domain/data/facility/service/FacilityService.java @@ -1,9 +1,9 @@ -package com.dduckddak.domain.data.service; +package com.dduckddak.domain.data.facility.service; -import com.dduckddak.domain.data.dto.FacilityByDistrictResponse; -import com.dduckddak.domain.data.dto.FacilityDto; -import com.dduckddak.domain.data.model.Facility; -import com.dduckddak.domain.data.repository.FacilityRepository; +import com.dduckddak.domain.data.facility.dto.FacilityByDistrictResponse; +import com.dduckddak.domain.data.facility.dto.FacilityDto; +import com.dduckddak.domain.data.facility.model.Facility; +import com.dduckddak.domain.data.facility.repository.FacilityRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/dduckddak/domain/data/model/Finance.java b/src/main/java/com/dduckddak/domain/data/finance/model/Finance.java similarity index 97% rename from src/main/java/com/dduckddak/domain/data/model/Finance.java rename to src/main/java/com/dduckddak/domain/data/finance/model/Finance.java index d855087..7dc9050 100644 --- a/src/main/java/com/dduckddak/domain/data/model/Finance.java +++ b/src/main/java/com/dduckddak/domain/data/finance/model/Finance.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.model; +package com.dduckddak.domain.data.finance.model; import com.dduckddak.domain.town.model.Town; import jakarta.persistence.*; diff --git a/src/main/java/com/dduckddak/domain/data/repository/FinanceBulkRepository.java b/src/main/java/com/dduckddak/domain/data/finance/repository/FinanceBulkRepository.java similarity index 92% rename from src/main/java/com/dduckddak/domain/data/repository/FinanceBulkRepository.java rename to src/main/java/com/dduckddak/domain/data/finance/repository/FinanceBulkRepository.java index c2625a2..a591a96 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/FinanceBulkRepository.java +++ b/src/main/java/com/dduckddak/domain/data/finance/repository/FinanceBulkRepository.java @@ -1,8 +1,7 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.finance.repository; -import com.dduckddak.domain.data.model.Finance; -import com.dduckddak.domain.data.model.Population; +import com.dduckddak.domain.data.finance.model.Finance; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/src/main/java/com/dduckddak/domain/data/repository/FinanceRepository.java b/src/main/java/com/dduckddak/domain/data/finance/repository/FinanceRepository.java similarity index 56% rename from src/main/java/com/dduckddak/domain/data/repository/FinanceRepository.java rename to src/main/java/com/dduckddak/domain/data/finance/repository/FinanceRepository.java index 8b9afdc..4673842 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/FinanceRepository.java +++ b/src/main/java/com/dduckddak/domain/data/finance/repository/FinanceRepository.java @@ -1,6 +1,6 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.finance.repository; -import com.dduckddak.domain.data.model.Finance; +import com.dduckddak.domain.data.finance.model.Finance; import org.springframework.data.jpa.repository.JpaRepository; public interface FinanceRepository extends JpaRepository { diff --git a/src/main/java/com/dduckddak/domain/data/dto/MarketAnalysisResponse.java b/src/main/java/com/dduckddak/domain/data/markettrends/dto/MarketAnalysisResponse.java similarity index 94% rename from src/main/java/com/dduckddak/domain/data/dto/MarketAnalysisResponse.java rename to src/main/java/com/dduckddak/domain/data/markettrends/dto/MarketAnalysisResponse.java index 155d010..1d20991 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/MarketAnalysisResponse.java +++ b/src/main/java/com/dduckddak/domain/data/markettrends/dto/MarketAnalysisResponse.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.markettrends.dto; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/com/dduckddak/domain/data/dto/MarketTrendsResponse.java b/src/main/java/com/dduckddak/domain/data/markettrends/dto/MarketTrendsResponse.java similarity index 86% rename from src/main/java/com/dduckddak/domain/data/dto/MarketTrendsResponse.java rename to src/main/java/com/dduckddak/domain/data/markettrends/dto/MarketTrendsResponse.java index a5ddd54..4ac1a0e 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/MarketTrendsResponse.java +++ b/src/main/java/com/dduckddak/domain/data/markettrends/dto/MarketTrendsResponse.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.markettrends.dto; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/dduckddak/domain/data/model/MarketTrends.java b/src/main/java/com/dduckddak/domain/data/markettrends/model/MarketTrends.java similarity index 96% rename from src/main/java/com/dduckddak/domain/data/model/MarketTrends.java rename to src/main/java/com/dduckddak/domain/data/markettrends/model/MarketTrends.java index 1d31b23..0e9a3f2 100644 --- a/src/main/java/com/dduckddak/domain/data/model/MarketTrends.java +++ b/src/main/java/com/dduckddak/domain/data/markettrends/model/MarketTrends.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.model; +package com.dduckddak.domain.data.markettrends.model; import com.dduckddak.domain.town.model.Town; import jakarta.persistence.*; diff --git a/src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepository.java b/src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepository.java similarity index 59% rename from src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepository.java rename to src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepository.java index 4cd0004..12eb147 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepository.java +++ b/src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepository.java @@ -1,6 +1,6 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.markettrends.repository; -import com.dduckddak.domain.data.model.MarketTrends; +import com.dduckddak.domain.data.markettrends.model.MarketTrends; import org.springframework.data.jpa.repository.JpaRepository; public interface MarketTrendRepository extends JpaRepository, MarketTrendRepositoryCustom { diff --git a/src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepositoryCustom.java b/src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepositoryCustom.java similarity index 67% rename from src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepositoryCustom.java rename to src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepositoryCustom.java index 5525346..206dee4 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepositoryCustom.java +++ b/src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepositoryCustom.java @@ -1,6 +1,6 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.markettrends.repository; -import com.dduckddak.domain.data.model.MarketTrends; +import com.dduckddak.domain.data.markettrends.model.MarketTrends; import java.util.List; diff --git a/src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepositoryImpl.java b/src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepositoryImpl.java similarity index 84% rename from src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepositoryImpl.java rename to src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepositoryImpl.java index a61455e..f27866d 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/MarketTrendRepositoryImpl.java +++ b/src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendRepositoryImpl.java @@ -1,12 +1,11 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.markettrends.repository; -import com.dduckddak.domain.data.model.MarketTrends; +import com.dduckddak.domain.data.markettrends.model.MarketTrends; import com.querydsl.jpa.impl.JPAQueryFactory; import jakarta.persistence.EntityManager; - import java.util.List; -import static com.dduckddak.domain.data.model.QMarketTrends.marketTrends; +import static com.dduckddak.domain.data.markettrends.model.QMarketTrends.marketTrends; public class MarketTrendRepositoryImpl implements MarketTrendRepositoryCustom { private final JPAQueryFactory queryFactory; diff --git a/src/main/java/com/dduckddak/domain/data/repository/MarketTrendsBulkRepository.java b/src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendsBulkRepository.java similarity index 90% rename from src/main/java/com/dduckddak/domain/data/repository/MarketTrendsBulkRepository.java rename to src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendsBulkRepository.java index d2b97e7..213628a 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/MarketTrendsBulkRepository.java +++ b/src/main/java/com/dduckddak/domain/data/markettrends/repository/MarketTrendsBulkRepository.java @@ -1,7 +1,6 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.markettrends.repository; -import com.dduckddak.domain.data.model.Facility; -import com.dduckddak.domain.data.model.MarketTrends; +import com.dduckddak.domain.data.markettrends.model.MarketTrends; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/src/main/java/com/dduckddak/domain/member/controller/ScrapController.java b/src/main/java/com/dduckddak/domain/data/member/controller/ScrapController.java similarity index 85% rename from src/main/java/com/dduckddak/domain/member/controller/ScrapController.java rename to src/main/java/com/dduckddak/domain/data/member/controller/ScrapController.java index 063d414..d35e28a 100644 --- a/src/main/java/com/dduckddak/domain/member/controller/ScrapController.java +++ b/src/main/java/com/dduckddak/domain/data/member/controller/ScrapController.java @@ -1,8 +1,8 @@ -package com.dduckddak.domain.member.controller; +package com.dduckddak.domain.data.member.controller; -import com.dduckddak.domain.member.controller.dto.ScrapRequest; -import com.dduckddak.domain.member.controller.dto.ScrapResponse; -import com.dduckddak.domain.member.service.ScrapService; +import com.dduckddak.domain.data.member.controller.dto.ScrapRequest; +import com.dduckddak.domain.data.member.controller.dto.ScrapResponse; +import com.dduckddak.domain.data.member.service.ScrapService; import com.dduckddak.global.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/dduckddak/domain/member/controller/dto/ScrapRequest.java b/src/main/java/com/dduckddak/domain/data/member/controller/dto/ScrapRequest.java similarity index 86% rename from src/main/java/com/dduckddak/domain/member/controller/dto/ScrapRequest.java rename to src/main/java/com/dduckddak/domain/data/member/controller/dto/ScrapRequest.java index 528e41f..974d123 100644 --- a/src/main/java/com/dduckddak/domain/member/controller/dto/ScrapRequest.java +++ b/src/main/java/com/dduckddak/domain/data/member/controller/dto/ScrapRequest.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.member.controller.dto; +package com.dduckddak.domain.data.member.controller.dto; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/dduckddak/domain/member/controller/dto/ScrapResponse.java b/src/main/java/com/dduckddak/domain/data/member/controller/dto/ScrapResponse.java similarity index 88% rename from src/main/java/com/dduckddak/domain/member/controller/dto/ScrapResponse.java rename to src/main/java/com/dduckddak/domain/data/member/controller/dto/ScrapResponse.java index ede2215..70c892d 100644 --- a/src/main/java/com/dduckddak/domain/member/controller/dto/ScrapResponse.java +++ b/src/main/java/com/dduckddak/domain/data/member/controller/dto/ScrapResponse.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.member.controller.dto; +package com.dduckddak.domain.data.member.controller.dto; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/dduckddak/domain/member/model/Member.java b/src/main/java/com/dduckddak/domain/data/member/model/Member.java similarity index 95% rename from src/main/java/com/dduckddak/domain/member/model/Member.java rename to src/main/java/com/dduckddak/domain/data/member/model/Member.java index 507682d..fce8917 100644 --- a/src/main/java/com/dduckddak/domain/member/model/Member.java +++ b/src/main/java/com/dduckddak/domain/data/member/model/Member.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.member.model; +package com.dduckddak.domain.data.member.model; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/com/dduckddak/domain/member/model/MemberRole.java b/src/main/java/com/dduckddak/domain/data/member/model/MemberRole.java similarity index 89% rename from src/main/java/com/dduckddak/domain/member/model/MemberRole.java rename to src/main/java/com/dduckddak/domain/data/member/model/MemberRole.java index 1f30189..dfd7d51 100644 --- a/src/main/java/com/dduckddak/domain/member/model/MemberRole.java +++ b/src/main/java/com/dduckddak/domain/data/member/model/MemberRole.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.member.model; +package com.dduckddak.domain.data.member.model; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/dduckddak/domain/member/model/Scrap.java b/src/main/java/com/dduckddak/domain/data/member/model/Scrap.java similarity index 84% rename from src/main/java/com/dduckddak/domain/member/model/Scrap.java rename to src/main/java/com/dduckddak/domain/data/member/model/Scrap.java index c7783b2..634d707 100644 --- a/src/main/java/com/dduckddak/domain/member/model/Scrap.java +++ b/src/main/java/com/dduckddak/domain/data/member/model/Scrap.java @@ -1,6 +1,6 @@ -package com.dduckddak.domain.member.model; +package com.dduckddak.domain.data.member.model; -import com.dduckddak.domain.member.controller.dto.ScrapRequest; +import com.dduckddak.domain.data.member.controller.dto.ScrapRequest; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/dduckddak/domain/member/repository/MemberRepository.java b/src/main/java/com/dduckddak/domain/data/member/repository/MemberRepository.java similarity index 72% rename from src/main/java/com/dduckddak/domain/member/repository/MemberRepository.java rename to src/main/java/com/dduckddak/domain/data/member/repository/MemberRepository.java index 4e47cfc..5168b0c 100644 --- a/src/main/java/com/dduckddak/domain/member/repository/MemberRepository.java +++ b/src/main/java/com/dduckddak/domain/data/member/repository/MemberRepository.java @@ -1,6 +1,6 @@ -package com.dduckddak.domain.member.repository; +package com.dduckddak.domain.data.member.repository; -import com.dduckddak.domain.member.model.Member; +import com.dduckddak.domain.data.member.model.Member; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/dduckddak/domain/member/repository/ScrapRepository.java b/src/main/java/com/dduckddak/domain/data/member/repository/ScrapRepository.java similarity index 84% rename from src/main/java/com/dduckddak/domain/member/repository/ScrapRepository.java rename to src/main/java/com/dduckddak/domain/data/member/repository/ScrapRepository.java index 0b5cba5..a267cb7 100644 --- a/src/main/java/com/dduckddak/domain/member/repository/ScrapRepository.java +++ b/src/main/java/com/dduckddak/domain/data/member/repository/ScrapRepository.java @@ -1,6 +1,6 @@ -package com.dduckddak.domain.member.repository; +package com.dduckddak.domain.data.member.repository; -import com.dduckddak.domain.member.model.Scrap; +import com.dduckddak.domain.data.member.model.Scrap; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/src/main/java/com/dduckddak/domain/member/service/ScrapService.java b/src/main/java/com/dduckddak/domain/data/member/service/ScrapService.java similarity index 83% rename from src/main/java/com/dduckddak/domain/member/service/ScrapService.java rename to src/main/java/com/dduckddak/domain/data/member/service/ScrapService.java index 35f4ecd..649f75f 100644 --- a/src/main/java/com/dduckddak/domain/member/service/ScrapService.java +++ b/src/main/java/com/dduckddak/domain/data/member/service/ScrapService.java @@ -1,11 +1,11 @@ -package com.dduckddak.domain.member.service; - -import com.dduckddak.domain.member.controller.dto.ScrapRequest; -import com.dduckddak.domain.member.controller.dto.ScrapResponse; -import com.dduckddak.domain.member.model.Member; -import com.dduckddak.domain.member.model.Scrap; -import com.dduckddak.domain.member.repository.MemberRepository; -import com.dduckddak.domain.member.repository.ScrapRepository; +package com.dduckddak.domain.data.member.service; + +import com.dduckddak.domain.data.member.repository.MemberRepository; +import com.dduckddak.domain.data.member.repository.ScrapRepository; +import com.dduckddak.domain.data.member.controller.dto.ScrapRequest; +import com.dduckddak.domain.data.member.controller.dto.ScrapResponse; +import com.dduckddak.domain.data.member.model.Member; +import com.dduckddak.domain.data.member.model.Scrap; import com.dduckddak.domain.town.model.Town; import com.dduckddak.domain.town.repository.TownRepository; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dduckddak/domain/data/controller/PopulationController.java b/src/main/java/com/dduckddak/domain/data/population/controller/PopulationController.java similarity index 95% rename from src/main/java/com/dduckddak/domain/data/controller/PopulationController.java rename to src/main/java/com/dduckddak/domain/data/population/controller/PopulationController.java index 8455002..f9f7613 100644 --- a/src/main/java/com/dduckddak/domain/data/controller/PopulationController.java +++ b/src/main/java/com/dduckddak/domain/data/population/controller/PopulationController.java @@ -1,8 +1,8 @@ -package com.dduckddak.domain.data.controller; +package com.dduckddak.domain.data.population.controller; -import com.dduckddak.domain.data.dto.*; -import com.dduckddak.domain.data.model.PopulationType; -import com.dduckddak.domain.data.service.PopulationService; +import com.dduckddak.domain.data.population.dto.*; +import com.dduckddak.domain.data.population.model.PopulationType; +import com.dduckddak.domain.data.population.service.PopulationService; import com.dduckddak.global.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/dduckddak/domain/data/dto/PopulationByDistrictResponse.java b/src/main/java/com/dduckddak/domain/data/population/dto/PopulationByDistrictResponse.java similarity index 90% rename from src/main/java/com/dduckddak/domain/data/dto/PopulationByDistrictResponse.java rename to src/main/java/com/dduckddak/domain/data/population/dto/PopulationByDistrictResponse.java index cc47912..688d9be 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/PopulationByDistrictResponse.java +++ b/src/main/java/com/dduckddak/domain/data/population/dto/PopulationByDistrictResponse.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.population.dto; import com.querydsl.core.annotations.QueryProjection; import lombok.AccessLevel; diff --git a/src/main/java/com/dduckddak/domain/data/dto/PopulationByQuarterDto.java b/src/main/java/com/dduckddak/domain/data/population/dto/PopulationByQuarterDto.java similarity index 86% rename from src/main/java/com/dduckddak/domain/data/dto/PopulationByQuarterDto.java rename to src/main/java/com/dduckddak/domain/data/population/dto/PopulationByQuarterDto.java index 4b0a50f..5bc5078 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/PopulationByQuarterDto.java +++ b/src/main/java/com/dduckddak/domain/data/population/dto/PopulationByQuarterDto.java @@ -1,6 +1,6 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.population.dto; -import com.dduckddak.domain.data.model.Population; +import com.dduckddak.domain.data.population.model.Population; import java.util.List; diff --git a/src/main/java/com/dduckddak/domain/data/dto/PopulationTransitionResponse.java b/src/main/java/com/dduckddak/domain/data/population/dto/PopulationTransitionResponse.java similarity index 85% rename from src/main/java/com/dduckddak/domain/data/dto/PopulationTransitionResponse.java rename to src/main/java/com/dduckddak/domain/data/population/dto/PopulationTransitionResponse.java index 8e0d731..8e20ccf 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/PopulationTransitionResponse.java +++ b/src/main/java/com/dduckddak/domain/data/population/dto/PopulationTransitionResponse.java @@ -1,6 +1,4 @@ -package com.dduckddak.domain.data.dto; - -import com.dduckddak.domain.data.model.Population; +package com.dduckddak.domain.data.population.dto; import java.util.List; @@ -8,6 +6,7 @@ public record PopulationTransitionResponse( List populationList ) { public record PopulationData( + String townName, long quarter, long populationOfTown, int rankAtCity, diff --git a/src/main/java/com/dduckddak/domain/data/dto/PopulationsTop10Response.java b/src/main/java/com/dduckddak/domain/data/population/dto/PopulationsTop10Response.java similarity index 92% rename from src/main/java/com/dduckddak/domain/data/dto/PopulationsTop10Response.java rename to src/main/java/com/dduckddak/domain/data/population/dto/PopulationsTop10Response.java index 918a79a..a2177eb 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/PopulationsTop10Response.java +++ b/src/main/java/com/dduckddak/domain/data/population/dto/PopulationsTop10Response.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.population.dto; import lombok.Builder; diff --git a/src/main/java/com/dduckddak/domain/data/dto/TimelyDto.java b/src/main/java/com/dduckddak/domain/data/population/dto/TimelyDto.java similarity index 86% rename from src/main/java/com/dduckddak/domain/data/dto/TimelyDto.java rename to src/main/java/com/dduckddak/domain/data/population/dto/TimelyDto.java index f41f87e..4561b9e 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/TimelyDto.java +++ b/src/main/java/com/dduckddak/domain/data/population/dto/TimelyDto.java @@ -1,6 +1,7 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.population.dto; -import com.dduckddak.domain.data.model.Population; +import com.dduckddak.domain.data.population.model.Population; +import com.dduckddak.domain.data.sales.dto.RecentlySalesDto; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/dduckddak/domain/data/model/Population.java b/src/main/java/com/dduckddak/domain/data/population/model/Population.java similarity index 97% rename from src/main/java/com/dduckddak/domain/data/model/Population.java rename to src/main/java/com/dduckddak/domain/data/population/model/Population.java index 40aeba6..e53611e 100644 --- a/src/main/java/com/dduckddak/domain/data/model/Population.java +++ b/src/main/java/com/dduckddak/domain/data/population/model/Population.java @@ -1,7 +1,6 @@ -package com.dduckddak.domain.data.model; +package com.dduckddak.domain.data.population.model; import com.dduckddak.domain.town.model.Town; -import com.dduckddak.domain.town.model.TownIndustry; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; diff --git a/src/main/java/com/dduckddak/domain/data/model/PopulationType.java b/src/main/java/com/dduckddak/domain/data/population/model/PopulationType.java similarity index 92% rename from src/main/java/com/dduckddak/domain/data/model/PopulationType.java rename to src/main/java/com/dduckddak/domain/data/population/model/PopulationType.java index 49f9bbe..767b475 100644 --- a/src/main/java/com/dduckddak/domain/data/model/PopulationType.java +++ b/src/main/java/com/dduckddak/domain/data/population/model/PopulationType.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.model; +package com.dduckddak.domain.data.population.model; import lombok.Getter; diff --git a/src/main/java/com/dduckddak/domain/data/repository/PopulationBulkRepository.java b/src/main/java/com/dduckddak/domain/data/population/repository/PopulationBulkRepository.java similarity index 96% rename from src/main/java/com/dduckddak/domain/data/repository/PopulationBulkRepository.java rename to src/main/java/com/dduckddak/domain/data/population/repository/PopulationBulkRepository.java index 4920a41..fdb7b89 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/PopulationBulkRepository.java +++ b/src/main/java/com/dduckddak/domain/data/population/repository/PopulationBulkRepository.java @@ -1,7 +1,7 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.population.repository; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.model.PopulationType; +import com.dduckddak.domain.data.population.model.Population; +import com.dduckddak.domain.data.population.model.PopulationType; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepository.java b/src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepository.java new file mode 100644 index 0000000..f471042 --- /dev/null +++ b/src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepository.java @@ -0,0 +1,16 @@ +package com.dduckddak.domain.data.population.repository; + +import com.dduckddak.domain.data.population.model.Population; +import com.dduckddak.domain.data.population.model.PopulationType; +import com.dduckddak.domain.town.model.Town; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PopulationRepository extends JpaRepository, PopulationRepositoryCustom { + + Population findByTownAndPopulationType(Town town, PopulationType populationType); + + + + + +} diff --git a/src/main/java/com/dduckddak/domain/data/repository/PopulationRepositoryCustom.java b/src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepositoryCustom.java similarity index 72% rename from src/main/java/com/dduckddak/domain/data/repository/PopulationRepositoryCustom.java rename to src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepositoryCustom.java index f903a9c..21b7663 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/PopulationRepositoryCustom.java +++ b/src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepositoryCustom.java @@ -1,9 +1,9 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.population.repository; -import com.dduckddak.domain.data.dto.PopulationByDistrictResponse; -import com.dduckddak.domain.data.dto.PopulationsTop10Response; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.model.PopulationType; +import com.dduckddak.domain.data.population.dto.PopulationByDistrictResponse; +import com.dduckddak.domain.data.population.dto.PopulationsTop10Response; +import com.dduckddak.domain.data.population.model.Population; +import com.dduckddak.domain.data.population.model.PopulationType; import java.util.List; import java.util.Optional; diff --git a/src/main/java/com/dduckddak/domain/data/repository/PopulationRepositoryImpl.java b/src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepositoryImpl.java similarity index 89% rename from src/main/java/com/dduckddak/domain/data/repository/PopulationRepositoryImpl.java rename to src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepositoryImpl.java index 9d36320..f3c252f 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/PopulationRepositoryImpl.java +++ b/src/main/java/com/dduckddak/domain/data/population/repository/PopulationRepositoryImpl.java @@ -1,10 +1,10 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.population.repository; -import com.dduckddak.domain.data.dto.PopulationByDistrictResponse; -import com.dduckddak.domain.data.dto.PopulationsTop10Response; -import com.dduckddak.domain.data.dto.QPopulationByDistrictResponse; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.model.PopulationType; +import com.dduckddak.domain.data.population.dto.PopulationByDistrictResponse; +import com.dduckddak.domain.data.population.dto.PopulationsTop10Response; +import com.dduckddak.domain.data.population.dto.QPopulationByDistrictResponse; +import com.dduckddak.domain.data.population.model.Population; +import com.dduckddak.domain.data.population.model.PopulationType; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import jakarta.persistence.EntityManager; @@ -16,7 +16,8 @@ import java.util.List; import java.util.Optional; -import static com.dduckddak.domain.data.model.QPopulation.population; + +import static com.dduckddak.domain.data.population.model.QPopulation.population; import static com.dduckddak.domain.town.model.QTown.town; @RequiredArgsConstructor @@ -126,7 +127,7 @@ public List findFloatingPopulationTransition(String code) { .innerJoin(population.town, town).fetchJoin() .where(population.populationType.eq(PopulationType.FloatingPopulation) .and(town.quarter.in(20241, 20234, 20233, 20232, 20231))) - .orderBy(population.town.quarter.desc(), population.totalPopulation.desc()) + .orderBy(population.town.quarter.asc(), population.totalPopulation.desc()) .fetch(); } diff --git a/src/main/java/com/dduckddak/domain/data/service/PopulationService.java b/src/main/java/com/dduckddak/domain/data/population/service/PopulationService.java similarity index 87% rename from src/main/java/com/dduckddak/domain/data/service/PopulationService.java rename to src/main/java/com/dduckddak/domain/data/population/service/PopulationService.java index 94b6dfa..2a0ff94 100644 --- a/src/main/java/com/dduckddak/domain/data/service/PopulationService.java +++ b/src/main/java/com/dduckddak/domain/data/population/service/PopulationService.java @@ -1,10 +1,10 @@ -package com.dduckddak.domain.data.service; +package com.dduckddak.domain.data.population.service; -import com.dduckddak.domain.data.dto.*; -import com.dduckddak.domain.data.dto.PopulationTransitionResponse.PopulationData; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.model.PopulationType; -import com.dduckddak.domain.data.repository.PopulationRepository; +import com.dduckddak.domain.data.population.dto.*; +import com.dduckddak.domain.data.population.dto.PopulationTransitionResponse.PopulationData; +import com.dduckddak.domain.data.population.model.Population; +import com.dduckddak.domain.data.population.model.PopulationType; +import com.dduckddak.domain.data.population.repository.PopulationRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -78,7 +78,7 @@ public PopulationTransitionResponse getFloatingPopulationTransition(String code) List populations = populationRepository.findFloatingPopulationTransition(code); List populationDataList = new ArrayList<>(); - long[] quarterArr = new long[]{20241L, 20234L, 20233L, 20232L, 20231L}; + long[] quarterArr = new long[]{20231L, 20232L, 20233L, 20234L ,20241L }; for(long quarter : quarterArr){ List listOfCity = populations.stream().filter @@ -97,7 +97,7 @@ public PopulationTransitionResponse getFloatingPopulationTransition(String code) int rankAtDistrict = listOfDistrict.indexOf(population) + 1; // 20241분기 구 내 등수 long populationAvgOfDistrict = (long) listOfDistrict.stream().mapToLong(Population::getTotalPopulation).average().getAsDouble(); - populationDataList.add(new PopulationData(quarter, populationOfTown, rankAtCity, populationAvgOfCity, rankAtDistrict, populationAvgOfDistrict)); + populationDataList.add(new PopulationData(population.getTown().getName().split(" ")[1] ,quarter, populationOfTown, rankAtCity, populationAvgOfCity, rankAtDistrict, populationAvgOfDistrict)); } return PopulationTransitionResponse.from(populationDataList); diff --git a/src/main/java/com/dduckddak/domain/data/repository/FacilityRepositoryCustom.java b/src/main/java/com/dduckddak/domain/data/repository/FacilityRepositoryCustom.java deleted file mode 100644 index fb32ad7..0000000 --- a/src/main/java/com/dduckddak/domain/data/repository/FacilityRepositoryCustom.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.dduckddak.domain.data.repository; - -import com.dduckddak.domain.data.dto.FacilityByDistrictResponse; -import com.dduckddak.domain.data.model.Facility; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.model.PopulationType; - -import java.util.List; - -public interface FacilityRepositoryCustom { - - Facility findByTownCodeAndQuarter(String code); - - FacilityByDistrictResponse findRecentByDistrict(String district); -} diff --git a/src/main/java/com/dduckddak/domain/data/repository/PopulationRepository.java b/src/main/java/com/dduckddak/domain/data/repository/PopulationRepository.java deleted file mode 100644 index 4d98d8a..0000000 --- a/src/main/java/com/dduckddak/domain/data/repository/PopulationRepository.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.dduckddak.domain.data.repository; - -import com.dduckddak.domain.data.dto.PopulationsTop10Response; -import com.dduckddak.domain.data.dto.SalesTop10Response; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.model.PopulationType; -import com.dduckddak.domain.town.model.Town; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -import java.util.List; - -public interface PopulationRepository extends JpaRepository, PopulationRepositoryCustom { - - Population findByTownAndPopulationType(Town town, PopulationType populationType); - - - - - -} diff --git a/src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepository.java b/src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepository.java deleted file mode 100644 index 6dfc707..0000000 --- a/src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepository.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.dduckddak.domain.data.repository.sales; - -import com.dduckddak.domain.data.dto.SalesTop10OfIndustryResponse; -import com.dduckddak.domain.data.dto.SalesTop10Response; -import com.dduckddak.domain.data.model.Sales; -import com.dduckddak.domain.town.dto.SalesVO; -import com.dduckddak.domain.town.model.TownIndustry; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -import java.util.List; - -public interface SalesRepository extends JpaRepository, SalesRepositoryCustom { - @Query("SELECT new com.dduckddak.domain.town.dto.SalesVO(" + - "s1.mondaySales - s2.mondaySales, " + - "s1.tuesdaySales - s2.tuesdaySales, " + - "s1.wednesdaySales - s2.wednesdaySales, " + - "s1.thursdaySales - s2.thursdaySales, " + - "s1.fridaySales - s2.fridaySales, " + - "s1.saturdaySales - s2.saturdaySales, " + - "s1.sundaySales - s2.sundaySales) " + - "FROM Sales s1, Sales s2 " + - "JOIN s1.townIndustry ti1 " + - "JOIN s2.townIndustry ti2 " + - "JOIN ti1.town t1 " + - "JOIN ti2.town t2 " + - "JOIN ti1.industry i1 " + - "JOIN ti2.industry i2 " + - "WHERE t1.code = :code AND t1.quarter = :currentQuarter AND " + - "t2.code = :code AND t2.quarter = :previousQuarter AND " + - "i1.name = :name AND i2.name = :name") - SalesVO getSalesCompare(@Param("code") String code, - @Param("name") String name, - @Param("currentQuarter") Long currentQuarter, - @Param("previousQuarter") Long previousQuarter); - - Sales findByTownIndustry(TownIndustry townIndustry); - - - -} diff --git a/src/main/java/com/dduckddak/domain/data/controller/SalesController.java b/src/main/java/com/dduckddak/domain/data/sales/controller/SalesController.java similarity index 59% rename from src/main/java/com/dduckddak/domain/data/controller/SalesController.java rename to src/main/java/com/dduckddak/domain/data/sales/controller/SalesController.java index 072edd0..1dce04a 100644 --- a/src/main/java/com/dduckddak/domain/data/controller/SalesController.java +++ b/src/main/java/com/dduckddak/domain/data/sales/controller/SalesController.java @@ -1,14 +1,14 @@ -package com.dduckddak.domain.data.controller; +package com.dduckddak.domain.data.sales.controller; -import com.dduckddak.domain.data.dto.*; -import com.dduckddak.domain.data.service.SalesService; +import com.dduckddak.domain.data.population.dto.TimelyDto; +import com.dduckddak.domain.data.sales.dto.*; +import com.dduckddak.domain.data.sales.service.SalesService; import com.dduckddak.domain.town.dto.SalesResponse; import com.dduckddak.global.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -46,7 +46,7 @@ public ApiResponse> getSalesTop10(@RequestParam(value = @Operation(summary = "행정동 별 업종 별 매출 Top10", description = "좌측 하단 매출 top10 UI에 사용(선택한 업종에 대해 행정동 별 매출 TOP10) (increaseRate or sales20241)") @GetMapping("/towns/industries/sales/top10") - public ApiResponse> getSalesTop10OfIndustry(@RequestParam(value = "orderCriteria", defaultValue = "sales20241") String orderCriteria,@RequestParam(value = "industryName") String name) { + public ApiResponse> getSalesTop10OfIndustry(@RequestParam(value = "orderCriteria", defaultValue = "sales20241") String orderCriteria, @RequestParam(value = "industryName") String name) { return ApiResponse.success(salesService.getSalesTop10OfIndustry(name, orderCriteria)); } @@ -56,4 +56,27 @@ public ApiResponse getSalesTransition(@RequestParam(val SalesTransitionResponse salesTransitionResponse = salesService.getSalesTransition(code); return success(salesTransitionResponse); } + + @Operation(summary = "행정동의 업종 별 매출 추이") + @GetMapping("/towns/industry/sales/transition") + public ApiResponse getSalesTransitionByIndustry(@RequestParam(value = "code") String townCode, @RequestParam(value = "industryName") String industryName){ + SalesTransitionByIndustryResponse salesTransitionResponseByIndustry = salesService.getSalesTransitionByIndustry(townCode, industryName); + return success(salesTransitionResponseByIndustry); + } + + @Operation(summary = "행정동의 업종 별 성 별 매출 비율") + @GetMapping("/towns/industry/sales/gender-rate") + public ApiResponse getSalesRateByGenderAndIndustry(@RequestParam(value = "code") String townCode, @RequestParam(value = "industryName") String industryName){ + SalesRateByGenderAndIndustryResponse salesRateByGenderAndIndustry = salesService.getSalesRateByGenderAndIndustry(townCode, industryName); + return success(salesRateByGenderAndIndustry); + } + + @Operation(summary = "행정동의 업종 별 나이 별 매출 비율") + @GetMapping("/towns/industry/sales/age-rate") + public ApiResponse getSalesRateByAgeAndIndustry(@RequestParam(value = "code") String townCode, @RequestParam(value = "industryName") String industryName){ + SalesRateByAgeAndIndustryResponse salesRateByAgeAndIndustry = salesService.getSalesRateByAgeAndIndustry(townCode, industryName); + return success( + salesRateByAgeAndIndustry + ); + } } diff --git a/src/main/java/com/dduckddak/domain/data/dto/RecentlySalesDto.java b/src/main/java/com/dduckddak/domain/data/sales/dto/RecentlySalesDto.java similarity index 95% rename from src/main/java/com/dduckddak/domain/data/dto/RecentlySalesDto.java rename to src/main/java/com/dduckddak/domain/data/sales/dto/RecentlySalesDto.java index 4386928..67c67f3 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/RecentlySalesDto.java +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/RecentlySalesDto.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.sales.dto; import com.querydsl.core.annotations.QueryProjection; import lombok.AccessLevel; diff --git a/src/main/java/com/dduckddak/domain/data/dto/SalesDiffVO.java b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesDiffVO.java similarity index 80% rename from src/main/java/com/dduckddak/domain/data/dto/SalesDiffVO.java rename to src/main/java/com/dduckddak/domain/data/sales/dto/SalesDiffVO.java index 7b3c64e..48ee9ba 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/SalesDiffVO.java +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesDiffVO.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.sales.dto; public interface SalesDiffVO { String getTownName(); diff --git a/src/main/java/com/dduckddak/domain/data/dto/SalesForTransitionData.java b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesForTransitionData.java similarity index 93% rename from src/main/java/com/dduckddak/domain/data/dto/SalesForTransitionData.java rename to src/main/java/com/dduckddak/domain/data/sales/dto/SalesForTransitionData.java index 3397420..45ba65f 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/SalesForTransitionData.java +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesForTransitionData.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.sales.dto; import com.querydsl.core.annotations.QueryProjection; import lombok.AccessLevel; diff --git a/src/main/java/com/dduckddak/domain/data/sales/dto/SalesRateByAgeAndIndustryResponse.java b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesRateByAgeAndIndustryResponse.java new file mode 100644 index 0000000..7a83e14 --- /dev/null +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesRateByAgeAndIndustryResponse.java @@ -0,0 +1,14 @@ +package com.dduckddak.domain.data.sales.dto; + +public interface SalesRateByAgeAndIndustryResponse { + String getTownName(); + String getIndustryName(); + Double getAge10sSales(); + Double getAge20sSales(); + Double getAge30sSales(); + Double getAge40sSales(); + Double getAge50sSales(); + Double getAge60sAndMoreSales(); + Double getWomenPercentage(); + Long getTotalSales(); +} diff --git a/src/main/java/com/dduckddak/domain/data/sales/dto/SalesRateByGenderAndIndustryResponse.java b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesRateByGenderAndIndustryResponse.java new file mode 100644 index 0000000..d21dbfd --- /dev/null +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesRateByGenderAndIndustryResponse.java @@ -0,0 +1,9 @@ +package com.dduckddak.domain.data.sales.dto; + +public interface SalesRateByGenderAndIndustryResponse { + String getTownName(); + String getIndustryName(); + Double getMenPercentage(); + Double getWomenPercentage(); + Long getSalesOfIndustry(); +} diff --git a/src/main/java/com/dduckddak/domain/data/dto/SalesTop10OfIndustryResponse.java b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTop10OfIndustryResponse.java similarity index 94% rename from src/main/java/com/dduckddak/domain/data/dto/SalesTop10OfIndustryResponse.java rename to src/main/java/com/dduckddak/domain/data/sales/dto/SalesTop10OfIndustryResponse.java index 5f10b37..9fe941b 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/SalesTop10OfIndustryResponse.java +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTop10OfIndustryResponse.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.sales.dto; import lombok.Builder; diff --git a/src/main/java/com/dduckddak/domain/data/dto/SalesTop10Response.java b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTop10Response.java similarity index 89% rename from src/main/java/com/dduckddak/domain/data/dto/SalesTop10Response.java rename to src/main/java/com/dduckddak/domain/data/sales/dto/SalesTop10Response.java index dfd6220..10815b2 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/SalesTop10Response.java +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTop10Response.java @@ -1,7 +1,6 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.sales.dto; -import com.dduckddak.domain.data.model.Sales; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTransitionByIndustryResponse.java b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTransitionByIndustryResponse.java new file mode 100644 index 0000000..3a31021 --- /dev/null +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTransitionByIndustryResponse.java @@ -0,0 +1,25 @@ +package com.dduckddak.domain.data.sales.dto; + +import java.util.List; + +public record SalesTransitionByIndustryResponse( + List salesList +) { + public record SalesData( + String townName, + String industryName, + long quarter, + long salesOfTown, + int rankAtCity, + long salesAvgOfCity, + int rankAtDistrict, + long salesAvgOfDistrict + + ) { + } + + public static SalesTransitionByIndustryResponse from(List sales) { + return new SalesTransitionByIndustryResponse(sales); + } +} + diff --git a/src/main/java/com/dduckddak/domain/data/dto/SalesTransitionResponse.java b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTransitionResponse.java similarity index 86% rename from src/main/java/com/dduckddak/domain/data/dto/SalesTransitionResponse.java rename to src/main/java/com/dduckddak/domain/data/sales/dto/SalesTransitionResponse.java index 842c1f1..7b86127 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/SalesTransitionResponse.java +++ b/src/main/java/com/dduckddak/domain/data/sales/dto/SalesTransitionResponse.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.data.sales.dto; import java.util.List; @@ -6,6 +6,7 @@ public record SalesTransitionResponse( List salesList ) { public record SalesData( + String townName, long quarter, long salesOfTown, int rankAtCity, diff --git a/src/main/java/com/dduckddak/domain/data/model/Sales.java b/src/main/java/com/dduckddak/domain/data/sales/model/Sales.java similarity index 98% rename from src/main/java/com/dduckddak/domain/data/model/Sales.java rename to src/main/java/com/dduckddak/domain/data/sales/model/Sales.java index d429e1f..4dac57c 100644 --- a/src/main/java/com/dduckddak/domain/data/model/Sales.java +++ b/src/main/java/com/dduckddak/domain/data/sales/model/Sales.java @@ -1,9 +1,8 @@ -package com.dduckddak.domain.data.model; +package com.dduckddak.domain.data.sales.model; import com.dduckddak.domain.town.model.TownIndustry; import jakarta.persistence.*; import lombok.AccessLevel; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/dduckddak/domain/data/repository/EstimateSalesBulkRepository.java b/src/main/java/com/dduckddak/domain/data/sales/repository/EstimateSalesBulkRepository.java similarity index 96% rename from src/main/java/com/dduckddak/domain/data/repository/EstimateSalesBulkRepository.java rename to src/main/java/com/dduckddak/domain/data/sales/repository/EstimateSalesBulkRepository.java index 26375c4..0356474 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/EstimateSalesBulkRepository.java +++ b/src/main/java/com/dduckddak/domain/data/sales/repository/EstimateSalesBulkRepository.java @@ -1,6 +1,6 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.data.sales.repository; -import com.dduckddak.domain.data.model.Sales; +import com.dduckddak.domain.data.sales.model.Sales; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepository.java b/src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepository.java new file mode 100644 index 0000000..9db0302 --- /dev/null +++ b/src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepository.java @@ -0,0 +1,88 @@ +package com.dduckddak.domain.data.sales.repository; + +import com.dduckddak.domain.data.sales.dto.SalesRateByAgeAndIndustryResponse; +import com.dduckddak.domain.data.sales.dto.SalesRateByGenderAndIndustryResponse; +import com.dduckddak.domain.data.sales.model.Sales; +import com.dduckddak.domain.town.dto.SalesVO; +import com.dduckddak.domain.town.model.TownIndustry; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +public interface SalesRepository extends JpaRepository, SalesRepositoryCustom { + @Query("SELECT new com.dduckddak.domain.town.dto.SalesVO(" + + "s1.mondaySales - s2.mondaySales, " + + "s1.tuesdaySales - s2.tuesdaySales, " + + "s1.wednesdaySales - s2.wednesdaySales, " + + "s1.thursdaySales - s2.thursdaySales, " + + "s1.fridaySales - s2.fridaySales, " + + "s1.saturdaySales - s2.saturdaySales, " + + "s1.sundaySales - s2.sundaySales) " + + "FROM Sales s1, Sales s2 " + + "JOIN s1.townIndustry ti1 " + + "JOIN s2.townIndustry ti2 " + + "JOIN ti1.town t1 " + + "JOIN ti2.town t2 " + + "JOIN ti1.industry i1 " + + "JOIN ti2.industry i2 " + + "WHERE t1.code = :code AND t1.quarter = :currentQuarter AND " + + "t2.code = :code AND t2.quarter = :previousQuarter AND " + + "i1.name = :name AND i2.name = :name") + SalesVO getSalesCompare(@Param("code") String code, + @Param("name") String name, + @Param("currentQuarter") Long currentQuarter, + @Param("previousQuarter") Long previousQuarter); + + Sales findByTownIndustry(TownIndustry townIndustry); + + + + + + @Query(value = + "SELECT \n" + + "\tt.name AS townName, \n" + + " i.name as industryName,\n" + + " ROUND(s.men_sales / (s.men_sales + s.women_sales) * 100, 1) AS menPercentage,\n" + + " ROUND(s.women_sales / (s.men_sales + s.women_sales) * 100, 1) AS womenPercentage,\n" + + " s.men_sales + s.women_sales as salesOfIndustry\n" + + "FROM \n" + + "\ttown_industry ti\n" + + "INNER JOIN \n" + + "\ttown t ON ti.town_id = t.id\n" + + "INNER JOIN \n" + + "\tindustry i ON ti.industry_id = i.id\n" + + "INNER JOIN \n" + + "\tsales s ON ti.id = s.town_industry_id\n" + + "WHERE \n" + + "\tt.quarter in (20241) AND t.code = :townCode AND i.name = :industryName", + nativeQuery = true) + SalesRateByGenderAndIndustryResponse findSalesRateByGenderAndIndustry(@Param("townCode") String townCode, @Param("industryName") String industryName); + + + @Query(value = + "SELECT \n" + + "\tt.name AS townName, \n" + + " i.name as industryName,\n" + + " age10s_sales + age20s_sales + age30s_sales + age40s_sales + age50s_sales + age60s_and_more_sales AS totalSales,\n" + + "\tROUND(age10s_sales / (age10s_sales + age20s_sales + age30s_sales + age40s_sales + age50s_sales + age60s_and_more_sales) * 100, 1) AS age10sSales,\n" + + "\tROUND(age20s_sales / (age10s_sales + age20s_sales + age30s_sales + age40s_sales + age50s_sales + age60s_and_more_sales) * 100, 1) AS age20sSales,\n" + + "\tROUND(age30s_sales / (age10s_sales + age20s_sales + age30s_sales + age40s_sales + age50s_sales + age60s_and_more_sales) * 100, 1) AS age30sSales,\n" + + "\tROUND(age40s_sales / (age10s_sales + age20s_sales + age30s_sales + age40s_sales + age50s_sales + age60s_and_more_sales) * 100, 1) AS age40sSales,\n" + + "\tROUND(age50s_sales / (age10s_sales + age20s_sales + age30s_sales + age40s_sales + age50s_sales + age60s_and_more_sales) * 100, 1) AS age50sSales,\n" + + "\tROUND(age60s_and_more_sales / (age10s_sales + age20s_sales + age30s_sales + age40s_sales + age50s_sales + age60s_and_more_sales) * 100, 1) AS age60sAndMoreSales,\n" + + " ROUND(s.men_sales / (s.men_sales + s.women_sales) * 100, 1) AS menPercentage,\n" + + " ROUND(s.women_sales / (s.men_sales + s.women_sales) * 100, 1) AS womenPercentage\n" + + "FROM \n" + + "\ttown_industry ti\n" + + "INNER JOIN \n" + + "\ttown t ON ti.town_id = t.id\n" + + "INNER JOIN \n" + + "\tindustry i ON ti.industry_id = i.id\n" + + "INNER JOIN \n" + + "\tsales s ON ti.id = s.town_industry_id\n" + + "WHERE \n" + + "\tt.quarter in (20241) AND t.code = :townCode AND i.name = :industryName ", + nativeQuery = true) + SalesRateByAgeAndIndustryResponse findSalesRateByAgeAndIndustry(@Param("townCode") String townCode, @Param("industryName") String industryName); +} diff --git a/src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepositoryCustom.java b/src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepositoryCustom.java similarity index 54% rename from src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepositoryCustom.java rename to src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepositoryCustom.java index f4627ce..17689b2 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepositoryCustom.java +++ b/src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepositoryCustom.java @@ -1,13 +1,11 @@ -package com.dduckddak.domain.data.repository.sales; +package com.dduckddak.domain.data.sales.repository; -import com.dduckddak.domain.data.dto.RecentlySalesDto; -import com.dduckddak.domain.data.dto.SalesForTransitionData; -import com.dduckddak.domain.data.dto.SalesTop10OfIndustryResponse; -import com.dduckddak.domain.data.dto.SalesTop10Response; -import com.dduckddak.domain.data.model.Sales; +import com.dduckddak.domain.data.sales.dto.RecentlySalesDto; +import com.dduckddak.domain.data.sales.dto.SalesForTransitionData; +import com.dduckddak.domain.data.sales.dto.SalesTop10OfIndustryResponse; +import com.dduckddak.domain.data.sales.dto.SalesTop10Response; +import com.dduckddak.domain.data.sales.model.Sales; import com.dduckddak.domain.town.dto.SalesVO; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; import java.util.List; @@ -17,10 +15,14 @@ public interface SalesRepositoryCustom { SalesVO findByTownAndIndustry(int code, String name); List findByTownAndIndustryInDistrict(String district, String name); - List findSalesForTransitionData(); + List findSalesTop10(String orderCriteria); List findSalesTop10OfIndustry(String name, String orderCriteria); + + List findSalesForTransitionData(); + + List findSalesByIndustryForTransitionData(String industryName); } diff --git a/src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepositoryImpl.java b/src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepositoryImpl.java similarity index 90% rename from src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepositoryImpl.java rename to src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepositoryImpl.java index 87343ba..541bf3a 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/sales/SalesRepositoryImpl.java +++ b/src/main/java/com/dduckddak/domain/data/sales/repository/SalesRepositoryImpl.java @@ -1,7 +1,6 @@ -package com.dduckddak.domain.data.repository.sales; - -import com.dduckddak.domain.data.dto.*; -import com.dduckddak.domain.data.model.Sales; +package com.dduckddak.domain.data.sales.repository; +import com.dduckddak.domain.data.sales.dto.*; +import com.dduckddak.domain.data.sales.model.Sales; import com.dduckddak.domain.town.dto.QSalesVO; import com.dduckddak.domain.town.dto.SalesVO; import com.querydsl.jpa.impl.JPAQuery; @@ -14,8 +13,9 @@ import java.util.ArrayList; import java.util.List; -import static com.dduckddak.domain.data.model.QPopulation.population; -import static com.dduckddak.domain.data.model.QSales.sales; + +import static com.dduckddak.domain.data.sales.model.QSales.sales; +import static com.dduckddak.domain.town.model.QIndustry.industry; import static com.dduckddak.domain.town.model.QTown.town; import static com.dduckddak.domain.town.model.QTownIndustry.townIndustry; @@ -101,7 +101,7 @@ public List findSalesForTransitionData() { town.quarter.in(20241L, 20234L, 20233L, 20232L, 20231L) ) .groupBy(town.name, town.quarter, town.code) - .orderBy(town.quarter.desc(), sales.currentMonthlySales.sum().desc()) + .orderBy(town.quarter.asc(), sales.currentMonthlySales.sum().desc()) .fetch(); } @@ -275,4 +275,27 @@ public List findSalesTop10OfIndustry(String name, return responseList; } + + @Override + public List findSalesByIndustryForTransitionData(String industryName) { + return queryFactory + .select(new QSalesForTransitionData( + town.name.stringValue(), + town.code.stringValue(), + town.quarter, + sales.currentMonthlySales + )) + .from(townIndustry) + .innerJoin(townIndustry.town, town) + .innerJoin(townIndustry.industry, industry) + .innerJoin(sales).on(sales.townIndustry.eq(townIndustry)) + .where( + industry.name.eq(industryName), + town.quarter.in(20241L, 20234L, 20233L, 20232L, 20231L) + ) + .orderBy(town.quarter.asc(), sales.currentMonthlySales.desc()) + .fetch(); + + + } } diff --git a/src/main/java/com/dduckddak/domain/data/sales/service/SalesService.java b/src/main/java/com/dduckddak/domain/data/sales/service/SalesService.java new file mode 100644 index 0000000..de81488 --- /dev/null +++ b/src/main/java/com/dduckddak/domain/data/sales/service/SalesService.java @@ -0,0 +1,110 @@ +package com.dduckddak.domain.data.sales.service; + +import com.dduckddak.domain.data.population.dto.TimelyDto; +import com.dduckddak.domain.data.sales.dto.*; +import com.dduckddak.domain.data.sales.repository.SalesRepository; +import com.dduckddak.domain.town.dto.SalesResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +@Slf4j +public class SalesService { + + private final SalesRepository salesRepository; + + public TimelyDto getSalesByCode(String code) { + return TimelyDto.from(salesRepository.findAllByTownCodeOrderByQuarterDesc(code)); + } + + public SalesResponse getSalesCompare(String code, String name) { + return SalesResponse.of(salesRepository.getSalesCompare(code, name, 20241L, 20234L), false); + } + + public List getSalesTop10(String orderCriteria) { + return salesRepository.findSalesTop10(orderCriteria); + } + + public List getSalesTop10OfIndustry(String name, String orderCriteria) { + return salesRepository.findSalesTop10OfIndustry(name, orderCriteria); + } + + public SalesTransitionResponse getSalesTransition(String code) { + List salesForTransitionData = salesRepository.findSalesForTransitionData(); + + + List salesDataList = new ArrayList<>(); + + long[] quarterArr = new long[]{20231L, 20232L, 20233L, 20234L ,20241L }; + for(long quarter : quarterArr){ + + List listOfCity = salesForTransitionData.stream().filter + (s -> s.getQuarter().equals(quarter)).toList(); + + SalesForTransitionData sales = listOfCity.stream().filter(s -> s.getTownCode().equals(code)).findFirst().get(); + Long salesAtTown = sales.getSalesAtTown(); + + int rankAtCity = listOfCity.indexOf(sales) + 1; // 20241분기 시 내 등수 + long salesAvgOfCity = (long) listOfCity.stream().mapToLong(s -> s.getSalesAtTown()).average().getAsDouble(); + + + List listOfDistrict = listOfCity.stream().filter + (s -> s.getTownName().split(" ")[0].equals(sales.getTownName().split(" ")[0])).toList(); + + int rankAtDistrict = listOfDistrict.indexOf(sales) + 1; // 20241분기 구 내 등수 + long populationAvgOfDistrict = (long) listOfDistrict.stream().mapToLong(s -> s.getSalesAtTown()).average().getAsDouble(); + + salesDataList.add(new SalesTransitionResponse.SalesData(sales.getTownName().split(" ")[1] ,quarter, sales.getSalesAtTown(), rankAtCity, salesAvgOfCity, rankAtDistrict, populationAvgOfDistrict)); + } + + return SalesTransitionResponse.from(salesDataList); + } + + public SalesTransitionByIndustryResponse getSalesTransitionByIndustry(String townCode, String industryName) { + List salesForTransitionData = salesRepository.findSalesByIndustryForTransitionData(industryName); + + + List salesDataList = new ArrayList<>(); + + long[] quarterArr = new long[]{20231L, 20232L, 20233L, 20234L ,20241L }; + for(long quarter : quarterArr){ + + List listOfCity = salesForTransitionData.stream().filter + (s -> s.getQuarter().equals(quarter)).toList(); + + SalesForTransitionData sales = listOfCity.stream().filter(s -> s.getTownCode().equals(townCode)).findFirst().get(); + Long salesAtTown = sales.getSalesAtTown(); + + int rankAtCity = listOfCity.indexOf(sales) + 1; // 20241분기 시 내 등수 + long salesAvgOfCity = (long) listOfCity.stream().mapToLong(s -> s.getSalesAtTown()).average().getAsDouble(); + + + List listOfDistrict = listOfCity.stream().filter + (s -> s.getTownName().split(" ")[0].equals(sales.getTownName().split(" ")[0])).toList(); + + int rankAtDistrict = listOfDistrict.indexOf(sales) + 1; // 20241분기 구 내 등수 + long populationAvgOfDistrict = (long) listOfDistrict.stream().mapToLong(s -> s.getSalesAtTown()).average().getAsDouble(); + + salesDataList.add(new SalesTransitionByIndustryResponse.SalesData(sales.getTownName().split(" ")[1], industryName, quarter, sales.getSalesAtTown(), rankAtCity, salesAvgOfCity, rankAtDistrict, populationAvgOfDistrict)); + } + + return SalesTransitionByIndustryResponse.from(salesDataList); + } + + public SalesRateByGenderAndIndustryResponse getSalesRateByGenderAndIndustry(String townCode, String industryName) { + SalesRateByGenderAndIndustryResponse salesRateByGenderAndIndustry = salesRepository.findSalesRateByGenderAndIndustry(townCode, industryName); + return salesRateByGenderAndIndustry; + } + + public SalesRateByAgeAndIndustryResponse getSalesRateByAgeAndIndustry(String townCode, String industryName) { + SalesRateByAgeAndIndustryResponse salesRateByAgeAndIndustryResponse = salesRepository.findSalesRateByAgeAndIndustry(townCode, industryName); + return salesRateByAgeAndIndustryResponse; + } +} diff --git a/src/main/java/com/dduckddak/domain/data/service/SalesService.java b/src/main/java/com/dduckddak/domain/data/service/SalesService.java deleted file mode 100644 index 4c52c7d..0000000 --- a/src/main/java/com/dduckddak/domain/data/service/SalesService.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.dduckddak.domain.data.service; - -import com.dduckddak.domain.data.dto.*; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.repository.sales.SalesRepository; -import com.dduckddak.domain.town.dto.SalesResponse; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.List; - -@Service -@RequiredArgsConstructor -@Transactional(readOnly = true) -@Slf4j -public class SalesService { - - private final SalesRepository salesRepository; - - public TimelyDto getSalesByCode(String code) { - return TimelyDto.from(salesRepository.findAllByTownCodeOrderByQuarterDesc(code)); - } - - public SalesResponse getSalesCompare(String code, String name) { - return SalesResponse.of(salesRepository.getSalesCompare(code, name, 20241L, 20234L), false); - } - - public List getSalesTop10(String orderCriteria) { - return salesRepository.findSalesTop10(orderCriteria); - } - - public List getSalesTop10OfIndustry(String name, String orderCriteria) { - return salesRepository.findSalesTop10OfIndustry(name, orderCriteria); - } - - public SalesTransitionResponse getSalesTransition(String code) { - List salesForTransitionData = salesRepository.findSalesForTransitionData(); - - - List salesDataList = new ArrayList<>(); - - long[] quarterArr = new long[]{20241L, 20234L, 20233L, 20232L, 20231L}; - for(long quarter : quarterArr){ - - List listOfCity = salesForTransitionData.stream().filter - (s -> s.getQuarter().equals(quarter)).toList(); - - SalesForTransitionData sales = listOfCity.stream().filter(s -> s.getTownCode().equals(code)).findFirst().get(); - Long salesAtTown = sales.getSalesAtTown(); - - int rankAtCity = listOfCity.indexOf(sales) + 1; // 20241분기 시 내 등수 - long salesAvgOfCity = (long) listOfCity.stream().mapToLong(s -> s.getSalesAtTown()).average().getAsDouble(); - - - List listOfDistrict = listOfCity.stream().filter - (s -> s.getTownName().split(" ")[0].equals(sales.getTownName().split(" ")[0])).toList(); - - int rankAtDistrict = listOfDistrict.indexOf(sales) + 1; // 20241분기 구 내 등수 - long populationAvgOfDistrict = (long) listOfDistrict.stream().mapToLong(s -> s.getSalesAtTown()).average().getAsDouble(); - - salesDataList.add(new SalesTransitionResponse.SalesData(quarter, sales.getSalesAtTown(), rankAtCity, salesAvgOfCity, rankAtDistrict, populationAvgOfDistrict)); - } - - return SalesTransitionResponse.from(salesDataList); - } -} diff --git a/src/main/java/com/dduckddak/domain/town/controller/TownIndustryController.java b/src/main/java/com/dduckddak/domain/town/controller/TownIndustryController.java index f9e6954..2e91212 100644 --- a/src/main/java/com/dduckddak/domain/town/controller/TownIndustryController.java +++ b/src/main/java/com/dduckddak/domain/town/controller/TownIndustryController.java @@ -1,16 +1,14 @@ package com.dduckddak.domain.town.controller; -import com.dduckddak.domain.data.dto.*; -import com.dduckddak.domain.town.dto.RecentlyTownIndustryResponse; -import com.dduckddak.domain.town.dto.SalesResponse; -import com.dduckddak.domain.town.dto.SimilarTownIndustryDto; +import com.dduckddak.domain.data.markettrends.dto.MarketAnalysisResponse; +import com.dduckddak.domain.data.markettrends.dto.MarketTrendsResponse; +import com.dduckddak.domain.town.dto.*; import com.dduckddak.domain.town.service.TownIndustryService; import com.dduckddak.global.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; diff --git a/src/main/java/com/dduckddak/domain/data/dto/StoreCountTop10OfIndustryResponse.java b/src/main/java/com/dduckddak/domain/town/dto/StoreCountTop10OfIndustryResponse.java similarity index 92% rename from src/main/java/com/dduckddak/domain/data/dto/StoreCountTop10OfIndustryResponse.java rename to src/main/java/com/dduckddak/domain/town/dto/StoreCountTop10OfIndustryResponse.java index 5b7591e..908c62b 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/StoreCountTop10OfIndustryResponse.java +++ b/src/main/java/com/dduckddak/domain/town/dto/StoreCountTop10OfIndustryResponse.java @@ -1,8 +1,7 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.town.dto; import lombok.Builder; -import lombok.Generated; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/dduckddak/domain/data/dto/StoreCountTop10Response.java b/src/main/java/com/dduckddak/domain/town/dto/StoreCountTop10Response.java similarity index 94% rename from src/main/java/com/dduckddak/domain/data/dto/StoreCountTop10Response.java rename to src/main/java/com/dduckddak/domain/town/dto/StoreCountTop10Response.java index 547cdff..5cb0dd7 100644 --- a/src/main/java/com/dduckddak/domain/data/dto/StoreCountTop10Response.java +++ b/src/main/java/com/dduckddak/domain/town/dto/StoreCountTop10Response.java @@ -1,4 +1,4 @@ -package com.dduckddak.domain.data.dto; +package com.dduckddak.domain.town.dto; import lombok.Builder; diff --git a/src/main/java/com/dduckddak/domain/data/repository/IndustryBulkRepository.java b/src/main/java/com/dduckddak/domain/town/repository/IndustryBulkRepository.java similarity index 90% rename from src/main/java/com/dduckddak/domain/data/repository/IndustryBulkRepository.java rename to src/main/java/com/dduckddak/domain/town/repository/IndustryBulkRepository.java index 2f0b9ad..3222914 100644 --- a/src/main/java/com/dduckddak/domain/data/repository/IndustryBulkRepository.java +++ b/src/main/java/com/dduckddak/domain/town/repository/IndustryBulkRepository.java @@ -1,6 +1,5 @@ -package com.dduckddak.domain.data.repository; +package com.dduckddak.domain.town.repository; -import com.dduckddak.domain.data.model.Sales; import com.dduckddak.domain.town.model.Industry; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dduckddak/domain/town/repository/TownBulkRepository.java b/src/main/java/com/dduckddak/domain/town/repository/TownBulkRepository.java index 3c07fb9..afbf9c3 100644 --- a/src/main/java/com/dduckddak/domain/town/repository/TownBulkRepository.java +++ b/src/main/java/com/dduckddak/domain/town/repository/TownBulkRepository.java @@ -1,6 +1,5 @@ package com.dduckddak.domain.town.repository; -import com.dduckddak.domain.data.model.Population; import com.dduckddak.domain.town.model.Town; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepository.java b/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepository.java index 905057b..e3a86fa 100644 --- a/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepository.java +++ b/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepository.java @@ -1,6 +1,6 @@ package com.dduckddak.domain.town.repository; -import com.dduckddak.domain.data.dto.*; +import com.dduckddak.domain.data.sales.dto.SalesDiffVO; import com.dduckddak.domain.town.model.Industry; import com.dduckddak.domain.town.model.Town; import com.dduckddak.domain.town.model.TownIndustry; @@ -8,8 +8,6 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.util.List; - public interface TownIndustryRepository extends JpaRepository, TownIndustryRepositoryCustom { @Query(value = "SELECT \n" + diff --git a/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepositoryCustom.java b/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepositoryCustom.java index 6ff2562..26c4698 100644 --- a/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepositoryCustom.java +++ b/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepositoryCustom.java @@ -1,11 +1,9 @@ package com.dduckddak.domain.town.repository; -import com.dduckddak.domain.data.dto.StoreCountTop10OfIndustryResponse; -import com.dduckddak.domain.data.dto.StoreCountTop10Response; +import com.dduckddak.domain.town.dto.StoreCountTop10OfIndustryResponse; +import com.dduckddak.domain.town.dto.StoreCountTop10Response; import com.dduckddak.domain.town.dto.RecentlyTownIndustryResponse; import com.dduckddak.domain.town.dto.SimilarTownIndustryDto; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; import java.util.List; diff --git a/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepositoryImpl.java b/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepositoryImpl.java index 3b66772..963eb4f 100644 --- a/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepositoryImpl.java +++ b/src/main/java/com/dduckddak/domain/town/repository/TownIndustryRepositoryImpl.java @@ -1,8 +1,7 @@ package com.dduckddak.domain.town.repository; -import com.dduckddak.domain.data.dto.SalesTop10OfIndustryResponse; -import com.dduckddak.domain.data.dto.StoreCountTop10OfIndustryResponse; -import com.dduckddak.domain.data.dto.StoreCountTop10Response; +import com.dduckddak.domain.town.dto.StoreCountTop10OfIndustryResponse; +import com.dduckddak.domain.town.dto.StoreCountTop10Response; import com.dduckddak.domain.town.dto.QRecentlyTownIndustryResponse; import com.dduckddak.domain.town.dto.QSimilarTownIndustryDto; import com.dduckddak.domain.town.dto.RecentlyTownIndustryResponse; diff --git a/src/main/java/com/dduckddak/domain/town/service/TownIndustryService.java b/src/main/java/com/dduckddak/domain/town/service/TownIndustryService.java index 24f1b0a..ab15b41 100644 --- a/src/main/java/com/dduckddak/domain/town/service/TownIndustryService.java +++ b/src/main/java/com/dduckddak/domain/town/service/TownIndustryService.java @@ -1,17 +1,16 @@ package com.dduckddak.domain.town.service; -import com.dduckddak.domain.data.dto.*; -import com.dduckddak.domain.data.model.MarketTrends; -import com.dduckddak.domain.data.model.Population; -import com.dduckddak.domain.data.model.PopulationType; -import com.dduckddak.domain.data.model.Sales; -import com.dduckddak.domain.data.repository.MarketTrendRepository; -import com.dduckddak.domain.data.repository.PopulationRepository; -import com.dduckddak.domain.data.repository.sales.SalesRepository; -import com.dduckddak.domain.town.dto.RecentlyTownIndustryResponse; -import com.dduckddak.domain.town.dto.SalesResponse; -import com.dduckddak.domain.town.dto.SalesVO; -import com.dduckddak.domain.town.dto.SimilarTownIndustryDto; +import com.dduckddak.domain.data.markettrends.dto.MarketAnalysisResponse; +import com.dduckddak.domain.data.markettrends.dto.MarketTrendsResponse; +import com.dduckddak.domain.data.markettrends.model.MarketTrends; +import com.dduckddak.domain.data.population.model.Population; +import com.dduckddak.domain.data.population.model.PopulationType; +import com.dduckddak.domain.data.sales.dto.SalesDiffVO; +import com.dduckddak.domain.data.sales.model.Sales; +import com.dduckddak.domain.data.markettrends.repository.MarketTrendRepository; +import com.dduckddak.domain.data.population.repository.PopulationRepository; +import com.dduckddak.domain.data.sales.repository.SalesRepository; +import com.dduckddak.domain.town.dto.*; import com.dduckddak.domain.town.model.Industry; import com.dduckddak.domain.town.model.Town; import com.dduckddak.domain.town.model.TownIndustry; diff --git a/src/main/java/com/dduckddak/global/security/oauth/OAuthSuccessHandler.java b/src/main/java/com/dduckddak/global/security/oauth/OAuthSuccessHandler.java index f62e63e..60ce990 100644 --- a/src/main/java/com/dduckddak/global/security/oauth/OAuthSuccessHandler.java +++ b/src/main/java/com/dduckddak/global/security/oauth/OAuthSuccessHandler.java @@ -1,9 +1,9 @@ package com.dduckddak.global.security.oauth; -import com.dduckddak.domain.member.model.Member; -import com.dduckddak.domain.member.model.MemberRole; -import com.dduckddak.domain.member.repository.MemberRepository; +import com.dduckddak.domain.data.member.model.Member; +import com.dduckddak.domain.data.member.model.MemberRole; +import com.dduckddak.domain.data.member.repository.MemberRepository; import com.dduckddak.global.security.jwt.JwtProvider; import com.dduckddak.global.security.jwt.JwtToken; import com.dduckddak.global.security.jwt.JwtUtils; @@ -12,7 +12,6 @@ import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseCookie; import org.springframework.security.core.Authentication; import org.springframework.security.oauth2.core.user.OAuth2User;