package cn.hmsoft.hmplatform.project.data.dao;

import org.springframework.stereotype.Repository;

import cn.hmsoft.helper.StringHelper;
import cn.hmsoft.hmplatform.project.data.model.PSchool;
import cn.hmsoft.jdbc.core.PlatformDaoSupport;
import cn.hmsoft.jdbc.entity.Pager;
import cn.hmsoft.jdbc.entity.QueryOrder;

@Repository
public class PSchoolDao extends PlatformDaoSupport<PSchool> {

	public Pager pageSchool(Integer start, Integer limit, String query, 
			QueryOrder queryOrder) {
		StringBuilder sql = new StringBuilder();
		sql.append("select * from p_school where 1=1 ");
		if (StringHelper.isEmpty(query)) {
			return this.pageMapBySql(queryOrder, start, limit, sql.toString());
		}
		sql.append(" and (school_code = ? or school_name like ?)");
		return this.pageMapBySql(queryOrder, start, limit, sql.toString(), query, "%" + query + "%");
	}
}
