Commit 6c7fd6f6 authored by Phạm Duy Phi's avatar Phạm Duy Phi

phipd commit

parent b18de655
...@@ -22,6 +22,6 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long ...@@ -22,6 +22,6 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long
@Query("update CustomerList c set c.status = 0 where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id") @Query("update CustomerList c set c.status = 0 where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id")
int deleteCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id); int deleteCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
@Query(value = "SELECT * FROM (SELECT c.*, MAX(c.CREATE_AT) OVER() AS LATEST_CREATED FROM CUSTOMER_LIST c) WHERE CREATE_AT = LATEST_CREATED", nativeQuery = true) @Query(value = "SELECT * FROM (SELECT c.*, MAX(c.CREATE_AT) OVER() AS LATEST_CREATED FROM CUSTOMER_LIST c) WHERE CREATE_AT = LATEST_CREATED AND COMPANY_SITE_ID =:p_company_site_id", nativeQuery = true)
CustomerList latestCreated(); CustomerList latestCreated(@Param("p_company_site_id") Long p_company_site_id);
} }
...@@ -36,7 +36,7 @@ public interface CustomerService { ...@@ -36,7 +36,7 @@ public interface CustomerService {
ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO); ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO);
CustomerList getLatestCreated(); CustomerList getLatestCreated(Long companySiteId);
// ------------ customer contact ------------ // // ------------ customer contact ------------ //
......
...@@ -602,8 +602,8 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -602,8 +602,8 @@ public class CustomerServiceImpl implements CustomerService {
} }
@Override @Override
public CustomerList getLatestCreated() { public CustomerList getLatestCreated(Long companySiteId) {
return customerListRepository.latestCreated(); return customerListRepository.latestCreated(companySiteId);
} }
@Override @Override
......
...@@ -53,7 +53,7 @@ public class CustomerController { ...@@ -53,7 +53,7 @@ public class CustomerController {
@GetMapping("/searchAllCustomerByParams") @GetMapping("/searchAllCustomerByParams")
@ResponseBody @ResponseBody
public ResponseEntity findAllCustomerName(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("customerListId") Long customerListId, @RequestParam("companySiteId") Long companySiteId, @RequestParam("name") String name, @RequestParam("mobileNumber") String mobileNumber, @RequestParam("email") String email) { public ResponseEntity findAllCustomerByParams(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("customerListId") Long customerListId, @RequestParam("companySiteId") Long companySiteId, @RequestParam("name") String name, @RequestParam("mobileNumber") String mobileNumber, @RequestParam("email") String email) {
ResultDTO result = customerService.searchAllCustomer(page, pageSize, sort, customerListId, companySiteId, name, mobileNumber, email); ResultDTO result = customerService.searchAllCustomer(page, pageSize, sort, customerListId, companySiteId, name, mobileNumber, email);
return new ResponseEntity(result, HttpStatus.OK); return new ResponseEntity(result, HttpStatus.OK);
} }
...@@ -166,9 +166,9 @@ public class CustomerController { ...@@ -166,9 +166,9 @@ public class CustomerController {
@GetMapping("/latestCreated") @GetMapping("/latestCreated")
@ResponseBody @ResponseBody
public ResponseEntity getLatestCreated() { public ResponseEntity getLatestCreated(@RequestParam("companySiteId") Long companySiteId) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
result.setData(customerService.getLatestCreated()); result.setData(customerService.getLatestCreated(companySiteId));
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment