package cokr.xit.fims.eqplc.web;

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

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.poi.ss.usermodel.CellStyle;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import cokr.xit.base.code.CommonCode;
import cokr.xit.base.code.service.CodeQuery;
import cokr.xit.base.code.service.CodeService;
import cokr.xit.base.code.service.bean.CodeBean;
import cokr.xit.base.docs.xls.CellDef;
import cokr.xit.base.docs.xls.Format;
import cokr.xit.base.docs.xls.Style;
import cokr.xit.base.docs.xls.XLSWriter;
import cokr.xit.base.security.Authority;
import cokr.xit.base.security.SecuredUserInfo;
import cokr.xit.base.security.access.service.AuthorityService;
import cokr.xit.base.user.UserQuery;
import cokr.xit.base.user.dao.UserMapper;
import cokr.xit.base.user.service.UserService;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.base.FimsUser;
import cokr.xit.fims.base.service.bean.OgdpBean;
import cokr.xit.fims.cmmn.service.bean.StngBean;
import cokr.xit.fims.cmmn.xls.FormatMaker;
import cokr.xit.fims.cmmn.xls.StyleMaker;
import cokr.xit.fims.crdn.service.CrdnStngService;
import cokr.xit.fims.crdn.web.Crdn06Controller;
import cokr.xit.fims.crdn.web.Crdn06Controller.METHOD_URL;
import cokr.xit.fims.eqplc.Eqplc;
import cokr.xit.fims.eqplc.EqplcQuery;
import cokr.xit.fims.eqplc.dao.EqplcMapper;
import cokr.xit.fims.eqplc.service.EqplcService;
import cokr.xit.fims.eqplc.service.bean.EqplcServiceBean;
import cokr.xit.fims.task.Task;
import cokr.xit.foundation.data.DataObject;

@Controller
@RequestMapping(name="단속장비장소 관리", value="/eqplc")
public class EqplcController extends ApplicationController {
	
	@Resource(name = "eqplcService")
	private EqplcService eqplcService;

	@GetMapping(name="단속장비장소 관리 메인", value="/main.do")
	public ModelAndView main() {
		return new ModelAndView("fims/eqplc/main")
			.addObject("pageName", "eqplc");
	}
	
	@GetMapping(name="단속장비장소 목록 조회", value="/list.do")
	public ModelAndView getList(EqplcQuery req) {
		return setPagingInfo(new ModelAndView("jsonView"), eqplcService.getList(req),"eqplc");				
	}
	
	@GetMapping(name="단속장비장소 상세 조회", value="info.do")
	public ModelAndView getInfo(@RequestParam String eqplcCd) {
		DataObject info = eqplcCd != "" ? eqplcService.getOne(eqplcCd) : new DataObject();

		return new ModelAndView("fims/eqplc/info")
			.addObject("pageName", "info")
			.addObject("eqplcInfo", toJson(info));
	}	
	
	@PostMapping(name="단속장비장소 관리 목록 등록", value="/insert.do")
	public ModelAndView insert(Eqplc req) {

		String rtnMsg = eqplcService.insert(req);
		return new ModelAndView("jsonView").addObject("saved", rtnMsg.contains("[S]"));		
	}
	
	@PostMapping(name="단속장비장소 관리 목록 수정", value="/update.do")
	public ModelAndView update(Eqplc req) {

		String rtnMsg = eqplcService.update(req);
		return new ModelAndView("jsonView").addObject("saved", rtnMsg.contains("[S]"));		
	}		

}