package cn.hmsoft.skill.data.dao.cf.enrol;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.hmsoft.skill.data.model.cf.enrol.CfEnrolParam;
import cn.hmsoft.helper.StringHelper;
import cn.hmsoft.jdbc.core.PlatformDaoSupport;
import cn.hmsoft.jdbc.entity.Pager;
import cn.hmsoft.jdbc.entity.QueryOrder;

@Repository
public class CfEnrolParamDao extends PlatformDaoSupport<CfEnrolParam> {

	public Pager pageParam(Integer start, Integer limit, String query, QueryOrder order) {
		StringBuilder sql = new StringBuilder("select * from cf_enrol_param p");
		if (StringHelper.isEmpty(query)) {
			return this.pageMapBySql(order, start, limit, sql.toString());
		}
		sql.append(" where param_type  like ? or param_name like ?");
		return this.pageMapBySql(order, start, limit, sql.toString(), "%" + query + "%", "%" + query + "%");
	}

	private final static String LIST_PARAM = "select * from cf_enrol_param where param_type=? or 1=?";

	public List<CfEnrolParam> listParam(String param_type) {
		return this.listBySql(LIST_PARAM, param_type, StringHelper.isEmpty(param_type) ? 1 : 2);

	}

}
