Commit 2cbe3756 authored by Phạm Duy Phi's avatar Phạm Duy Phi

phipd commit: commit

parent 373e6d79
...@@ -21,4 +21,7 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long ...@@ -21,4 +21,7 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long
@Modifying @Modifying
@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 *, MAX(CREATE_AT) OVER() AS LATEST_CREATED FROM CUSTOMER_LIST) WHERE CREATE_AT = LATEST_CREATED", nativeQuery = true)
CustomerList latestCreated();
} }
package com.viettel.campaign.service; package com.viettel.campaign.service;
import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.web.dto.CustomerDTO; import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO; import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
...@@ -34,6 +35,8 @@ public interface CustomerService { ...@@ -34,6 +35,8 @@ public interface CustomerService {
ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO); ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO);
CustomerList getLatestCreated();
// ------------ customer contact ------------ // // ------------ customer contact ------------ //
ResultDTO getCustomerContact(Long customerId, Short contactType, String contact); ResultDTO getCustomerContact(Long customerId, Short contactType, String contact);
......
...@@ -156,9 +156,15 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -156,9 +156,15 @@ public class CustomerServiceImpl implements CustomerService {
StringBuilder sqlStrBuilder = new StringBuilder(); StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params")); sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params"));
sqlStrBuilder.append(" AND "); if (!DataUtil.isNullOrEmpty(name)) {
sqlStrBuilder.append(" ORDER BY name DESC"); sqlStrBuilder.append(" AND b.NAME LIKE :p_name");
sqlStrBuilder.append(" ORDER BY name DESC"); }
if (!DataUtil.isNullOrEmpty(mobileNumber)) {
sqlStrBuilder.append(" AND c.MOBILE LIKE :p_mobile_number");
}
if (!DataUtil.isNullOrEmpty(email)) {
sqlStrBuilder.append(" AND d.EMAIL LIKE :p_email");
}
sqlStrBuilder.append(" ORDER BY name DESC"); sqlStrBuilder.append(" ORDER BY name DESC");
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString()); SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
...@@ -166,6 +172,30 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -166,6 +172,30 @@ public class CustomerServiceImpl implements CustomerService {
query.setParameter("p_company_site_id", companySiteId); query.setParameter("p_company_site_id", companySiteId);
query.setParameter("p_customer_list_id", customerListId); query.setParameter("p_customer_list_id", customerListId);
if (!DataUtil.isNullOrEmpty(name)) {
query.setParameter("p_name", "%" +
name.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(mobileNumber)) {
query.setParameter("p_mobile_number", "%" +
mobileNumber.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(email)) {
query.setParameter("p_email", "%" +
email.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
query.addScalar("customerListMappingId", new LongType()); query.addScalar("customerListMappingId", new LongType());
query.addScalar("companySiteId", new LongType()); query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType()); query.addScalar("customerListId", new LongType());
...@@ -570,6 +600,11 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -570,6 +600,11 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO; return resultDTO;
} }
@Override
public CustomerList getLatestCreated() {
return customerListRepository.latestCreated();
}
@Override @Override
public ResultDTO getCustomerContact(Long customerId, Short contactType, String contact) { public ResultDTO getCustomerContact(Long customerId, Short contactType, String contact) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
......
...@@ -25,7 +25,6 @@ import java.io.File; ...@@ -25,7 +25,6 @@ import java.io.File;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
@Controller @Controller
@RequestMapping("/ipcc/customer") @RequestMapping("/ipcc/customer")
...@@ -164,6 +163,14 @@ public class CustomerController { ...@@ -164,6 +163,14 @@ public class CustomerController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/latestCreated")
@ResponseBody
public ResponseEntity getLatestCreated() {
ResultDTO result = new ResultDTO();
result.setData(customerService.getLatestCreated());
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/findCustomerContact") @GetMapping("/findCustomerContact")
@ResponseBody @ResponseBody
public ResponseEntity<ResultDTO> findAllCustomerContact(@RequestParam("customerId") Long customerId, @RequestParam("contactType") Short contactType, @RequestParam("contact") String contact) { public ResponseEntity<ResultDTO> findAllCustomerContact(@RequestParam("customerId") Long customerId, @RequestParam("contactType") Short contactType, @RequestParam("contact") String contact) {
......
...@@ -12,4 +12,5 @@ SELECT ...@@ -12,4 +12,5 @@ SELECT
DEPT_CREATE deptCreate DEPT_CREATE deptCreate
FROM CUSTOMER_LIST FROM CUSTOMER_LIST
WHERE 1 = 1 WHERE 1 = 1
AND STATUS = 1
AND COMPANY_SITE_ID = :p_company_site_id AND COMPANY_SITE_ID = :p_company_site_id
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