package cn.hmsoft.weixin.data.dao;

import java.util.List;

import org.springframework.stereotype.Component;

import cn.hmsoft.helper.StringHelper;
import cn.hmsoft.jdbc.core.PlatformDaoSupport;
import cn.hmsoft.jdbc.entity.Pager;
import cn.hmsoft.jdbc.entity.QueryOrder;
import cn.hmsoft.weixin.data.model.WxDefine;

@Component
public class WxDefineDao extends PlatformDaoSupport<WxDefine> {
	public List<WxDefine> listWeiXin(String status) {
		if (StringHelper.isEmpty(status)) {
			String sql = "select * from wx_define";
			return this.listBySql(sql);
		}
		String sql = "select * from wx_define where app_status=?";
		return this.listBySql(WxDefine.class, sql, status);

	}

	public Pager pageDefine(Integer start, Integer limit, String query, QueryOrder order) {
		String sql = "select * from wx_define";
		if (StringHelper.isEmpty(query))
			return this.pageBySql(order, start, limit, sql);
		sql = sql + " where app_name like ?  or wx_code like ? or wx_name like ?";
		return this.pageBySql(order, start, limit, sql, "%" + query + "%", "%" + query + "%", "%" + query + "%");
	}

}