xml、 Dao service 三层参数以及对应关系

=======service   调用dao用params.put(K,Value);将参数传入后台。

  

BaseResponse response = new BaseResponse();
Map<String,Object> params = new HashMap<String,Object>();
String queryByDay = byday.replaceAll("-","/");
List<OrderDateQueryList> result = null;
params.put("masterId", masterId);
params.put("firstDay", queryByDay);
params.put("lastDay", queryByDay);
try {
result = orderDateQueryDao.findWorkOrderListByMonth(params);
response.setData(result);
response.setInfo(ReturnCode.OK);
response.setReturnCode(ReturnCode.STATUS_200);

=====Dao

public interface OrderDateQueryDao {
List<OrderDateQueryList> findWorkOrderListByMonth(Map<String,Object> params) throws Exception;
}

============xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.eaju.dao.OrderDateQueryDao">
<resultMap type="com.eaju.po.OrderDateQueryList" id="orderDateQueryList">
<result property="id" column="fid" />
<result property="workNo" column="work_no" />
<result property="sendDate" column="send_date" />
<result property="amount" column="amount" />
.................
</resultMap>

<!-- 按月查询已预约工单信息 -->
<select id="findWorkOrderListByMonth" parameterType="java.util.HashMap" resultMap="orderDateQueryList">
<!-- select *
from (select tt.*, ROWNUM as rn
from ( -->
SELECT t.fid,
t.work_no,
to_char(t.send_date,'yyyy/mm/dd HH24:mi:ss') send_date,
to_char(t.complete_date,'yyyy/mm/dd HH24:mi:ss') completeDate,
(select count(1) from  tb_work_order_item i
  where i.work_order_id = t.fid) item_count
FROM tb_work_order t
WHERE
<![CDATA[
    t.master_id=#{masterId}
    and t.status_display='待服务'
    and to_date(to_char(t.booking_time,'yyyy/mm/dd'),'yyyy/mm/dd')>=to_date(#{firstDay},'yyyy/mm/dd')
    and to_date(to_char(t.booking_time,'yyyy/mm/dd'),'yyyy/mm/dd')<=to_date(#{lastDay},'yyyy/mm/dd')
]]>
order by t.send_date desc
<!-- ) tt
where <![CDATA[ROWNUM <= #{rowEnd}]]>) ttt
where <![CDATA[ttt.rn >= #{rowStart}]]> -->
</select>


</mapper>

上一篇:iOS阶段学习第21天笔记(ARC内存管理-Copy-代理)


下一篇:一位交易巨匠的十年心得:如何使用MACD判断后期趋势,把握买卖点