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

Posted guoshunwgs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>

 

以上是关于xml Dao service 三层参数以及对应关系的主要内容,如果未能解决你的问题,请参考以下文章

学习笔记dao,domain,service三层理解

046医疗项目-模块四:采购单模块—采购单审核(Dao,Service,Action三层)

Action+Service +Dao三层的功能划分

Java Web基础——Action+Service +Dao三层的功能划分

通过条件的查询----涉及到三层(Action Service DAO)

Springboot三层架构--DAO层Service层Colltroler层--这波我在外太空