Customer 페이지 추가.
This commit is contained in:
parent
7377f7b663
commit
206fcf615b
|
|
@ -5,6 +5,7 @@ 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.time.LocalDate;
|
||||
|
|
@ -20,6 +21,10 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
|
|||
Optional<Customer> findByCusNo(String cusNo);
|
||||
|
||||
boolean existsByCusNo(String cusNo);
|
||||
|
||||
@Query(value = "select c from Customer c order by c.cusContractDate desc nulls last",
|
||||
countQuery = "select count(c) from Customer c")
|
||||
Page<Customer> findAllOrderByContractDateDesc(Pageable pageable);
|
||||
|
||||
// 현재(활성) 고객 수: cus_status = 'A'
|
||||
long countByCusStatus(String cusStatus);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class CustomerService {
|
|||
|
||||
public Page<CustomerResponseDto> getAllCustomers(int page, int size) {
|
||||
Pageable pageable = PageRequest.of(page, size);
|
||||
Page<Customer> customers = customerRepository.findAll(pageable);
|
||||
Page<Customer> customers = customerRepository.findAllOrderByContractDateDesc(pageable);
|
||||
return customers.map(this::mapToDto); // 기존 mapToDto 사용
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue