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

anhvd commit change

parent e5e6e51e
......@@ -16,4 +16,6 @@ public interface CampaignService {
ResultDTO addNewCampaign(CampaignDTO campaignDTO);
Map countRecallCustomer(Long companySiteId, Long agentId);
ResultDTO findCampaignById(Long campaignId);
}
......@@ -58,6 +58,7 @@ public class CampaignServiceImpl implements CampaignService {
@Override
public ResultDTO addNewCampaign(CampaignDTO campaignDTO) {
logger.info("=== Start add new campaign ");
ResultDTO resultDTO = new ResultDTO();
Campaign campaign = modelMapper.map(campaignDTO, Campaign.class);
Long campaignId;
......@@ -90,12 +91,12 @@ public class CampaignServiceImpl implements CampaignService {
timeZoneDialModeRepository.saveAll(lstTimeZoneModeToInser);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setErrorCode(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(campaignResult);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setErrorCode(Constants.ApiErrorDesc.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
......@@ -119,6 +120,25 @@ public class CampaignServiceImpl implements CampaignService {
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) {
int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepository.getMaxCampaignIndex();
......
......@@ -63,4 +63,11 @@ public class CampaignController {
ResultDTO result = campaignExecuteService.searchInteractiveResult(dto);
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