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