Commit 6b55d2d4 authored by Tu Bach's avatar Tu Bach

tubn merge

parents 8d22a9c0 499eb4dc
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="ExternalSystem" externalSystem="Maven" />
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
......
......@@ -27,6 +27,7 @@ public class CampaignCompleteCodeMapper extends BaseMapper<CampaignCompleteCode,
dto.setCompanySiteId(entity.getCompanySiteId());
dto.setIsLock(entity.getIsLock());
dto.setDurationLock(entity.getDurationLock());
dto.setChanel(entity.getChanel());
}
return dto;
......@@ -54,6 +55,7 @@ public class CampaignCompleteCodeMapper extends BaseMapper<CampaignCompleteCode,
entity.setCompanySiteId(dtoBean.getCompanySiteId());
entity.setIsLock(dtoBean.getIsLock());
entity.setDurationLock(dtoBean.getDurationLock());
entity.setChanel(dtoBean.getChanel());
}
return entity;
......
......@@ -12,7 +12,7 @@ public class CustomerListMapper extends BaseMapper<CustomerList, CustomerListDTO
obj.setCreateBy(customerList.getCreateBy());
obj.setCustomerListCode(customerList.getCustomerListCode());
obj.setCustomerListId(customerList.getCustomerListId());
obj.setCustomerSiteId(customerList.getCustomerSiteId());
obj.setCompanySiteId(customerList.getCompanySiteId());
obj.setCustomerListName(customerList.getCustomerListName());
obj.setDeptCreate(customerList.getDeptCreate());
obj.setSource(customerList.getSource());
......@@ -32,7 +32,7 @@ public class CustomerListMapper extends BaseMapper<CustomerList, CustomerListDTO
obj.setCustomerListCode(dtoBean.getCustomerListCode());
obj.setCustomerListId(dtoBean.getCustomerListId());
obj.setCustomerListName(dtoBean.getCustomerListName());
obj.setCustomerSiteId(dtoBean.getCustomerSiteId());
obj.setCompanySiteId(dtoBean.getCompanySiteId());
obj.setDeptCreate(dtoBean.getDeptCreate());
obj.setSource(dtoBean.getSource());
obj.setStatus(dtoBean.getStatus());
......
......@@ -6,6 +6,7 @@ import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Entity
......@@ -44,7 +45,6 @@ public class CampaignCompleteCode implements Serializable {
@Column(name = "CREATE_AT")
@Temporal(TemporalType.TIMESTAMP)
private Date createAt;
@Transient
@Column(name = "CAMPAIGN_TYPE")
private String campaignType;
@Column(name = "IS_FINISH")
......@@ -55,4 +55,7 @@ public class CampaignCompleteCode implements Serializable {
private Short isLock;
@Column(name = "DURATION_LOCK")
private Long durationLock;
@Column(name = "CHANEL")
private BigDecimal chanel;
}
......@@ -23,7 +23,7 @@ public class CustomerList implements Serializable {
@Column(name = "CUSTOMER_LIST_ID")
private Long customerListId;
@Column(name = "COMPANY_SITE_ID")
private Long customerSiteId;
private Long companySiteId;
@Size(max = 200)
@Column(name = "CUSTOMER_LIST_CODE")
private String customerListCode;
......
......@@ -18,8 +18,10 @@ public interface ApParamRepository extends JpaRepository<ApParam, Long>, ApParam
@Query(value = "SELECT p FROM ApParam p WHERE parName LIKE concat('%', :parName, '%') ")
List<ApParam> findParamByName(@Param("parName") String parName, Pageable pageable);
@Query(value = "SELECT p FROM ApParam p WHERE status = 1 AND parType LIKE concat('%', :parType, '%') ")
List<ApParam> findParamByParType(@Param("parType") String parType);
@Query(value = "select a from ApParam a WHERE status = 1 AND parType = 'CAMPAIGN_TYPE'")
List<ApParam> findAllParam();
}
......@@ -25,4 +25,5 @@ public interface CampaignCompleteCodeRepository extends JpaRepository<CampaignCo
@Query("delete from CampaignCompleteCode c where c.campaignCompleteCodeId in (:ids)")
int deleteds(@Param("ids") List<Long> ids);
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.CustomerListMapping;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
public interface CustomerListMappingRepository extends JpaRepository<CustomerListMapping, Long> {
@Modifying
@Query("delete from CustomerListMapping c where c.customerListId=:customerListId")
int deleteMappingByCustomerListId(@Param("customerListId") Long customerListId);
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.CustomerList;
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.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.Date;
import java.util.List;
public interface CustomerListRepository extends JpaRepository<CustomerList, Long> {
......@@ -19,8 +16,5 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long
@Modifying
@Query("delete from CustomerList c where c.customerListId in (:ids)")
int deleteIds(@Param("ids") List<Long> ids);
@Query("select c from CustomerList c where c.customerListCode=:customerListCode or c.customerListName=:customerListName or c.createAt >:dateFrom and c.createAt <:dateTo or c.createAt=:dateFrom or c.createAt=:dateTo")
Page<CustomerList> searchCustomerList(@Param("customerListCode") String customerListCode, @Param("customerListName") String customerListName, @Param("dateFrom") Date dateFrom, @Param("dateTo") Date dateTo, Pageable pageable);
int deleteCustomerListIds(@Param("ids") List<Long> ids);
}
......@@ -4,7 +4,9 @@ import com.viettel.campaign.model.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.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -20,4 +22,7 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
@Query("SELECT COUNT(0) FROM Customer t WHERE t.mobileNumber = ?1 and t.siteId = ?2 and t.status = 1 ")
Long findByMobileNumberAndSiteId(String mobileNumber, Long siteId);
@Modifying
@Query("delete from Customer c where c.customerId in (:ids)")
int deleteIds(@Param("ids") List<Long> ids);
}
......@@ -2,14 +2,17 @@ package com.viettel.campaign.repository.impl;
import com.viettel.campaign.model.CampaignCompleteCode;
import com.viettel.campaign.repository.CampaignCompleteCodeRepository;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.hibernate.type.BigDecimalType;
import org.hibernate.type.LongType;
import org.hibernate.type.ShortType;
import org.hibernate.type.StringType;
......@@ -21,6 +24,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.util.ArrayList;
......@@ -43,7 +47,7 @@ public class CampaignCompleteCodeRepositoryIpml implements CampaignCompleteCodeR
// } catch (Exception e) {
//
// }
return null;
return null;
}
@Override
......@@ -69,7 +73,7 @@ public class CampaignCompleteCodeRepositoryIpml implements CampaignCompleteCodeR
query.addScalar("chanel", new ShortType());
query.addScalar("description", new StringType());
query.addScalar("status", new ShortType());
query.addScalar("chanel", new BigDecimalType());
query.setResultTransformer(Transformers.aliasToBean(CampaignCompleteCodeDTO.class));
......@@ -113,8 +117,18 @@ public class CampaignCompleteCodeRepositoryIpml implements CampaignCompleteCodeR
}
@Override
public void deleteById(Long aLong) {
@Transactional
public void deleteById(Long id) {
ResultDTO result = new ResultDTO();
try {
// update Status = 0 cho cái ID truyền vào
CampaignCompleteCode entity = entityManager.find(CampaignCompleteCode.class, id);
// set giá trị Status = 0 --> tương đương với inactive
entity.setStatus(new Short("0"));
entityManager.merge(entity);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
@Override
......
......@@ -8,6 +8,8 @@ import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
......@@ -19,6 +21,7 @@ import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.xml.crypto.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
......@@ -26,6 +29,7 @@ import java.util.List;
@Repository
public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
private static final Logger logger = LogManager.getLogger(CampaignRepositoryImpl.class);
@Autowired
EntityManager entityManager;
......@@ -161,6 +165,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
@Override
public ResultDTO search(CampaignRequestDTO requestDto) {
logger.info("Start search campaign::");
ResultDTO result = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
......@@ -202,10 +208,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if (!DataUtil.isNullOrZero(requestDto.getNumOfCusTo())) {
sqlStr.append(" AND a.CUSTOMER_NUMBER <= :p_cusNumTo");
}
if (requestDto.getType() != null) {
sqlStr.append(" AND a.CAMPAIGN_TYPE = :p_type");
if (!DataUtil.isNullOrEmpty(requestDto.getTypes())) {
sqlStr.append(" AND a.CAMPAIGN_TYPE IN (:p_type)");
}
if (requestDto.getChanel() != null && requestDto.getChanel() > 0) {
if (requestDto.getChanel() != null && !DataUtil.isNullOrZero(requestDto.getChanel())) {
sqlStr.append(" AND a.CHANEL = :p_chanel");
}
if (!DataUtil.isNullOrZero(requestDto.getNumOfCusFr())) {
......@@ -249,10 +255,11 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if (!DataUtil.isNullOrEmpty(requestDto.getToDateTo())) {
query.setParameter("p_toDateTo", requestDto.getToDateTo());
}
if (requestDto.getType() != null) {
query.setParameter("p_type", requestDto.getType());
if (!DataUtil.isNullOrEmpty(requestDto.getTypes())) {
String[] types = requestDto.getTypes().split(",");
query.setParameterList("p_type", types);
}
if (requestDto.getChanel() != null && requestDto.getChanel() > 0) {
if (requestDto.getChanel() != null && !DataUtil.isNullOrZero(requestDto.getChanel())) {
query.setParameter("p_chanel", requestDto.getChanel());
}
if (!DataUtil.isNullOrZero(requestDto.getNumOfCusFr())) {
......@@ -266,6 +273,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query.addScalar("campaignCode", new StringType());
query.addScalar("campaignName", new StringType());
query.addScalar("campaignType", new StringType());
query.addScalar("campaignTypeName", new StringType());
query.addScalar("chanel", new ShortType());
query.addScalar("startTime", new DateType());
query.addScalar("endTime", new DateType());
......@@ -291,18 +299,19 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
result.setData(dataPage);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
session.close();
return result;
} catch (Exception ex) {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(ex.getMessage(), ex);
} finally {
session.close();
}
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
return result;
}
@Override
public ResultDTO findByCampaignCode(CampaignRequestDTO requestDto) {
logger.info("Start search campaign by code::");
ResultDTO result = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
......@@ -365,10 +374,12 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return result;
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
}
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
return result;
}
......
......@@ -13,9 +13,8 @@ public interface ApParamService {
List<ApParam> getParamByName(int page, int pageSize, String sort, String parName);
ResultDTO createApParam(ApParamDTO apParamDTO);
List<ApParam>findAllParam();
ResultDTO findParamByParType(String parType);
List<ApParam>findAllParam();
}
......@@ -20,4 +20,6 @@ public interface CampaignCompleteCodeService {
ResultDTO deleteList(List<Long> completeCodeDtos);
ResultDTO deleteById(Long id);
}
......@@ -142,4 +142,21 @@ public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeServ
return resultDTO;
}
@Override
public ResultDTO deleteById(Long id) {
ResultDTO result = new ResultDTO();
try {
completeCodeRepository.deleteById(id);
result.setErrorCode(Constants.Status.ACTIVE_STR);
result.setDescription(Constants.Status.ACTIVE_STR);
} catch (Exception e) {
result.setErrorCode("-1");
return result;
}
result.setErrorCode("0");
return result;
}
}
package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface CustomerListService {
Map getCustomerList(int page, int pageSize, String sort);
ResultDTO createCustomerList(CustomerListDTO customerListDTO);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteIds(List<Long> ids);
Map searchCustomerList(String customerListCode, String customerListName, Date dateFrom, Date dateTo, int page, int pageSize, String sort);
}
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 java.util.Date;
import java.util.List;
import java.util.Map;
public interface CustomerService {
......@@ -12,4 +15,22 @@ public interface CustomerService {
Map listCustByName(int page, int pageSize, String sort, String name);
ResultDTO createCustomer(CustomerDTO customerDTO);
ResultDTO deleteCustomer(CustomerDTO customerDTO);
ResultDTO deleteIds(List<Long> ids);
// ------------ customer list ------------ //
Map getCustomerList(int page, int pageSize, String sort);
ResultDTO createCustomerList(CustomerListDTO customerListDTO);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerListIds(List<Long> ids);
ResultDTO searchCustomerList(String customerListCode, String customerListName, Date dateFrom, Date dateTo, int page, int pageSize, String sort);
}
package com.viettel.campaign.service.impl;
import com.viettel.campaign.service.ApParamService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.ApParamDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.mapper.ApParamMapper;
......@@ -13,6 +14,8 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Service
public class ApParamServiceImpl implements ApParamService {
......@@ -20,6 +23,10 @@ public class ApParamServiceImpl implements ApParamService {
@Autowired
ApParamRepository apParamRepository;
private static final Logger logger = LogManager.getLogger(ApParamServiceImpl.class);
@Override
public Iterable<ApParam> getAllParams(int page, int pageSize, String sort) {
return apParamRepository.findAll(PageRequest.of(page, pageSize, Sort.by(sort)));
......@@ -54,13 +61,30 @@ public class ApParamServiceImpl implements ApParamService {
result.setData(apparam);
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
}
@Override
public ResultDTO findParamByParType(String parType) {
ResultDTO resultDTO = new ResultDTO();
try {
List<ApParam> lst = apParamRepository.findParamByParType(parType);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(lst);
logger.info("find params by type: " + resultDTO.getErrorCode());
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
public List<ApParam> findAllParam() {
return apParamRepository.findAllParam();
}
......
package com.viettel.campaign.service.impl;
import com.viettel.campaign.mapper.CustomerListMapper;
import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.repository.CampaignCustomerListRepository;
import com.viettel.campaign.repository.CustomerListRepository;
import com.viettel.campaign.service.CustomerListService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.util.*;
@Service
public class CustomerListServiceImpl implements CustomerListService {
@Autowired
EntityManager entityManager;
@Autowired
CustomerListRepository customerListRepository;
@Autowired
CampaignCustomerListRepository campaignCustomerListRepository;
private Logger logger = LogManager.getLogger(CustomerListServiceImpl.class);
@Override
public Map getCustomerList(int page, int pageSize, String sort) {
Map result = new HashMap();
List<CustomerList> list = new ArrayList<>();
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
Page<CustomerList> pc = customerListRepository.findAll(pageable);
result.put("totalItem", pc.getTotalElements());
result.put("customerList", pc.iterator());
return result;
}
@Override
public ResultDTO createCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
Date today = new Date();
CustomerList customerList = new CustomerList();
try {
if (customerListDTO != null) {
// insert
CustomerList findCustomer = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (findCustomer == null) {
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
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();
}
return resultDTO;
}
@Override
public ResultDTO updateCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
Date today = new Date();
CustomerList customerList = customerListRepository.findCustomerListByCustomerListId(customerListDTO.getCustomerListId());
try {
if (customerListDTO != null) {
// update
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerList = customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
@Override
public ResultDTO deleteCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
Date today = new Date();
CustomerList customerList = new CustomerList();
try {
if (customerListDTO != null) {
// delete
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) {
customerListRepository.deleteById(customerListDTO.getCustomerListId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
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();
}
return resultDTO;
}
@Transactional
@Override
public ResultDTO deleteIds(List<Long> ids) {
ResultDTO resultDTO = new ResultDTO();
try {
if (ids != null) {
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignIdsCount(ids))) {
customerListRepository.deleteIds(ids);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
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();
}
return resultDTO;
}
@Override
public Map searchCustomerList(String customerListCode, String customerListName, Date dateFrom, Date dateTo, int page, int pageSize, String sort) {
Map result = new HashMap();
List<CustomerList> list = new ArrayList<>();
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
Page<CustomerList> pc = customerListRepository.searchCustomerList(customerListCode, customerListName, dateFrom, dateTo, pageable);
result.put("totalItem", pc.getTotalElements());
result.put("searchList", pc.iterator());
return result;
}
}
package com.viettel.campaign.service.impl;
import com.viettel.campaign.mapper.CustomerListMapper;
import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.repository.CampaignCustomerListRepository;
import com.viettel.campaign.repository.CustomerListMappingRepository;
import com.viettel.campaign.repository.CustomerListRepository;
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.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
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 org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -28,6 +38,15 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired
CustomerRepository customerRepository;
@Autowired
CustomerListRepository customerListRepository;
@Autowired
CampaignCustomerListRepository campaignCustomerListRepository;
@Autowired
CustomerListMappingRepository customerListMappingRepository;
@Override
public Map listAllCustomer(int page, int pageSize, String sort) {
Map result = new HashMap();
......@@ -61,7 +80,6 @@ public class CustomerServiceImpl implements CustomerService {
public ResultDTO createCustomer(CustomerDTO customerDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerMapper customerMapper = new CustomerMapper();
Date today = new Date();
Customer customer = new Customer();
try {
......@@ -92,6 +110,46 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO;
}
@Override
public ResultDTO deleteCustomer(CustomerDTO customerDTO) {
ResultDTO resultDTO = new ResultDTO();
try {
if (customerDTO != null) {
// delete
customerRepository.deleteById(customerDTO.getCustomerId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
@Transactional
@Override
public ResultDTO deleteIds(List<Long> ids) {
ResultDTO resultDTO = new ResultDTO();
try {
if (ids != null) {
customerRepository.deleteIds(ids);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
public Date getSysdate() {
try {
Query query = entityManager.createNativeQuery("SELECT to_char(sysdate, 'dd/MM/YYYY hh24:mi:ss') FROM DUAL ");
......@@ -105,4 +163,197 @@ public class CustomerServiceImpl implements CustomerService {
}
return new Date();
}
// ------------- customer list ----------------- //
@Override
public Map getCustomerList(int page, int pageSize, String sort) {
Map result = new HashMap();
List<CustomerList> list = new ArrayList<>();
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
Page<CustomerList> pc = customerListRepository.findAll(pageable);
result.put("totalItem", pc.getTotalElements());
result.put("customerList", pc.iterator());
return result;
}
@Override
public ResultDTO createCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = new CustomerList();
try {
if (customerListDTO != null) {
// insert
CustomerList findCustomer = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (findCustomer == null) {
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
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();
}
return resultDTO;
}
@Override
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 = customerListMapper.toPersistenceBean(customerListDTO);
customerList = customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
@Transactional
@Override
public ResultDTO deleteCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = customerListRepository.findCustomerListByCustomerListId(customerListDTO.getCustomerListId());
try {
// delete
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) {
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerList = customerListRepository.save(customerList);
customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
@Transactional
@Override
public ResultDTO deleteCustomerListIds(List<Long> ids) {
ResultDTO resultDTO = new ResultDTO();
try {
if (ids != null) {
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignIdsCount(ids))) {
customerListRepository.deleteCustomerListIds(ids);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
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();
}
return resultDTO;
}
@Override
public ResultDTO searchCustomerList(String customerListCode, String customerListName, Date dateFrom, Date dateTo, int page, int pageSize, String sort) {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params"));
if (!customerListCode.equals("undefined")) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_CODE LIKE :p_list_code");
}
if (!customerListName.equals("undefined")) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name");
}
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
query.setParameter("p_date_from", dateFrom);
query.setParameter("p_date_to", dateTo);
if (!customerListCode.equals("undefined")) {
query.setParameter("p_list_code", "%" +
customerListCode
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
+ "%");
}
if (!customerListName.equals("undefined")) {
query.setParameter("p_list_name", "%" +
customerListName
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
+ "%");
}
// Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
// Page<CustomerList> pc = customerListRepository.search();
//
// result.put("totalItem", pc.getTotalElements());
// result.put("searchList", pc.iterator());
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class));
int count = 0;
List<CustomerListDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
// Pageable pageable = buildPageable();
// if (pageable != null) {
// query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
// query.setMaxResults(pageable.getPageSize());
// }
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
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);
session.close();
return resultDTO;
}
}
......@@ -28,7 +28,7 @@ public class Constants {
Long ACTIVE = 1L;
Long INACTIVE = 0L;
String ACTIVE_STR = "Trang thai ket noi(Khong thanh cong)";
String INACTIVE_STR = "Trang thai khao sat";
String ACTIVE_STR = "Trạng thái kêt nối(Không thành công)";
String INACTIVE_STR = "Trạng thái khảo sát";
}
}
......@@ -266,4 +266,8 @@ public class DataUtil {
}
return input;
}
public static boolean isNullOrZero(Short value) {
return (value == null || value.equals(Short.parseShort("0")));
}
}
......@@ -17,6 +17,7 @@ import org.springframework.data.domain.Sort;
public class SQLBuilder {
public static final String SQL_MODULE_CAMPAIGN_MNG = "campaign-mng";
public static final String SQL_MODULE_CAMPAIGN_STATUS_MNG = "campaign-status-mng";
public static final String SQL_MODULE_CAMPAIGN_CUSTOMER = "campaign-customer";
public static String getSqlQueryById(String module,
String queryId) {
......
......@@ -3,6 +3,7 @@ package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.Date;
@Getter
......@@ -26,4 +27,5 @@ public class CampaignCompleteCodeDTO extends BaseDTO {
private Long companySiteId;
private Short isLock;
private Long durationLock;
private BigDecimal chanel;
}
......@@ -57,4 +57,5 @@ public class CampaignDTO extends BaseDTO {
private Long numOfJoinedCus;
private Long numOfNotJoinedCus;
private Long numOfLockCus;
private String campaignTypeName;
}
......@@ -9,12 +9,12 @@ import java.util.Date;
@Setter
public class CustomerListDTO extends BaseDTO {
private long customerListId;
private Long customerListId;
// private String customerListPK;
private long customerSiteId;
private Long companySiteId;
private String customerListCode;
private String customerListName;
private short status;
private Short status;
private String createBy;
private Date createAt;
private String updateBy;
......
......@@ -8,7 +8,6 @@ import lombok.Setter;
* @author anhvd_itsol
*/
@Getter
@Setter
public class CampaignRequestDTO extends BaseDTO {
......@@ -25,4 +24,5 @@ public class CampaignRequestDTO extends BaseDTO {
Short chanel;
String companySiteId;
String agentId;
String types;
}
......@@ -2,6 +2,7 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ApParam;
import com.viettel.campaign.service.ApParamService;
import com.viettel.campaign.web.rest.controller.CustomerController;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -40,9 +41,15 @@ public class ApParamController {
return new ResponseEntity(lst, HttpStatus.OK);
}
@RequestMapping(path = "/findParamByParType", method = RequestMethod.GET)
public ResponseEntity findParamByParType(@RequestParam String parType) {
return new ResponseEntity<>(apParamService.findParamByParType(parType), HttpStatus.OK);
}
@GetMapping(path = "/findAllParam")
@ResponseBody
public ResponseEntity findAllParam(){
public ResponseEntity findAllParam() {
List<ApParam> findAll = apParamService.findAllParam();
if(findAll.isEmpty()) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
......@@ -50,3 +57,4 @@ public class ApParamController {
return new ResponseEntity(findAll, HttpStatus.OK);
}
}
......@@ -3,6 +3,7 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.service.CampaignCompleteCodeService;
import com.viettel.campaign.web.rest.controller.CustomerController;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -60,13 +61,8 @@ public class CampaignCompleteCodeController {
@ResponseBody
public ResultDTO updateCompleteCode(@RequestBody @Valid CampaignCompleteCodeDTO completeCodeDTO) {
ResultDTO result = new ResultDTO();
//LogUtil logUtil = new LogUtil();
//logUtil.initKpiLog("createCust");
try {
//LOGGER.info("Returning createCustomer: start");
result = completeCodeService.updateCompleteCode(completeCodeDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) {
result.setErrorCode("-1");
LOGGER.error(e);
......@@ -89,4 +85,13 @@ public class CampaignCompleteCodeController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/deleteById/{id}")
@ResponseBody
public ResultDTO deleteById(@RequestParam("id") Long id){
ResultDTO resultDTO = new ResultDTO();
resultDTO = completeCodeService.deleteById(id);
return resultDTO;
}
}
package com.viettel.campaign.web.rest;
import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.service.CustomerService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Map;
@Controller
@RequestMapping("/ipcc/customer")
@CrossOrigin("*")
public class CustomerController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
@Autowired(required=true)
CustomerService customerService;
@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);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/findCustomerByName")
@ResponseBody
public ResponseEntity findAllCustomerName(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("name") String name) {
Map result = customerService.listCustByName(page, pageSize, sort, name);
return new ResponseEntity(result, HttpStatus.OK);
}
@PostMapping(value = "/create")
@ResponseBody
public ResultDTO createCust(@RequestBody @Valid CustomerDTO customerDTO) {
ResultDTO result = new ResultDTO();
//LogUtil logUtil = new LogUtil();
//logUtil.initKpiLog("createCust");
try {
//LOGGER.info("Returning createCustomer: start");
result = customerService.createCustomer(customerDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) {
result.setErrorCode("-1");
LOGGER.error(e);
//logUtil.endKpiLog(customerDTO, 1, result.getErrorCode(), e.getMessage(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
}
return result;
}
}
package com.viettel.campaign.web.rest;
package com.viettel.campaign.web.rest.controller;
import com.viettel.campaign.service.CustomerListService;
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 org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -15,21 +17,75 @@ import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(path = "/ipcc/customerlist")
@CrossOrigin(origins = "*")
public class CustomerListController {
@RequestMapping("/ipcc/customer")
@CrossOrigin("*")
public class CustomerController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
@Autowired(required=true)
CustomerListService customerListService;
CustomerService customerService;
@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);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/findCustomerByName")
@ResponseBody
public ResponseEntity findAllCustomerName(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("name") String name) {
Map result = customerService.listCustByName(page, pageSize, sort, name);
return new ResponseEntity(result, HttpStatus.OK);
}
@PostMapping(value = "/create")
@ResponseBody
public ResultDTO createCustomer(@RequestBody @Valid CustomerDTO customerDTO) {
ResultDTO result = new ResultDTO();
//LogUtil logUtil = new LogUtil();
//logUtil.initKpiLog("createCust");
try {
//LOGGER.info("Returning createCustomer: start");
result = customerService.createCustomer(customerDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) {
result.setErrorCode("-1");
LOGGER.error(e);
//logUtil.endKpiLog(customerDTO, 1, result.getErrorCode(), e.getMessage(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
}
return result;
}
@PostMapping("/delete")
@ResponseBody
public ResultDTO deleteCustomer(@RequestBody @Valid CustomerDTO customerDTO) {
ResultDTO result = new ResultDTO();
result = customerService.deleteCustomer(customerDTO);
return result;
}
@PostMapping("/deleteIds")
@ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid List<Long> ids) {
ResultDTO result = new ResultDTO();
result = customerService.deleteIds(ids);
return result;
}
// --------------- customer list table ----------------- //
@GetMapping("/findAlls")
@ResponseBody
public ResponseEntity findAllCustomerList(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) {
Map result = customerListService.getCustomerList(page, pageSize, sort);
Map result = customerService.getCustomerList(page, pageSize, sort);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/create")
@PostMapping("/createCustomerList")
@ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO();
......@@ -37,7 +93,7 @@ public class CustomerListController {
//logUtil.initKpiLog("createCust")
try {
//LOGGER.info("Returning createCustomer: start");
result = customerListService.createCustomerList(customerListDTO);
result = customerService.createCustomerList(customerListDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) {
......@@ -49,7 +105,7 @@ public class CustomerListController {
// return new ResponseEntity<>("", HttpStatus.OK);
}
@PutMapping("/update")
@PutMapping("/updateCustomerList")
@ResponseBody
public ResultDTO updateCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO();
......@@ -57,7 +113,7 @@ public class CustomerListController {
//logUtil.initKpiLog("createCust");
try {
//LOGGER.info("Returning createCustomer: start");
result = customerListService.updateCustomerList(customerListDTO);
result = customerService.updateCustomerList(customerListDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) {
......@@ -68,26 +124,26 @@ public class CustomerListController {
return result;
}
@PostMapping("/delete")
@PostMapping("/deleteCustomerList")
@ResponseBody
public ResultDTO deleteCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO();
result = customerListService.deleteCustomerList(customerListDTO);
result = customerService.deleteCustomerList(customerListDTO);
return result;
}
@PostMapping("/ids")
@PostMapping("/deleteCustomerListIds")
@ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid List<Long> ids) {
public ResultDTO deleteCustomerListIds(@RequestBody @Valid List<Long> ids) {
ResultDTO result = new ResultDTO();
result = customerListService.deleteIds(ids);
result = customerService.deleteCustomerListIds(ids);
return result;
}
@GetMapping("/search")
@GetMapping("/searchCustomerList")
@ResponseBody
public ResponseEntity searchCustomerList(@RequestParam("customerListCode") String customerListCode, @RequestParam("customerListName") String customerListName, @RequestParam("dateFrom") Date dateFrom, @RequestParam("dateTo") Date dateTo, @RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) {
Map result = customerListService.searchCustomerList(customerListCode, customerListName, dateFrom, dateTo, page, pageSize, sort);
ResultDTO result = customerService.searchCustomerList(customerListCode, customerListName, dateFrom, dateTo, page, pageSize, sort);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
......@@ -3,6 +3,7 @@ SELECT
a.CAMPAIGN_CODE campaignCode,
a.CAMPAIGN_NAME campaignName,
a.CAMPAIGN_TYPE campaignType,
(SELECT PAR_NAME FROM AP_PARAM WHERE STATUS = 1 AND PAR_TYPE = 'CAMPAIGN_TYPE' AND PAR_VALUE = a.CAMPAIGN_TYPE) campaignTypeName,
a.CHANEL chanel,
a.START_TIME startTime,
a.END_TIME endTime,
......
SELECT
CUSTOMER_LIST_ID,
COMPANY_SITE_ID,
CUSTOMER_LIST_CODE,
CUSTOMER_LIST_NAME,
STATUS,
CREATE_BY,
CREATE_AT,
UPDATE_BY,
UPDATE_AT,
SOURCE,
DEPT_CREATE
FROM CUSTOMER_LIST
WHERE 1 = 1
AND CREATE_AT BETWEEN :p_date_from AND :p_date_to
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