package com.app.framework.core.support.controller;

import com.app.framework.core.support.filter.DateConvertEditor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.util.Date;

/**
 * Controller基类，所有Controller都必须继承该类
 * 	提供获取请求头信息的各种方法
 * 	提供获取参数的各种方法
 */
public abstract class CrudControllerSupport {
	protected Logger logger = null;
	
	public CrudControllerSupport(){
		logger = LoggerFactory.getLogger(getClass().getName());
	}
	
	@InitBinder
	public void initBinder(WebDataBinder binder) {
		binder.registerCustomEditor(Date.class, null, new DateConvertEditor());
		binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
	}

}
