package com.engine.kq.wfset.attendance.framework;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.ArrayUtils;
import weaver.common.StringUtil;

/**
 * @author wangcd
 * @version 9.0 2016-05-17
 */
public abstract class BaseEntity implements Serializable {
	private Map<String, Object> param;
	
	protected int rowNum;
	
	private boolean isDown;
	
	protected String errorMessage;
	
	public BaseEntity() {
		this(true);
	}
	
	public BaseEntity(boolean arg) {
		this.param = new HashMap<String, Object>();
		if(arg) init();
	}
	
	protected abstract void init();

	public Object get(String key) {
		return param.get(StringUtil.vString(key));
	}

	public void put(String key, Object value) {
		if(StringUtil.isNotNull(key)) {
			this.param.put(StringUtil.vString(key), value);
		}
	}
	
	public void putAll(Map<String, String> map) {
		this.param.putAll(map);
	}
	
	public Object getId() {
		return null;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public boolean isDown() {
		return isDown;
	}

	public void setDown(boolean isDown) {
		this.isDown = isDown;
	}

	public int getRowNum() {
		return rowNum;
	}

	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}

	public String getSql() {
		return "";
	}
	
	public Object[] toInsertObj() {
		return new Object[]{};
	}
	
	public Object[] toUpdateObj() {
		return ArrayUtils.addAll(toInsertObj(), new Object[]{getId()});
	}
}
