package com.style24.admin.biz.web;

import java.util.Collection;

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

import com.style24.admin.biz.service.TsaRendererService;
import com.style24.admin.support.controller.TsaBaseController;
import com.style24.persistence.domain.Color;
import com.style24.persistence.domain.CommonCode;
import com.style24.persistence.domain.DelvFeePolicy;

import lombok.extern.slf4j.Slf4j;

/**
 * 콤보박스, 체크박스, 라디오버튼 구성 시 필요한 Renderer Controller
 *
 * @author renderer
 * @since 2020. 10. 20
 */
@Controller
@RequestMapping("/renderer")
@Slf4j
public class TsaRendererController extends TsaBaseController {

	@Autowired
	private TsaRendererService rendererService;

	/**
	 * 공급업체 목록
	 * @param brandGb - 브랜드구분(S:자사브랜드, E:입점브랜드)
	 * @return
	 * @author gagamel
	 * @since 2019. 11. 4
	 */
	@GetMapping("/supply/company/list/{brandGb}")
	@ResponseBody
	public Collection<CommonCode> getSupplyCompanyList(@PathVariable String brandGb) {
		return brandGb.equals("S") ? rendererService.getSelfSupplyCompanyList() : rendererService.getEntrSupplyCompanyList();
	}

	/**
	 * 입점업체브랜드 목록
	 * @param supplyCompCd - 입점업체관리일련번호
	 * @return
	 * @author gagamel
	 * @since 2019. 6. 7
	 */
	@GetMapping("/supplyCompany/brand/list/{supplyCompCd}")
	@ResponseBody
	public Collection<CommonCode> getSupplyCompanyBrandList(@PathVariable String supplyCompCd) {
		return rendererService.getSupplyCompanyBrandList(supplyCompCd);
	}

//
//	/**
//	 * 브랜드그룹별 브랜드 목록
//	 * @param brandGrpNm - 브랜드그룹명
//	 * @return
//	 * @author gagamel
//	 * @since 2020. 1. 10
//	 */
//	@GetMapping("/group/brand/list/{brandGrpNm}")
//	@ResponseBody
//	public Collection<AdmCommonCode> getGroupBrandList(@PathVariable String brandGrpNm) {
//		return rendererService.getGroupBrandList(brandGrpNm);
//	}
//
//	/**
//	 * 권한별 브랜드 목록
//	 * @return
//	 * @author eskim
//	 * @since 2019. 6.17
//	 */
//	@GetMapping("/brand/AuthBrandlist")
//	@ResponseBody
//	public Collection<AdmCommonCode> getAuthBrandList() {
//		return rendererService.getAuthBrandList(AdmSession.getInfo().getUserId());
//	}

	/**
	 * 출고처 목록
	 * @param supplyCompCd - 공급업체코드
	 * @return
	 * @author gagamel
	 * @since 2020. 11. 4
	 */
	@GetMapping("/delvloc/list/{supplyCompCd}")
	@ResponseBody
	public Collection<CommonCode> getDeliveryLocList(@PathVariable String supplyCompCd) {
		return rendererService.getDeliveryLocList(supplyCompCd);
	}

	/**
	 * 배송비정책 목록
	 * @param supplyCompCd - 공급업체코드
	 * @return
	 * @author eskim
	 * @since 2020. 11. 25
	 */
	@GetMapping("/delvFee/list/{supplyCompCd}")
	@ResponseBody
	public Collection<CommonCode> getDeliveryFeeList(@PathVariable String supplyCompCd) {
		return rendererService.getSupplyDeliveryFeePolicyList(supplyCompCd);
	}
	
	/**
	 * 업체별 배송비정책 목록(정책명)
	 * @param supplyCompCd - 공급업체코드
	 * @return
	 * @author eskim
	 * @since 2021. 07. 19
	 */
	@GetMapping("/delvPolicy/list/{supplyCompCd}")
	@ResponseBody
	public Collection<DelvFeePolicy> getSupplyDeliveryPolicyList(@PathVariable String supplyCompCd) {
		return rendererService.getSupplyDeliveryPolicyList(supplyCompCd);
	}

	/**
	 * 벤더외부몰 목록
	 * @param vendorId - 벤더ID
	 * @return
	 * @author gagamel
	 * @since 2021. 7. 5
	 */
	@GetMapping("/vendor/extmall/list/{vendorId}")
	@ResponseBody
	public Collection<CommonCode> getVendorExtmallList(@PathVariable String vendorId) {
		return rendererService.getVendorExtmallList(vendorId);
	}

//	/**
//	 * 벤더외부몰판매매장 목록
//	 * @param vendorId - 벤더ID
//	 * @return
//	 * @author gagamel
//	 * @since 2020. 4. 28
//	 */
//	@GetMapping("/vendor/extmall/sellStore/list/{vendorId}")
//	@ResponseBody
//	public Collection<AdmCommonCode> getVendorExtmallSellStoreList(@PathVariable String vendorId) {
//		return rendererService.getVendorExtmallSellStoreList(vendorId);
//	}
//
	/**
	 * 현재 유효한 공통코드 목록
	 * @param cdGb - 공통그룹코드
	 * @return
	 * @author eskim
	 * @since 2020. 01. 22
	 */
	@GetMapping("/avail/commonCode/list/{cdGb}")
	@ResponseBody
	public Collection<CommonCode> getAvailCommonCodeList(@PathVariable String cdGb) {
		return rendererService.getAvailCommonCodeList(cdGb);
	}

	/**
	 * 업체별 색상 목록
	 * @param cdGb - 공통그룹코드
	 * @return
	 * @author eskim
	 * @since 2020. 01. 22
	 */
	@GetMapping("/avail/color/list")
	@ResponseBody
	public Collection<CommonCode> getColorList() {
		Color color = new Color();
		return rendererService.getColorList(color);
	}
//
//	/**
//	 * MD별 브랜드 목록
//	 * @param mdId - 엠디아이디
//	 * @return
//	 * @author jaewonho
//	 * @since 2020. 02. 11
//	 */
//	@GetMapping("/md/brand/list/{mdId}")
//	@ResponseBody
//	public Collection<AdmCommonCode> getMdBrandList(@PathVariable String mdId) {
//		return rendererService.getMdBrandList(mdId);
//	}
//
//	/**
//	 * MD별 브랜드그룹 목록
//	 * @param mdId - 엠디아이디
//	 * @return
//	 * @author jaewonho
//	 * @since 2020. 02. 11
//	 */
//	@GetMapping("/md/brand/grp/list/{mdId}")
//	@ResponseBody
//	public Collection<AdmCommonCode> getMdBrandGrpList(@PathVariable String mdId) {
//		return rendererService.getMdBrandGrpList(mdId);
//	}
//
//	/**
//	 * 판매몰 목록
//	 * @param
//	 * @return
//	 * @author swkim
//	 * @since 2020. 03. 19
//	 */
//	@GetMapping("/sellStore/list")
//	@ResponseBody
//	public Collection<AdmCommonCode> getSellStoreList() {
//		return rendererService.getSellStoreList();
//	}

	/**
	 * 제휴채널 목록
	 * @param afChannel - 상위제휴채널
	 * @return
	 * @author gagamel
	 * @since 2021. 1. 20
	 */
	@GetMapping("/aflink/list/{afChannel}")
	@ResponseBody
	public Collection<CommonCode> getAflinkList(@PathVariable String afChannel) {
		return rendererService.getAflinkList(afChannel);
	}

}
