/**
 * date : 2022. 4. 26.
 * auth : ckr
 * desc : 유치 현황 관리
 */
package kr.co.uplus.ez.api.attractMgt;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import kr.co.uplus.ez.api.attractMgt.dto.*;
import kr.co.uplus.ez.common.components.ValidComponents;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Map;

@RestController
@RequestMapping(value = "api/v1/bo/attractMgt")
public class AttractMgtController {

	@Autowired
	AttractMgtService attractService;

	@Autowired
	ValidComponents validComponents;

	/**
	 * date : 2022. 4. 26.
	 * auth : ckr
	 * desc : 유치채널 목록조회
	 * @param channelListReqDto
	 * @return
	 * @
	 */
	@ApiOperation(value = "channelList", notes = "유치채널 목록조회")
	@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
	@RequestMapping(value = "/channelList" , method = {RequestMethod.POST})
	@ResponseBody
	public ChannelListResDto channelList(@RequestBody @Valid ChannelListReqDto channelListReqDto, BindingResult bindingResult) {
		if (validComponents.validParameter(bindingResult)) {
			return new ChannelListResDto(ApiResponseCode.CM_PARAMETER_ERROR);
		}
		return attractService.channelList(channelListReqDto);
	}

	/**
	 * date : 2022. 4. 26.
	 * auth : ckr
	 * desc : 유치채널 목록 엑셀 다운로드
	 * @param channelListExcelReqDto
	 * @return
	 * @
	 */
	@ApiOperation(value = "channelListExcel", notes = "유치채널 목록 엑셀 다운로드")
	@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
	@RequestMapping(value = "/channelListExcel" , method = {RequestMethod.POST})
	@ResponseBody
	public ChannelListExcelResDto channelListExcel(@RequestBody @Valid ChannelListExcelReqDto channelListExcelReqDto, BindingResult bindingResult) {
		if (validComponents.validParameter(bindingResult)) {
			return new ChannelListExcelResDto(ApiResponseCode.CM_PARAMETER_ERROR);
		}
		return attractService.channelListExcel(channelListExcelReqDto);
	}

	/**
	 * date : 2022. 4. 26.
	 * auth : ckr
	 * desc : 유치 채널 상세 조회
	 * @param channelDetailReqDto
	 * @return
	 * @
	 */
	@ApiOperation(value = "channelDetail", notes = "유치 채널 상세 조회")
	@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
	@RequestMapping(value = "/channelDetail" , method = {RequestMethod.POST})
	@ResponseBody
	public ChannelDetailResDto channelDetail(@RequestBody @Valid ChannelDetailReqDto channelDetailReqDto, BindingResult bindingResult) {
		if (validComponents.validParameter(bindingResult)) {
			return new ChannelDetailResDto(ApiResponseCode.CM_PARAMETER_ERROR);
		}
		return attractService.channelDetail(channelDetailReqDto);
	}

	/**
	 * date : 2022. 4. 26.
	 * auth : ckr
	 * desc : 발송건수 엑셀 다운로드
	 * @param channelDetailReqDto
	 * @return
	 * @
	 */
	@ApiOperation(value = "sendNumberListExcel", notes = "유치 채널 상세 조회")
	@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
	@RequestMapping(value = "/sendNumberListExcel" , method = {RequestMethod.POST})
	@ResponseBody
	public ChannelDetailResDto sendNumberListExcel(@RequestBody @Valid ChannelDetailReqDto channelDetailReqDto, BindingResult bindingResult) {
		if (validComponents.validParameter(bindingResult)) {
			return new ChannelDetailResDto(ApiResponseCode.CM_PARAMETER_ERROR);
		}
		return attractService.sendNumberListExcel(channelDetailReqDto);
	}
}
