Commit 69d7839d authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd commit change

parent e5e6e51e
...@@ -16,4 +16,6 @@ public interface CampaignService { ...@@ -16,4 +16,6 @@ public interface CampaignService {
ResultDTO addNewCampaign(CampaignDTO campaignDTO); ResultDTO addNewCampaign(CampaignDTO campaignDTO);
Map countRecallCustomer(Long companySiteId, Long agentId); Map countRecallCustomer(Long companySiteId, Long agentId);
ResultDTO findCampaignById(Long campaignId);
} }
...@@ -58,6 +58,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -58,6 +58,7 @@ public class CampaignServiceImpl implements CampaignService {
@Override @Override
public ResultDTO addNewCampaign(CampaignDTO campaignDTO) { public ResultDTO addNewCampaign(CampaignDTO campaignDTO) {
logger.info("=== Start add new campaign ");
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
Campaign campaign = modelMapper.map(campaignDTO, Campaign.class); Campaign campaign = modelMapper.map(campaignDTO, Campaign.class);
Long campaignId; Long campaignId;
...@@ -90,12 +91,12 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -90,12 +91,12 @@ public class CampaignServiceImpl implements CampaignService {
timeZoneDialModeRepository.saveAll(lstTimeZoneModeToInser); timeZoneDialModeRepository.saveAll(lstTimeZoneModeToInser);
} }
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setErrorCode(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(campaignResult); resultDTO.setData(campaignResult);
} catch (Exception ex) { } catch (Exception ex) {
logger.error(ex.getMessage(), ex); logger.error(ex.getMessage(), ex);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setErrorCode(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} }
return resultDTO; return resultDTO;
} }
...@@ -119,6 +120,25 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -119,6 +120,25 @@ public class CampaignServiceImpl implements CampaignService {
return result; return result;
} }
@Override
public ResultDTO findCampaignById(Long campaignId) {
logger.info("=== Start find campaign by id: " + campaignId);
ResultDTO resultDTO = new ResultDTO();
try {
Campaign campaign = campaignRepository.findById(campaignId).orElse(null);
if(campaign != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(campaign);
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
private String generateCampaignCode(String campaignType, Short chanel) { private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR); int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepository.getMaxCampaignIndex(); String maxIndexStr = campaignRepository.getMaxCampaignIndex();
......
...@@ -63,4 +63,11 @@ public class CampaignController { ...@@ -63,4 +63,11 @@ public class CampaignController {
ResultDTO result = campaignExecuteService.searchInteractiveResult(dto); ResultDTO result = campaignExecuteService.searchInteractiveResult(dto);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@RequestMapping(value = "/find-campaign-by-id/{campaignId}", method = RequestMethod.GET)
public ResponseEntity<ResultDTO> findCampaignById(@PathVariable Long campaignId) {
ResultDTO resultDTO = campaignService.findCampaignById(campaignId);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
} }
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