package cn.hmsoft.frame.data.dao;

import org.springframework.stereotype.Repository;

import cn.hmsoft.frame.data.model.FrameDictName;
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 FrameDictNameDao extends PlatformDaoSupport<FrameDictName>{

	public Pager pageDictType(Integer start, Integer limit, String query, QueryOrder order) {
		String sql = "select a.*,b.dict_total from frame_dict_name a left join (select dict_name,count(1) dict_total from frame_dict group by dict_name) b on a.dict_name=b.dict_name ";
		if (StringHelper.isEmpty(query))
			return this.pageBySql(FrameDictName.class, order, start, limit, sql);
		sql = sql + " where a.dict_name like ? or dict_desc like ? ";
		return this.pageMapBySql(order, start, limit, sql, "%" + query + "%", "%" + query + "%");
	}
}
