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.WxMsgReply;

@Component
public class WxMsgReplyDao extends PlatformDaoSupport<WxMsgReply> {
	private final static String LIST_MSG_REPLY_SQL = "select * from wx_msg_reply where wx_id=0 or wx_id=? order by msg_id";

	public List<WxMsgReply> listMsgReply(int wx_id) {
		return this.listBySql(LIST_MSG_REPLY_SQL, wx_id);
	}

	public Pager pageMsgReply(int wx_id, Integer start, Integer limit, String query, QueryOrder order) {
		String sql = "select * from wx_msg_reply  where wx_id=?";
		if (StringHelper.isEmpty(query))
			return this.pageBySql(order, start, limit, sql, wx_id);
		sql = sql + " and msg_name like ? ";
		return this.pageBySql(order, start, limit, sql, wx_id, "%" + query + "%");
	}
}