Spring Boot 使用DAO层不使用xml直接进行数据访问


  一般我们开发Spring boot的web应用的时候,一般会实现Service接口,然后实现对应的类,调用方法,通过对DAO映射进行数据访问,我现在就说一下如何实现简单快速的实现数据的访问。通过对DAO层直接进行数据的访问.

@Results({
@Result(column = "id",property = "id")
})

@SelectProvider(type = SqlProvider.class,method = "queryReceivableForm")
List<ReceivableForm> queryReceivableForm(Map<String, Object> map);

class SqlProvider{
public String queryReceivableForm(Map<String,Object> map){
String sql = new SQL(){
{
SELECT("id,settlement_cycle,tc_code,insurance_name,payment_channel,amount_receivable,refund_amount," +
"net_settlement,actual_amount_received,amount_paid,net_amount");
FROM("t_insurance_collection");
WHERE("batch_no = #{batchNo}");
WHERE("archive_flag = '1'");
if(!StringUtils.isEmpty(map.get("paymentChannel")))
{
WHERE("payment_channel = #{paymentChannel}");
}
}
}.toString();
if (map.get("offset")!=null&&map.get("limit")!=null){
sql += "limit #{offset},#{limit}";
}
return sql;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM