package cokr.xit.fims.cvlc.web;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.servlet.ModelAndView;

import cokr.xit.base.code.CommonCode;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.crdn.CrdnQuery;
import cokr.xit.fims.crdn.service.CrdnService;
import cokr.xit.fims.cvlc.service.CrdnCvlcptService;

/**민원관리 서비스 웹 컨트롤러.<br />
 * {웹 컨텍스트}/cvlc/cvlc03 로 접근할 수 있다.
 * @author leebj
 */
public class Cvlc03Controller extends ApplicationController {

	public static final String CLASS_URL = "/cvlc/cvlc03";

	public class METHOD_URL {
		public static final String
		civilComplaintManagementMain = "/010/main.do",
		getCivilComplaintList = "/010/list.do"
		;
	}

	@Resource(name="crdnService")
	private CrdnService crdnService;

	@Resource(name="crdnCvlcptService")
	private CrdnCvlcptService crdnCvlcptService;

	/** 민원 관리 메인화면을 연다.
	 * @return fims/cvlc/cvlc03010-main
	 */
	public ModelAndView civilComplaintManagementMain() {
		ModelAndView mav = new ModelAndView();
		mav.setViewName("fims/cvlc/cvlc03010-main");
		mav.addObject("pageName", "cvlc03010-main");

		Map<String, List<CommonCode>> commonCodes = getCodesOf("FIM022","FIM026", "FIM054");
		mav.addObject("FIM054List", commonCodes.get("FIM054"));
		addCodes(commonCodes, mav, "FIM022", "FIM026");
		return mav;
	}

	/**민원자료 목록을 조회한다.<br />
	 * {@link CrdnService#getCrackdownList(CrdnQuery)} 참고
	 * @param query 민원자료 목록 조회 조건
	 * @return jsonView
	 */
	public ModelAndView getCivilComplaintList(CrdnQuery query) {
		setFetchSize(query);
		return setCollectionInfo(new ModelAndView("jsonView"),crdnCvlcptService.getCivilComplaintList(query),"");
	}
}
