diff --git a/src/main/java/com/goi/erp/SecurityApplication.java b/src/main/java/com/goi/erp/SecurityApplication.java index f7c79a2..295217b 100644 --- a/src/main/java/com/goi/erp/SecurityApplication.java +++ b/src/main/java/com/goi/erp/SecurityApplication.java @@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -@SpringBootApplication +@SpringBootApplication(scanBasePackages = {"com.goi.erp"}) @EnableJpaAuditing(auditorAwareRef = "auditorAware") @EntityScan(basePackages = {"com.goi.erp.entity"}) @EnableJpaRepositories(basePackages = {"com.goi.erp.repository"}) diff --git a/src/main/java/com/goi/erp/dto/CustomerRequestDto.java b/src/main/java/com/goi/erp/dto/CustomerRequestDto.java index efd0e18..cce1365 100644 --- a/src/main/java/com/goi/erp/dto/CustomerRequestDto.java +++ b/src/main/java/com/goi/erp/dto/CustomerRequestDto.java @@ -1,11 +1,13 @@ package com.goi.erp.dto; import lombok.Data; +import lombok.NoArgsConstructor; import java.math.BigDecimal; import java.time.LocalDate; @Data +@NoArgsConstructor public class CustomerRequestDto { private String cusNo; // c_accountno @@ -56,7 +58,7 @@ public class CustomerRequestDto { private String cusComment; private Integer cusLastPickupMin; - private String loginUser; + private String cusLoginUser; } diff --git a/src/main/java/com/goi/erp/repository/CustomerRepository.java b/src/main/java/com/goi/erp/repository/CustomerRepository.java index ad7594e..375de11 100644 --- a/src/main/java/com/goi/erp/repository/CustomerRepository.java +++ b/src/main/java/com/goi/erp/repository/CustomerRepository.java @@ -1,12 +1,10 @@ package com.goi.erp.repository; -import com.goi.erp.dto.CustomerResponseDto; import com.goi.erp.entity.Customer; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import java.util.Optional; @@ -14,25 +12,10 @@ import java.util.UUID; @Repository public interface CustomerRepository extends JpaRepository { - @Query("SELECT new com.goi.erp.dto.CustomerResponseDto(" + - "c.cusUuid, c.cusNo, c.cusName, c.cusStatus, c.cusAreaId, " + - "c.cusAddress1, c.cusAddress2, c.cusPostalCode, c.cusCity, c.cusProvince, " + - "c.cusGeoLat, c.cusGeoLon, c.cusEmail, c.cusPhone, c.cusPhoneExt, " + - "c.cusOpenTime, c.cusComment, c.cusContractDate, c.cusContractedBy, c.cusInstallDate, c.cusInstallLocation) " + - "FROM Customer c WHERE c.cusUuid = :uuid") - Optional findCustomerDtoByCusUuid(UUID uuid); - @Query("SELECT new com.goi.erp.dto.CustomerResponseDto(" + - "c.cusUuid, c.cusNo, c.cusName, c.cusStatus, c.cusAreaId, " + - "c.cusAddress1, c.cusAddress2, c.cusPostalCode, c.cusCity, c.cusProvince, " + - "c.cusGeoLat, c.cusGeoLon, c.cusEmail, c.cusPhone, c.cusPhoneExt, " + - "c.cusOpenTime, c.cusComment, c.cusContractDate, c.cusContractedBy, c.cusInstallDate, c.cusInstallLocation) " + - "FROM Customer c") - Page findAllCustomerDtos(Pageable pageable); + Page findAll(Pageable pageable); Optional findByCusUuid(UUID cusUuid); - - // from MIS Optional findByCusNo(String cusNo); boolean existsByCusNo(String cusNo); diff --git a/src/main/java/com/goi/erp/service/CustomerService.java b/src/main/java/com/goi/erp/service/CustomerService.java index 5dca64f..5f29daf 100644 --- a/src/main/java/com/goi/erp/service/CustomerService.java +++ b/src/main/java/com/goi/erp/service/CustomerService.java @@ -80,15 +80,17 @@ public class CustomerService { customer = customerRepository.save(customer); return mapToDto(customer); // 생성 시에는 여전히 엔티티 → DTO 필요 } - + public Page getAllCustomers(int page, int size) { Pageable pageable = PageRequest.of(page, size); - return customerRepository.findAllCustomerDtos(pageable); // DTO 바로 조회 + Page customers = customerRepository.findAll(pageable); + return customers.map(this::mapToDto); // 기존 mapToDto 사용 } public CustomerResponseDto getCustomerByUuid(UUID uuid) { - return customerRepository.findCustomerDtoByCusUuid(uuid) + Customer customer = customerRepository.findByCusUuid(uuid) .orElseThrow(() -> new RuntimeException("Customer not found")); + return mapToDto(customer); } public CustomerResponseDto updateCustomer(UUID uuid, CustomerRequestDto dto) { @@ -226,7 +228,7 @@ public class CustomerService { CustomerResponseDto response = updateCustomerInternal(oldCustomer, newCustomer); // 4. 변경 비교 (old vs new) - String misLoginUser = newCustomer.getLoginUser(); // todo: 내부 loginId 로 변경 + String misLoginUser = newCustomer.getCusLoginUser(); // todo: 내부 loginId 로 변경 String loginId = SecurityContextHolder.getContext().getAuthentication().getName(); // 현재는 MIS login user compareAndLogChanges(beforeUpdate, oldCustomer, misLoginUser, loginId);