Commit 6415876b authored by Phạm Duy Phi's avatar Phạm Duy Phi

phi pd commit: gop customerListController voi customerController

parent 0b754284
...@@ -12,7 +12,7 @@ public class CustomerListMapper extends BaseMapper<CustomerList, CustomerListDTO ...@@ -12,7 +12,7 @@ public class CustomerListMapper extends BaseMapper<CustomerList, CustomerListDTO
obj.setCreateBy(customerList.getCreateBy()); obj.setCreateBy(customerList.getCreateBy());
obj.setCustomerListCode(customerList.getCustomerListCode()); obj.setCustomerListCode(customerList.getCustomerListCode());
obj.setCustomerListId(customerList.getCustomerListId()); obj.setCustomerListId(customerList.getCustomerListId());
obj.setCustomerSiteId(customerList.getCustomerSiteId()); obj.setCompanySiteId(customerList.getCompanySiteId());
obj.setCustomerListName(customerList.getCustomerListName()); obj.setCustomerListName(customerList.getCustomerListName());
obj.setDeptCreate(customerList.getDeptCreate()); obj.setDeptCreate(customerList.getDeptCreate());
obj.setSource(customerList.getSource()); obj.setSource(customerList.getSource());
...@@ -32,7 +32,7 @@ public class CustomerListMapper extends BaseMapper<CustomerList, CustomerListDTO ...@@ -32,7 +32,7 @@ public class CustomerListMapper extends BaseMapper<CustomerList, CustomerListDTO
obj.setCustomerListCode(dtoBean.getCustomerListCode()); obj.setCustomerListCode(dtoBean.getCustomerListCode());
obj.setCustomerListId(dtoBean.getCustomerListId()); obj.setCustomerListId(dtoBean.getCustomerListId());
obj.setCustomerListName(dtoBean.getCustomerListName()); obj.setCustomerListName(dtoBean.getCustomerListName());
obj.setCustomerSiteId(dtoBean.getCustomerSiteId()); obj.setCompanySiteId(dtoBean.getCompanySiteId());
obj.setDeptCreate(dtoBean.getDeptCreate()); obj.setDeptCreate(dtoBean.getDeptCreate());
obj.setSource(dtoBean.getSource()); obj.setSource(dtoBean.getSource());
obj.setStatus(dtoBean.getStatus()); obj.setStatus(dtoBean.getStatus());
......
...@@ -23,7 +23,7 @@ public class CustomerList implements Serializable { ...@@ -23,7 +23,7 @@ public class CustomerList implements Serializable {
@Column(name = "CUSTOMER_LIST_ID") @Column(name = "CUSTOMER_LIST_ID")
private Long customerListId; private Long customerListId;
@Column(name = "COMPANY_SITE_ID") @Column(name = "COMPANY_SITE_ID")
private Long customerSiteId; private Long companySiteId;
@Size(max = 200) @Size(max = 200)
@Column(name = "CUSTOMER_LIST_CODE") @Column(name = "CUSTOMER_LIST_CODE")
private String customerListCode; private String customerListCode;
......
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; package com.viettel.campaign.repository;
import com.viettel.campaign.model.CustomerList; 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.JpaRepository;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import java.util.Date;
import java.util.List; import java.util.List;
public interface CustomerListRepository extends JpaRepository<CustomerList, Long> { public interface CustomerListRepository extends JpaRepository<CustomerList, Long> {
...@@ -19,8 +16,5 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long ...@@ -19,8 +16,5 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long
@Modifying @Modifying
@Query("delete from CustomerList c where c.customerListId in (:ids)") @Query("delete from CustomerList c where c.customerListId in (:ids)")
int deleteIds(@Param("ids") List<Long> ids); int deleteCustomerListIds(@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);
} }
...@@ -4,7 +4,9 @@ import com.viettel.campaign.model.Customer; ...@@ -4,7 +4,9 @@ import com.viettel.campaign.model.Customer;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; 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.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
...@@ -20,4 +22,7 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> { ...@@ -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 ") @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); Long findByMobileNumberAndSiteId(String mobileNumber, Long siteId);
@Modifying
@Query("delete from Customer c where c.customerId in (:ids)")
int deleteIds(@Param("ids") List<Long> ids);
} }
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; package com.viettel.campaign.service;
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.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface CustomerService { public interface CustomerService {
...@@ -12,4 +15,22 @@ public interface CustomerService { ...@@ -12,4 +15,22 @@ public interface CustomerService {
Map listCustByName(int page, int pageSize, String sort, String name); Map listCustByName(int page, int pageSize, String sort, String name);
ResultDTO createCustomer(CustomerDTO customerDTO); 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; package com.viettel.campaign.service.impl;
import com.viettel.campaign.model.Campaign;
import com.viettel.campaign.repository.CampaignRepository; import com.viettel.campaign.repository.CampaignRepository;
import com.viettel.campaign.service.CampaignService; import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.web.dto.CampaignDTO; import com.viettel.campaign.web.dto.CampaignDTO;
......
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;
}
}
...@@ -11,6 +11,7 @@ import org.springframework.core.io.ClassPathResource; ...@@ -11,6 +11,7 @@ import org.springframework.core.io.ClassPathResource;
public class SQLBuilder { public class SQLBuilder {
public static final String SQL_MODULE_CAMPAIGN_MNG = "campaign-mng"; 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_STATUS_MNG = "campaign-status-mng";
public static final String SQL_MODULE_CAMPAIGN_CUSTOMER = "campaign-customer";
public static String getSqlQueryById(String module, public static String getSqlQueryById(String module,
String queryId) { String queryId) {
......
...@@ -9,12 +9,12 @@ import java.util.Date; ...@@ -9,12 +9,12 @@ import java.util.Date;
@Setter @Setter
public class CustomerListDTO extends BaseDTO { public class CustomerListDTO extends BaseDTO {
private long customerListId; private Long customerListId;
// private String customerListPK; // private String customerListPK;
private long customerSiteId; private Long companySiteId;
private String customerListCode; private String customerListCode;
private String customerListName; private String customerListName;
private short status; private Short status;
private String createBy; private String createBy;
private Date createAt; private Date createAt;
private String updateBy; private String updateBy;
......
...@@ -2,6 +2,7 @@ package com.viettel.campaign.web.rest; ...@@ -2,6 +2,7 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ApParam; import com.viettel.campaign.model.ApParam;
import com.viettel.campaign.service.ApParamService; import com.viettel.campaign.service.ApParamService;
import com.viettel.campaign.web.rest.controller.CustomerController;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
......
...@@ -3,6 +3,7 @@ package com.viettel.campaign.web.rest; ...@@ -3,6 +3,7 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO; import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.service.CampaignCompleteCodeService; import com.viettel.campaign.service.CampaignCompleteCodeService;
import com.viettel.campaign.web.rest.controller.CustomerController;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
......
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.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO; 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.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -15,21 +17,75 @@ import java.util.List; ...@@ -15,21 +17,75 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@Controller @Controller
@RequestMapping(path = "/ipcc/customerlist") @RequestMapping("/ipcc/customer")
@CrossOrigin(origins = "*") @CrossOrigin("*")
public class CustomerListController { public class CustomerController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
@Autowired(required=true) @Autowired(required=true)
CustomerListService customerListService; CustomerService customerService;
@GetMapping("/findAll") @GetMapping("/findAll")
@ResponseBody @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) { 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); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@PostMapping("/create") @PostMapping("/createCustomerList")
@ResponseBody @ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) { public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
...@@ -37,7 +93,7 @@ public class CustomerListController { ...@@ -37,7 +93,7 @@ public class CustomerListController {
//logUtil.initKpiLog("createCust") //logUtil.initKpiLog("createCust")
try { try {
//LOGGER.info("Returning createCustomer: start"); //LOGGER.info("Returning createCustomer: start");
result = customerListService.createCustomerList(customerListDTO); result = customerService.createCustomerList(customerListDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode()); //LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort); //logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) { } catch (Exception e) {
...@@ -49,7 +105,7 @@ public class CustomerListController { ...@@ -49,7 +105,7 @@ public class CustomerListController {
// return new ResponseEntity<>("", HttpStatus.OK); // return new ResponseEntity<>("", HttpStatus.OK);
} }
@PutMapping("/update") @PutMapping("/updateCustomerList")
@ResponseBody @ResponseBody
public ResultDTO updateCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) { public ResultDTO updateCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
...@@ -57,7 +113,7 @@ public class CustomerListController { ...@@ -57,7 +113,7 @@ public class CustomerListController {
//logUtil.initKpiLog("createCust"); //logUtil.initKpiLog("createCust");
try { try {
//LOGGER.info("Returning createCustomer: start"); //LOGGER.info("Returning createCustomer: start");
result = customerListService.updateCustomerList(customerListDTO); result = customerService.updateCustomerList(customerListDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode()); //LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort); //logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) { } catch (Exception e) {
...@@ -68,26 +124,26 @@ public class CustomerListController { ...@@ -68,26 +124,26 @@ public class CustomerListController {
return result; return result;
} }
@PostMapping("/delete") @PostMapping("/deleteCustomerList")
@ResponseBody @ResponseBody
public ResultDTO deleteCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) { public ResultDTO deleteCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
result = customerListService.deleteCustomerList(customerListDTO); result = customerService.deleteCustomerList(customerListDTO);
return result; return result;
} }
@PostMapping("/ids") @PostMapping("/deleteCustomerListIds")
@ResponseBody @ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid List<Long> ids) { public ResultDTO deleteCustomerListIds(@RequestBody @Valid List<Long> ids) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
result = customerListService.deleteIds(ids); result = customerService.deleteCustomerListIds(ids);
return result; return result;
} }
@GetMapping("/search") @GetMapping("/searchCustomerList")
@ResponseBody @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) { 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); return new ResponseEntity<>(result, HttpStatus.OK);
} }
} }
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