package com.style24.batch.biz.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.style24.batch.biz.job.statistics.TsbInflowStatisticsJob;
import com.style24.batch.biz.job.statistics.TsbInflowYesterdayStatisticsJob;
import com.style24.core.support.controller.TscBaseController;

import lombok.extern.slf4j.Slf4j;

/**
 * 통계 Controller
 * 
 * @author gagamel
 * @since 2021. 5. 24
 */
@Controller
@RequestMapping("/statistics")
@CrossOrigin(origins = "${domain.admin}")
@Slf4j
public class TsbStatisticsController extends TscBaseController {

	@Autowired
	private TsbInflowStatisticsJob inflowStatisticsJob;

	@Autowired
	private TsbInflowYesterdayStatisticsJob inflowYesterdayStatisticsJob;

	/**
	 * 제휴채널 유입집계 생성
	 * @throws Exception
	 * @author gagamel
	 * @since 2021. 5. 24
	 */
	@GetMapping("/aflink/inflow/create")
	@ResponseBody
	public String createAflinkInflow() throws Exception {
		inflowStatisticsJob.runById("cron.statistics.aflink.inflow.create");
		return "OK";
	}

	/**
	 * 제휴채널 유입집계 전일자 생성
	 * @return 메시지
	 * @throws Exception
	 * @author gagamel
	 * @since 2021. 5. 24
	 */
	@GetMapping("/aflink/inflow/yesterday/create")
	@ResponseBody
	public String createAflinkInflowYesterday() throws Exception {
		inflowYesterdayStatisticsJob.runById("cron.statistics.aflink.inflow.yesterday.create");
		return "OK";
	}

}
