@Query(value = " select m.* from mining_area as m " +
" where 1 = 1" +
" and if(:name != ‘‘ , m.name like :name , 1 = 1) " +
" and if(IFNULL(:startDate, ‘‘) != ‘‘ , DATE(m.create_time) > DATE(:startDate) , 1 = 1 ) " +
" and if(IFNULL(:endDate, ‘‘) != ‘‘ , DATE(m.create_time) < DATE(:endDate) , 1 = 1 ) " +
" and if(IFNULL(:status, ‘‘) != ‘‘ , m.audit_status = :status , 1 = 1 ) " +
" and m.deleted = :deleted " +
" and ( m.tree_code like :treeCode and m.audit_status = 3 )" +
" or ( m.tree_code = :noLikeTreeCode ) ",
countQuery = " select count(m.*) from mining_area as m " +
" where 1 = 1" +
" and if(:name != ‘‘ , m.name like :name , 1 = 1) " +
" and if(IFNULL(:startDate, ‘‘) != ‘‘ , DATE(m.create_time) > DATE(:startDate) , 1 = 1 ) " +
" and if(IFNULL(:endDate, ‘‘) != ‘‘ , DATE(m.create_time) < DATE(:endDate) , 1 = 1 ) " +
" and if(IFNULL(:status, ‘‘) != ‘‘ , m.audit_status = :status , 1 = 1 ) " +
" and m.deleted = :deleted " +
" and ( m.tree_code like :treeCode and m.audit_status = 3 )" +
" or ( m.tree_code = :noLikeTreeCode ) ",
nativeQuery = true)
List<MiningArea> findPage(String name, Date startDate, Date endDate, AreaAuditStatusEnum status,
String treeCode, String noLikeTreeCode , Integer deleted, Pageable pageable);
原文:https://www.cnblogs.com/GoslingWu/p/13697326.html