package com.viettel.campaign.web.rest;

import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.service.ScenarioService;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.ScenarioDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author anhvd_itsol
 */

@RestController
@RequestMapping("/ipcc/campaign/scenario")
@CrossOrigin
public class ScenarioController {
    private static final Logger logger = LoggerFactory.getLogger(ScenarioController.class);
    @Autowired
    ScenarioService scenarioService;

    @RequestMapping(value="/findOneByCampaignIdAndCompanyId", method = RequestMethod.GET)
    Scenario findOneByCampaignIdAndCompanyId(@RequestParam Long campaignId, @RequestParam Long companySiteId) {
        return scenarioService.findScenarioByCampaignIdAndCompanySiteId(campaignId, companySiteId);
    }

    @RequestMapping(method = RequestMethod.PUT)
    ResponseEntity<ResultDTO> update(@RequestBody ScenarioDTO scenario) {
        ResultDTO resultDTO = scenarioService.update(scenario);
        return new ResponseEntity<>(resultDTO, HttpStatus.OK);
    }
}
