package com.style24.admin.biz.web;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.style24.admin.biz.service.TsaRendererService;
import com.style24.admin.biz.service.TsaDeliveryService;
import com.style24.admin.support.controller.TsaBaseController;
import com.style24.admin.support.security.session.TsaSession;
import com.style24.core.support.message.TscMessageByLocale;
import com.style24.persistence.domain.Delivery;
import com.style24.persistence.domain.DeliveryLoc;

import lombok.extern.slf4j.Slf4j;

import com.gagaframework.web.rest.server.GagaResponse;

/**
 * 택배 Controller
 *
 * @author moon
 * @since 2020. 11. 17
 */
@Controller
@RequestMapping("/ship")
@Slf4j
public class TsaShipController extends TsaBaseController {

	@Autowired
	private TscMessageByLocale message;

	@Autowired
	private Environment env;

	@Autowired
	private TsaRendererService rendererService;

	@Autowired
	private TsaDeliveryService deliveryService;

	@Value("${upload.default.target.path}")
	private String uploadTargetPath;

	/**
	 * 배송/회수지시목록 화면
	 * 
	 * @return ModelAndView
	 * @throws Exception
	 * @author moon
	 * @since 2020. 11. 17
	 */
	@RequestMapping(value = "/dwdirect/list/form")
	public ModelAndView deliveryWithdrawDirectiveListForm() throws Exception {
		ModelAndView mav = new ModelAndView();

		// 사이트구분
		mav.addObject("siteCdList", rendererService.getAvailCommonCodeList("G000"));

		mav.setViewName("delivery/DeliveryWithdrawDirectiveListForm");

		return mav;
	}

	/**
	 * 배송/회수지시 목록
	 * 
	 * @param dwDirective - 배송/회수지시 정보
	 * @return
	 * @throws Exception
	 * @author moon
	 * @since 2020. 11. 17
	 */
	@RequestMapping(value = "/dwdirect/list", method = RequestMethod.POST)
	@ResponseBody
	public Collection<Delivery> getDeliveryWithdrawDirectiveList(@RequestBody Delivery dwDirective) throws Exception {
		return deliveryService.getDeliveryWithdrawDirectiveList(dwDirective);
	}	
}
