Commit e32be465 authored by Phạm Duy Phi's avatar Phạm Duy Phi

phi pd commit: commit

parent 3dd1723b
......@@ -13,20 +13,20 @@ public interface CustomerListMappingRepository extends JpaRepository<CustomerLis
// ----------- customer ------------ //
@Modifying
@Query("delete from CustomerListMapping c where c.customerId=:p_customer_id and c.customerListId=:p_customer_list_id")
int deleteMappingByCustomerId(@Param("p_customer_id") Long p_customer_id, @Param("p_customer_list_id") Long p_customer_list_id);
@Query("delete from CustomerListMapping c where c.customerId=:p_customer_id and c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerId(@Param("p_customer_id") Long p_customer_id, @Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@Query("delete from CustomerListMapping c where c.customerId in (:p_id) and c.customerListId =:p_customer_list_id")
int deleteMappingByCustomerIds(@Param("p_id") List<Long> p_id, @Param("p_customer_list_id") Long p_customer_list_id);
@Query("delete from CustomerListMapping c where c.customerId in (:p_ids) and c.customerListId =:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerIds(@Param("p_ids") List<Long> p_ids, @Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
// ----------- customer list --------------- //
@Modifying
@Query("delete from CustomerListMapping c where c.customerListId=:p_customerListId")
int deleteMappingByCustomerListId(@Param("p_customerListId") Long p_customerListId);
@Query("delete from CustomerListMapping c where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerListId(@Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@Query("delete from CustomerListMapping c where c.customerListId in (:p_ids)")
int deleteMappingByCustomerListIds(@Param("p_ids") List<Long> p_ids);
@Query("delete from CustomerListMapping c where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
}
......@@ -10,15 +10,15 @@ import java.util.List;
public interface CustomerListRepository extends JpaRepository<CustomerList, Long> {
CustomerList findCustomerListByCustomerListId(long customerListId);
CustomerList findByCustomerListIdAndCompanySiteId(long customerListId, long companySiteId);
CustomerList findByCustomerListCode(String customerListCode);
@Modifying
@Query("update CustomerList c set c.status = 0 where c.customerListId=:p_customerListId")
int deleteCustomerList(@Param("p_customerListId") Long p_customerListId);
@Query("update CustomerList c set c.status = 0 where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteCustomerList(@Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@Query("update CustomerList c set c.status = 0 where c.customerListId in (:p_ids)")
int deleteCustomerListIds(@Param("p_ids") List<Long> p_ids);
@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);
}
......@@ -3,24 +3,22 @@ package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.DeleteCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface CustomerService {
Map listAllCustomer(int page, int pageSize, String sort);
ResultDTO listAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId);
Map listCustByName(int page, int pageSize, String sort, String name);
ResultDTO createCustomer(CustomerDTO customerDTO);
ResultDTO deleteCustomer(DeleteCustomerRequestDTO deleteCustomerRequestDTO);
ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO);
ResultDTO deleteIds(DeleteCustomerRequestDTO deleteCustomerRequestDTO);
ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO);
// ------------ customer list ------------ //
......@@ -32,7 +30,7 @@ public interface CustomerService {
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerListIds(List<Long> ids);
ResultDTO deleteCustomerListIds(CustomerRequestDTO customerRequestDTO);
ResultDTO searchCustomerList(CampaignCustomerRequestDTO campaignCustomerRequestDTO);
ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO);
}
......@@ -9,6 +9,7 @@ import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.CustomerCustomDTO;
import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
......@@ -16,8 +17,8 @@ import com.viettel.campaign.mapper.CustomerMapper;
import com.viettel.campaign.model.Customer;
import com.viettel.campaign.repository.CustomerRepository;
import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.web.dto.request_dto.CampaignCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.DeleteCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
......@@ -54,17 +55,76 @@ public class CustomerServiceImpl implements CustomerService {
CustomerListMappingRepository customerListMappingRepository;
@Override
public Map listAllCustomer(int page, int pageSize, String sort) {
Map result = new HashMap();
List<Customer> lst = new ArrayList<>();
public ResultDTO listAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId) {
// Map result = new HashMap();
// List<Customer> lst = new ArrayList<>();
//
// Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
// Page<Customer> pc = customerRepository.findAll(pageable);
//
// result.put("totalItem", pc.getTotalElements());
// result.put("customers", pc.iterator());
//
// return result;
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
try {
StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params"));
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
query.setParameter("p_company_site_id", companySiteId);
query.setParameter("p_customer_list_id", customerListId);
query.addScalar("customerListMappingId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType());
query.addScalar("customerId", new LongType());
query.addScalar("name", new StringType());
query.addScalar("description", new StringType());
query.addScalar("companyName", new StringType());
query.addScalar("customerType", new StringType());
query.addScalar("currentAddress", new StringType());
query.addScalar("mobileNumber", new StringType());
query.addScalar("email", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerCustomDTO.class));
int count = 0;
List<CustomerListDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
// Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
// if (pageable != null) {
// query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
// query.setMaxResults(pageable.getPageSize());
// }
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
Page<Customer> pc = customerRepository.findAll(pageable);
result.put("totalItem", pc.getTotalElements());
result.put("customers", pc.iterator());
List<CustomerListDTO> data = query.list();
Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count);
resultDTO.setData(dataPage);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
}
return result;
return resultDTO;
}
@Override
......@@ -116,14 +176,15 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO;
}
@Transactional
@Override
public ResultDTO deleteCustomer(DeleteCustomerRequestDTO deleteCustomerRequestDTO) {
public ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
try {
if (deleteCustomerRequestDTO != null) {
if (customerRequestDTO != null) {
// delete
// customerRepository.deleteById(customerDTO.getCustomerId());
customerListMappingRepository.deleteMappingByCustomerId(deleteCustomerRequestDTO.getCustomerId(), deleteCustomerRequestDTO.getCustomerListId());
customerListMappingRepository.deleteMappingByCustomerId(customerRequestDTO.getCustomerId(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......@@ -140,12 +201,12 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional
@Override
public ResultDTO deleteIds(DeleteCustomerRequestDTO deleteCustomerRequestDTO) {
public ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
try {
if (deleteCustomerRequestDTO != null) {
if (customerRequestDTO != null) {
// customerRepository.deleteIds(ids);
customerListMappingRepository.deleteMappingByCustomerIds(deleteCustomerRequestDTO.getCustomerIds(), deleteCustomerRequestDTO.getCustomerListId());
customerListMappingRepository.deleteMappingByCustomerIds(customerRequestDTO.getIds(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
......@@ -222,11 +283,13 @@ public class CustomerServiceImpl implements CustomerService {
public ResultDTO updateCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = customerListRepository.findCustomerListByCustomerListId(customerListDTO.getCustomerListId());
try {
if (customerListDTO != null) {
// update
CustomerList customerList = customerListRepository.findByCustomerListIdAndCompanySiteId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
if (customerList != null) {
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerListRepository.save(customerList);
......@@ -236,6 +299,10 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
......@@ -252,9 +319,9 @@ public class CustomerServiceImpl implements CustomerService {
// delete
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) {
customerListRepository.deleteCustomerList(customerListDTO.getCustomerListId());
customerListRepository.deleteCustomerList(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId());
customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......@@ -272,14 +339,14 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional
@Override
public ResultDTO deleteCustomerListIds(List<Long> ids) {
public ResultDTO deleteCustomerListIds(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
try {
if (ids != null) {
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignIdsCount(ids))) {
customerListRepository.deleteCustomerListIds(ids);
if (customerRequestDTO != null) {
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignIdsCount(customerRequestDTO.getIds()))) {
customerListRepository.deleteCustomerListIds(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId());
customerListMappingRepository.deleteMappingByCustomerListIds(ids);
customerListMappingRepository.deleteMappingByCustomerListIds(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......@@ -298,14 +365,14 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
public ResultDTO searchCustomerList(CampaignCustomerRequestDTO campaignCustomerRequestDTO) {
public ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
if (DataUtil.isNullOrEmpty(campaignCustomerRequestDTO.getCompanySiteId())) {
if (DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCompanySiteId())) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
......@@ -314,33 +381,34 @@ public class CustomerServiceImpl implements CustomerService {
try {
StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params"));
if (DataUtil.isNullOrEmpty(campaignCustomerRequestDTO.getCustomerListCode())) {
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_CODE LIKE :p_list_code");
}
if (DataUtil.isNullOrEmpty(campaignCustomerRequestDTO.getCustomerListName())) {
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListName())) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name");
}
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
query.setParameter("p_date_from", campaignCustomerRequestDTO.getConvertedDateFrom());
query.setParameter("p_date_to", campaignCustomerRequestDTO.getConvertedDateTo());
query.setParameter("p_date_from", searchCustomerRequestDTO.getConvertedDateFrom());
query.setParameter("p_date_to", searchCustomerRequestDTO.getConvertedDateTo());
query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId());
if (!campaignCustomerRequestDTO.getCustomerListCode().equals("undefined")) {
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
query.setParameter("p_list_code", "%" +
campaignCustomerRequestDTO.getCustomerListCode()
searchCustomerRequestDTO.getCustomerListCode()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!campaignCustomerRequestDTO.getCustomerListName().equals("undefined")) {
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListName())) {
query.setParameter("p_list_name", "%" +
campaignCustomerRequestDTO.getCustomerListName()
searchCustomerRequestDTO.getCustomerListName()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
......@@ -362,11 +430,12 @@ public class CustomerServiceImpl implements CustomerService {
if (dtoList.size() > 0) {
count = query.list().size();
}
Pageable pageable = SQLBuilder.buildPageable(campaignCustomerRequestDTO);
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
// Pageable pageable = SQLBuilder.buildPageable(searchCustomerRequestDTO);
// if (pageable != null) {
// query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
// query.setMaxResults(pageable.getPageSize());
// }
Pageable pageable = PageRequest.of(searchCustomerRequestDTO.getPage(), searchCustomerRequestDTO.getPageSize(), Sort.by(searchCustomerRequestDTO.getSort()));
List<CustomerListDTO> data = query.list();
Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count);
......
......@@ -5,7 +5,6 @@ import java.nio.file.Paths;
import java.io.IOException;
import com.viettel.campaign.web.dto.BaseDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
......
package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CustomerCustomDTO {
Long customerListMappingId;
Long companySiteId;
Long customerListId;
Long customerId;
String name;
String description;
String companyName;
String customerType;
String currentAddress;
String mobileNumber;
String email;
}
......@@ -7,8 +7,9 @@ import java.util.List;
@Getter
@Setter
public class DeleteCustomerRequestDTO {
public class CustomerRequestDTO {
Long customerId;
Long customerListId;
List<Long> customerIds;
List<Long> ids;
Long companySiteId;
}
......@@ -6,7 +6,7 @@ import lombok.Setter;
@Getter
@Setter
public class CampaignCustomerRequestDTO extends BaseDTO {
public class SearchCustomerRequestDTO extends BaseDTO {
String customerListCode;
String customerListName;
String convertedDateFrom;
......
......@@ -4,8 +4,8 @@ import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.web.dto.request_dto.CampaignCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.DeleteCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -14,12 +14,11 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/ipcc/customer")
@CrossOrigin("*")
@CrossOrigin(origins = "*")
public class CustomerController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
......@@ -29,8 +28,8 @@ public class CustomerController {
@GetMapping("/findAll")
@ResponseBody
public ResponseEntity findAllCustomer(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) {
Map result = customerService.listAllCustomer(page, pageSize, sort);
public ResponseEntity findAllCustomer(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("customerListId") long customerListId, @RequestParam("companySiteId") long companySiteId) {
ResultDTO result = customerService.listAllCustomer(page, pageSize, sort, customerListId, companySiteId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
......@@ -62,17 +61,17 @@ public class CustomerController {
@PostMapping("/delete")
@ResponseBody
public ResultDTO deleteCustomer(@RequestBody @Valid DeleteCustomerRequestDTO deleteCustomerRequestDTO) {
public ResultDTO deleteCustomer(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO();
result = customerService.deleteCustomer(deleteCustomerRequestDTO);
result = customerService.deleteCustomer(customerRequestDTO);
return result;
}
@PostMapping("/deleteIds")
@ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid DeleteCustomerRequestDTO deleteCustomerRequestDTO) {
public ResultDTO deleteIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO();
result = customerService.deleteIds(deleteCustomerRequestDTO);
result = customerService.deleteIds(customerRequestDTO);
return result;
}
......@@ -135,15 +134,15 @@ public class CustomerController {
@PostMapping("/deleteCustomerListIds")
@ResponseBody
public ResultDTO deleteCustomerListIds(@RequestBody @Valid List<Long> ids) {
public ResultDTO deleteCustomerListIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO();
result = customerService.deleteCustomerListIds(ids);
result = customerService.deleteCustomerListIds(customerRequestDTO);
return result;
}
@RequestMapping(value = "/searchCustomerList", method = RequestMethod.POST)
public ResponseEntity searchCustomerList(@RequestBody CampaignCustomerRequestDTO campaignCustomerRequestDTO) {
ResultDTO result = customerService.searchCustomerList(campaignCustomerRequestDTO);
public ResponseEntity searchCustomerList(@RequestBody SearchCustomerRequestDTO searchCustomerRequestDTO) {
ResultDTO result = customerService.searchCustomerList(searchCustomerRequestDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
select
a.CUSTOMER_LIST_MAPPING_ID customerListMappingId,
a.COMPANY_SITE_ID companySiteId,
a.CUSTOMER_LIST_ID customerListId,
a.CUSTOMER_ID customerId,
b.NAME name,
b.DESCRIPTION description,
b.COMPANY_NAME companyName,
b.CUSTOMER_TYPE customerType,
b.CURRENT_ADDRESS currentAddress,
c.MOBILE mobileNumber,
d.EMAIL email
from CUSTOMER_LIST_MAPPING a
join CUSTOMER b on a.CUSTOMER_ID = b.CUSTOMER_ID
left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS MOBILE
FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 GROUP BY CUSTOMER_ID) c on b.CUSTOMER_ID = c.CUSTOMER_ID
left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS EMAIL
FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 GROUP BY CUSTOMER_ID) d on b.CUSTOMER_ID = d.CUSTOMER_ID
where 1 = 1
and COMPANY_SITE_ID = :p_company_site_id
and CUSTOMER_LIST_ID = :p_customer_list_id
......@@ -12,4 +12,5 @@ SELECT
DEPT_CREATE deptCreate
FROM CUSTOMER_LIST
WHERE 1 = 1
AND CREATE_AT BETWEEN :p_date_from AND :p_date_to
AND CREATE_AT BETWEEN to_date(:p_date_from, 'YYYYMMDD') AND to_date(:p_date_to, 'YYYYMMDD')
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