代码如下:
先创建一个Provider类:
public class RptEbankFsymtTranflowingProvider {
public String select(String orgId, String startDate, String endDate, String merId) {
String sql = "select * from RPT_EBANK_FSYMT_TRANFLOWING where 1=1";
if (orgId != null) {
sql += " and ORG_ID=#{orgId}";
}
if (startDate != null) {
sql += " and DATA_DT>=#{startDate}";
}
if (endDate != null) {
sql += " and DATA_DT<=#{endDate}";
}
if (merId != null) {
sql += " and MER_ID=#{merId}";
}
return sql;
}
}
然后在代码中类似如下使用它:
@Mapper
public interface RptEbankMerchantDetailMapper {
// 查询所有数据
@Select("select * from RPT_EBANK_MERCHANT_DETAIL")
List<RptEbankMerchantDetail> getAllRptEbankMerchantDetail();
@SelectProvider(method = "select", type = RptEbankMerchantDetailProvider.class)
List<RptEbankMerchantDetail> getRptEbankMerchantDetail(@Param("orgId") String orgId,
@Param("startDate") String startDate,
@Param("endDate") String endDate,
@Param("merId") String merId);
}