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

phipd commit

parent 8740b74e
...@@ -14,6 +14,9 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long ...@@ -14,6 +14,9 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long
CustomerList findByCustomerListCode(String customerListCode); CustomerList findByCustomerListCode(String customerListCode);
@Query("select c from CustomerList c where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id and c.status = 1")
List<CustomerList> findAllCustomerList(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
@Modifying @Modifying
@Query("update CustomerList c set c.status = 0 where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id") @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); int deleteCustomerList(@Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
......
...@@ -393,10 +393,9 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -393,10 +393,9 @@ public class CustomerServiceImpl implements CustomerService {
public ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO) { public ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
List<Long> listId = new ArrayList<>(); List<Long> listId = new ArrayList<>();
listId.add(customerRequestDTO.getCustomerId());
try { try {
if (customerRequestDTO != null) { if (customerRequestDTO != null) {
listId.add(customerRequestDTO.getCustomerId());
if (customerListMappingRepository.findAllCustomerListMapping(listId, customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId()).size() > 0) { if (customerListMappingRepository.findAllCustomerListMapping(listId, customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId()).size() > 0) {
// delete // delete
// customerRepository.deleteById(customerDTO.getCustomerId()); // customerRepository.deleteById(customerDTO.getCustomerId());
...@@ -405,8 +404,8 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -405,8 +404,8 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else { } else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.DELETE_ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.DELETE_ERROR);
} }
} else { } else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -425,10 +424,15 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -425,10 +424,15 @@ public class CustomerServiceImpl implements CustomerService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
try { try {
if (customerRequestDTO != null) { if (customerRequestDTO != null) {
// customerRepository.deleteIds(ids); if (customerListMappingRepository.findAllCustomerListMapping(customerRequestDTO.getIds(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId()).size() > 0) {
//customerRepository.deleteIds(ids);
customerListMappingRepository.deleteMappingByCustomerIds(customerRequestDTO.getIds(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId()); customerListMappingRepository.deleteMappingByCustomerIds(customerRequestDTO.getIds(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.DELETE_ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.DELETE_ERROR);
}
} else { } else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
...@@ -721,17 +725,23 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -721,17 +725,23 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomerList(CustomerListDTO customerListDTO) { public ResultDTO deleteCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
List<Long> ids = new ArrayList<>();
ids.add(customerListDTO.getCustomerListId());
try { try {
// delete // delete
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) { if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) {
if (customerListRepository.findAllCustomerList(ids, customerListDTO.getCompanySiteId()).size() > 0) {
customerListRepository.deleteCustomerList(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId()); customerListRepository.deleteCustomerList(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId()); customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.DELETE_ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.DELETE_ERROR);
}
} else { } else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
...@@ -751,12 +761,17 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -751,12 +761,17 @@ public class CustomerServiceImpl implements CustomerService {
try { try {
if (customerRequestDTO != null) { if (customerRequestDTO != null) {
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignIdsCount(customerRequestDTO.getIds()))) { if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignIdsCount(customerRequestDTO.getIds()))) {
if (customerListRepository.findAllCustomerList(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId()).size() > 0) {
customerListRepository.deleteCustomerListIds(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId()); customerListRepository.deleteCustomerListIds(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId());
customerListMappingRepository.deleteMappingByCustomerListIds(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId()); customerListMappingRepository.deleteMappingByCustomerListIds(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.DELETE_ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.DELETE_ERROR);
}
} else { } else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
......
...@@ -7,10 +7,12 @@ public class Constants { ...@@ -7,10 +7,12 @@ public class Constants {
public interface ApiErrorCode { public interface ApiErrorCode {
String ERROR = "01"; String ERROR = "01";
String SUCCESS = "00"; String SUCCESS = "00";
String DELETE_ERROR = "02";
} }
public interface ApiErrorDesc { public interface ApiErrorDesc {
String ERROR = "ERROR"; String ERROR = "ERROR";
String SUCCESS = "SUCCESS"; String SUCCESS = "SUCCESS";
String DELETE_ERROR = "DELETE_ERROR";
} }
public interface FileType { public interface FileType {
String pdf = "pdf"; String pdf = "pdf";
......
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