<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"> <sqlMap namespace="mail"> <typeAlias alias="ResultItem" type="org.metas.dao.result.ResultItem"/> <typeAlias alias="CustomerItem" type="org.metas.dao.result.CustomerItem"/> <typeAlias alias="MailItem" type="org.metas.dao.result.MailItem"/> <typeAlias alias="QryCondition" type="org.metas.web.query.condition.QryCondition"/> <resultMap id="mailItem-map"class="MailItem"> <result property="mailNo" column="MAIL_NO"/> <result property="linkedEvent" column="LINKED_EVENT"/> <result property="sendFrom" column="SEND_FROM"/> <result property="cc" column="CC"/> <result property="sendTime" column="SEND_TIME"/> </resultMap> <select id="query" parameterClass="QryCondition" resultClass="ResultItem"> select b.invite_count as inviteCnt,b.event_no as eventCode, b.title as eventTitle, count(nvl(a.send_from,0)) as responseCnt from mail a, event b where a.linked_event=b.event_no and a.send_time between to_date(#from#,'YYYY-MM-DD') and to_date(#to#,'YYYY-MM-DD') group by b.invite_count, b.event_no, b.title order by b.event_no </select> <select id="queryCustomer" parameterClass="QryCondition" resultClass="CustomerItem"> select c.name as name,c.email as email from customer c, mail a where a.linked_event=#eventNo# and a.send_time between to_date(#from#,'YYYY-MM-DD') and to_date(#to#,'YYYY-MM-DD') and c.email=a.send_from </select> <select id="totalCount" resultClass="int"> SELECT count(*) as totalCnt FROM mail </select> <select id="queryResultItemByPage" parameterClass="org.metas.dao.result.impl.PaginateParameterImpl" resultClass="MailItem" resultMap="mailItem-map" > <![CDATA[ SELECT * FROM ( SELECT r.*, ROWNUM as row_number FROM ( $querySQL$ ) r WHERE ROWNUM < #endRow# ) WHERE #startRow# <= row_number ]]> </select> </sqlMap>
/** *//** * interface for accessing the mail data and the linked data */ package org.metas.dao; import java.util.List; import org.metas.dao.result.CustomerItem; import org.metas.dao.result.MailItem; import org.metas.dao.result.PaginateParameter; import org.metas.dao.result.ResultItem; import org.metas.web.query.condition.QryCondition; /** *//** * @author wzh * */ publicinterface MailDAO ...{ /** *//** * get analysis result by a query with condition * @param condition QryCondition * @return analysis result Item */ public List<ResultItem> query(QryCondition condition); /** *//** * get mail-list in special page * @param params paginate parameter * @return list as elements of MailItem */ public List<MailItem> queryByPage(PaginateParameter params); /** *//** * query customer by QryCondition * @param condition * @return list as elements of CustomerItem */ public List<CustomerItem> queryCustomer(QryCondition condition); /** *//** * get total mail count from db * @param parameter * @return total mail count */ public Integer getTotalCount(PaginateParameter parameter); }
package org.metas.dao.result; publicinterface PaginateParameter ...{ /** *//** * get item count per-page * @return */ publicint getPageSize(); /** *//** * set item count per-page * @param size */ publicvoid setPageSize(int size); /** *//** * get current page number * @return */ publicint getCurrentPageNo(); /** *//** * set current page number * @param current */ publicvoid setCurrentPageNo(int current); /** *//** * get total item count in all pages * @return */ publicint getTotalItemCnt(); /** *//** * set total item count * @param cnt */ publicvoid setTotalItemCnt(int cnt); /** *//** * count the page * @return */ publicint getPageCnt(); /** *//** * source query SQL for pagination * @return */ public String getQuerySQL(); /** *//** * get the start paging number * @return */ publicint getStartRow(); /** *//** * get the end paging number * @return */ publicint getEndRow(); /** *//** * mapping for the disabled attribute of next page button for HTML * @return */ publicboolean isNextDisabled(); /** *//** * mapping for the disabled attribute of previous button for HTML * @return */ publicboolean isPrevDisabled(); /** *//** * mapping for the disabled attribute of first button for HTML * @return */ publicboolean isFirstDisabled(); /** *//** * mapping for the disabled attribute of last button for HTML * @return */ publicboolean isLastDisabled(); }
package org.metas.web.query.condition; publicinterface QryCondition ...{ /**//** * event no * @return */ public Integer getEventNo(); /**//** * from date as String * @return */ public String getFrom(); /**//** * to date as String * @return */ public String getTo(); }