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.shoplinker.TsbShoplinkerInvoiceJob;
import com.style24.batch.biz.job.shoplinker.TsbShoplinkerOrderJob;
import com.style24.batch.biz.job.shoplinker.TsbShoplinkerStockJob;
import com.style24.core.support.controller.TscBaseController;

import lombok.extern.slf4j.Slf4j;

/**
 * 샵링커 Controller
 *
 * @author jmh
 * @since 2021. 6. 21
 */
@Controller
@RequestMapping("/shoplinker")
@CrossOrigin(origins = "${domain.admin}")
@Slf4j
public class TsbShoplinkerController extends TscBaseController {

	@Autowired
	private TsbShoplinkerStockJob shoplinkerStockJob;

	@Autowired
	private TsbShoplinkerOrderJob shoplinkerOrderJob;

	@Autowired
	private TsbShoplinkerInvoiceJob shoplinkerInvoiceJob;



	/**
	 * 재고전송 10시
	 * @throws Exception - 예외처리
	 * @author jmh
	 * @since 2021. 06. 22
	 */
	@GetMapping("/stock/send10")
	@ResponseBody
	public String sendStock10() throws Exception {
		shoplinkerStockJob.runById("cron.shoplinker.stock.send10");
		return "OK";
	}

	/**
	 * 재고전송 15시
	 * @throws Exception - 예외처리
	 * @author jmh
	 * @since 2021. 06. 22
	 */
	@GetMapping("/stock/send15")
	@ResponseBody
	public String sendStock15() throws Exception {
		shoplinkerStockJob.runById("cron.shoplinker.stock.send15");
		return "OK";
	}

	/**
	 * 주문수집
	 * @throws Exception - 예외처리
	 * @author jmh
	 * @since 2021. 06. 22
	 */
	@GetMapping("/order/receive")
	@ResponseBody
	public String receiveOrder() throws Exception {
		shoplinkerOrderJob.runById("cron.shoplinker.order.receive");
		return "OK";
	}

	/**
	 * 송장전송
	 * @throws Exception - 예외처리
	 * @author jmh
	 * @since 2021. 06. 22
	 */
	@GetMapping("/invoice/send")
	@ResponseBody
	public String sendInvoice() throws Exception {
		shoplinkerInvoiceJob.runById("cron.shoplinker.invoice.send");
		return "OK";
	}

}
