一般我们开发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;
}