Commit 89da29ea authored by Đào Nhật Quang's avatar Đào Nhật Quang

quangdn

parent 9ffdc023
package com.viettel.campaign.repository;
import com.viettel.campaign.model.Campaign;
import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
......
......@@ -16,4 +16,6 @@ public interface CampaignService {
ResultDTO addNewCampaign(CampaignDTO campaignDTO);
Map countRecallCustomer(Long companySiteId, Long agentId);
ResultDTO changeCampaignStatus(CampaignDTO dto);
}
......@@ -119,6 +119,33 @@ public class CampaignServiceImpl implements CampaignService {
return result;
}
@Override
public ResultDTO changeCampaignStatus(CampaignDTO dto) {
ResultDTO result = new ResultDTO();
try {
Optional<Campaign> campaign = campaignRepository.findById(dto.getCampaignId());
if (campaign.isPresent()) {
Campaign entity = campaign.get();
entity.setStatus(dto.getStatus().longValue());
entity.setUpdateTime(new Date());
entity.setUpdateBy(dto.getUpdateBy());
entity.setCampaignId(dto.getCampaignId());
entity.setCompanySiteId(dto.getCompanySiteId());
campaignRepository.save(entity);
result.setData(entity);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription("Entity not found");
}
} catch (Exception e) {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(e.getMessage());
}
return result;
}
private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepository.getMaxCampaignIndex();
......
......@@ -63,4 +63,9 @@ public class CampaignController {
ResultDTO result = campaignExecuteService.searchInteractiveResult(dto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/changeCampaignStatus")
public ResultDTO changeCampaignStatus(@RequestBody CampaignDTO dto) {
return campaignService.changeCampaignStatus(dto);
}
}
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