Commit 9b2fde6b authored by ='s avatar =

hungtt-commit update campaign

parent 09c40d24
......@@ -45,5 +45,7 @@ public interface CampaignService {
List<TimeZoneDialMode> getCampaignTimeZoneMode (Long campaignId, Long companySiteId);
ResultDTO renewCampaign (CampaignDTO campaignDTO);
ResultDTO renewCampaign(CampaignDTO campaignDTO);
ResultDTO updateCampaign(CampaignDTO dto);
}
......@@ -382,6 +382,35 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO updateCampaign(CampaignDTO dto) {
ResultDTO resultDTO = new ResultDTO();
List<TimeZoneDialModeDTO> lstTimeZone = dto.getLstTimeZone();
List<TimeRangeDialModeDTO> lstTimeRange = dto.getLstTimeRange();
Campaign campaignEntity = modelMapper.map(dto, Campaign.class);
try {
// Save campaign to database
campaignRepository.save(campaignEntity);
// Save time dial
for (TimeRangeDialModeDTO timeRangeDto : lstTimeRange) {
TimeRangeDialMode timeRangeEntity = modelMapper.map(timeRangeDto, TimeRangeDialMode.class);
timeRangeDialModeRepository.save(timeRangeEntity);
}
for (TimeZoneDialModeDTO timeZoneDto : lstTimeZone) {
TimeZoneDialMode timeZoneEntity = modelMapper.map(timeZoneDto, TimeZoneDialMode.class);
timeZoneDialModeRepository.save(timeZoneEntity);
}
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;
}
private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepositoryCustom.getMaxCampaignIndex();
......
......@@ -2,8 +2,6 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.TimeRangeDialMode;
import com.viettel.campaign.model.ccms_full.TimeZoneDialMode;
import com.viettel.campaign.repository.ccms_full.TimeRangeDialModeRepository;
import com.viettel.campaign.repository.ccms_full.TimeZoneDialModeRepository;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.web.dto.CampaignDTO;
......@@ -41,12 +39,6 @@ public class CampaignController {
@Autowired
CampaignExecuteService campaignExecuteService;
@Autowired
TimeRangeDialModeRepository timeRangeDialModeRepository;
@Autowired
TimeZoneDialModeRepository timeZoneDialModeRepository;
@PostMapping("/searchCampaignExecute")
@ResponseBody
public ResponseEntity<ResultDTO> searchCampaignExecute(@RequestBody CampaignRequestDTO requestDto) {
......@@ -84,6 +76,20 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/findCampaignTimeRangeMode")
@ResponseBody
public ResponseEntity<?> findCampaignTimeRangeMode(@RequestParam("campaignId") Long campaignId, @RequestParam("companySiteId") Long companySiteId) {
List<TimeRangeDialMode> list = campaignService.getCampaignTimeRangeMode(campaignId, companySiteId);
return new ResponseEntity<>(list, HttpStatus.OK);
}
@GetMapping("/findCampaignTimeZoneMode")
@ResponseBody
public ResponseEntity<?> findCampaignTimeZoneMode(@RequestParam("campaignId") Long campaignId, @RequestParam("companySiteId") Long companySiteId) {
List<TimeZoneDialMode> list = campaignService.getCampaignTimeZoneMode(campaignId, companySiteId);
return new ResponseEntity<>(list, HttpStatus.OK);
}
@PostMapping("/searchInteractiveResult")
@ResponseBody
public ResponseEntity<ResultDTO> searchInteractiveResult(@RequestBody CampaignRequestDTO dto) throws Exception {
......@@ -165,20 +171,11 @@ public class CampaignController {
headers.setContentType(MediaType.parseMediaType("application/vnd.ms-excel"));
return new ResponseEntity<byte[]>(contentReturn, headers, HttpStatus.OK);
}
@RequestMapping(value = "/findCampaignTimeRangeMode", method = RequestMethod.GET)
public List<TimeRangeDialMode> findCampaignTimeRangeMode(@RequestParam Long campaignId, @RequestParam Long companySiteId) {
return timeRangeDialModeRepository.findTimeRangeDialModeByCampaignIdAndCompanySiteId(campaignId, companySiteId);
}
@RequestMapping(value = "/findCampaignTimeZoneMode", method = RequestMethod.GET)
public List<TimeZoneDialMode> findCampaignTimeZoneMode(@RequestParam Long campaignId, @RequestParam Long companySiteId) {
return timeZoneDialModeRepository.findTimeZoneDialModeByCampaignIdAndCompanySiteId(campaignId, companySiteId);
}
@RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
@PostMapping("/updateCampaign")
@ResponseBody
public ResponseEntity<?> updateCampaign(@RequestBody CampaignDTO dto) {
ResultDTO resultDTO = campaignService.updateCampaign(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
}
......@@ -248,6 +248,6 @@ public class CustomerController {
@RequestParam("sort") String sort,
@RequestParam("campaignId") Long campaignId,
@RequestParam("companySiteId") Long companySiteId) {
return null;//customerService.searchCustomerListInfoFromCustomerList(page, pageSize, sort, campaignId, companySiteId);
return null;// customerService.searchCustomerListInfoFromCustomerList(page, pageSize, sort, campaignId, companySiteId);
}
}
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