Commit 8b162942 authored by ='s avatar =

hungtt-commit fix bug reallocation

parent b684a288
......@@ -838,7 +838,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"count_data as (\n" +
"select count(*) totalRow from data_temp\n" +
")\n" +
"select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter totalRow from data a, count_data\n" +
"select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter, totalRow from data a, count_data\n" +
"where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)\n";
params.put("p_campaign_id", dto.getCampaignId());
params.put("p_company_site_id", dto.getCompanySiteId());
......
......@@ -60,6 +60,8 @@ public interface CampaignService {
ResultDTO getCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerChoosenList(CampaignRequestDTO dto);
ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto);
//</editor-fold>
}
......@@ -61,6 +61,9 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired
ScenarioRepository scenarioRepository;
@Autowired
CampaignCustomerListRepository campaignCustomerListRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) {
......@@ -370,8 +373,8 @@ public class CampaignServiceImpl implements CampaignService {
ResultDTO resultDTO = new ResultDTO();
List<TimeZoneDialModeDTO> lstTimeZone = dto.getLstTimeZone();
List<TimeRangeDialModeDTO> lstTimeRange = dto.getLstTimeRange();
Campaign campaignEntity = new Campaign();
campaignEntity.setCampaignId(dto.getCampaignId());
Campaign campaignEntity = campaignRepository.findByCampaignId(dto.getCampaignId());
campaignEntity.setCampaignName(dto.getCampaignName());
campaignEntity.setCampaignCode(dto.getCampaignCode());
campaignEntity.setContent(dto.getContent());
campaignEntity.setCustomerNumber(dto.getCustomerNumber());
......@@ -499,6 +502,30 @@ public class CampaignServiceImpl implements CampaignService {
return campaignRepositoryCustom.getCustomerChoosenList(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
String[] lstCusListId = dto.getLstCustomerListId().split(",");
try {
for(String cusListId : lstCusListId) {
CampaignCustomerList entity = new CampaignCustomerList();
entity.setCampaignId(Long.parseLong(dto.getCampaignId()));
entity.setCompanySiteId(Long.parseLong(dto.getCompanySiteId()));
entity.setCustomerListId(Long.parseLong(cusListId));
campaignCustomerListRepository.save(entity);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
// hungtt
private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) {
mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale));
......
......@@ -50,5 +50,6 @@ public class CampaignRequestDTO extends BaseDTO {
String custListName;
String createTimeTo;
String createTimeFr;
String lstCustomerListId;
}
......@@ -267,8 +267,15 @@ public class CampaignController {
public ResponseEntity getCustomerChoosenList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCustomerChoosenList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/addCustomerListToCampaign")
@ResponseBody
public ResponseEntity addCustomerListToCampaign(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.addCustomerListToCampaign(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO);
......
......@@ -55,5 +55,5 @@ select a.*, rownum row_ from data_temp a
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter totalRow from data a, count_data
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
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