|
| 1 | +package com.codingapi.springboot.fast.jpa.repository; |
| 2 | + |
| 3 | +import com.codingapi.springboot.fast.jdbc.JdbcQueryContext; |
| 4 | +import org.springframework.data.domain.Page; |
| 5 | +import org.springframework.data.domain.PageRequest; |
| 6 | +import org.springframework.data.repository.NoRepositoryBean; |
| 7 | + |
| 8 | +import java.util.List; |
| 9 | +import java.util.Map; |
| 10 | + |
| 11 | +@NoRepositoryBean |
| 12 | +public interface DynamicNativeRepository<T, ID> extends BaseRepository<T, ID> { |
| 13 | + |
| 14 | + default List<Map<String, Object>> dynamicNativeListMapQuery(String sql, Object... params) { |
| 15 | + return JdbcQueryContext.getInstance().getJdbcQuery().queryForList(sql, params); |
| 16 | + } |
| 17 | + |
| 18 | + default List<T> dynamicNativeListQuery(String sql, Object... params) { |
| 19 | + return dynamicNativeListQuery(getEntityClass(), sql, params); |
| 20 | + } |
| 21 | + |
| 22 | + default <V> List<V> dynamicNativeListQuery(Class<V> clazz, String sql, Object... params) { |
| 23 | + return JdbcQueryContext.getInstance().getJdbcQuery().queryForList(sql, clazz, params); |
| 24 | + } |
| 25 | + |
| 26 | + default Page<T> dynamicNativePageQuery(String sql, String countSql, PageRequest request, Object... params) { |
| 27 | + return dynamicNativePageQuery(getEntityClass(), sql, countSql, request, params); |
| 28 | + } |
| 29 | + |
| 30 | + default Page<T> dynamicNativePageQuery(String sql, PageRequest request, Object... params) { |
| 31 | + return dynamicNativePageQuery(getEntityClass(), sql, request, params); |
| 32 | + } |
| 33 | + |
| 34 | + default <V> Page<V> dynamicNativePageQuery(Class<V> clazz, String sql, String countSql, PageRequest request, Object... params) { |
| 35 | + return JdbcQueryContext.getInstance().getJdbcQuery().queryForPage(sql, countSql, clazz, request, params); |
| 36 | + } |
| 37 | + |
| 38 | + default <V> Page<V> dynamicNativePageQuery(Class<V> clazz, String sql, PageRequest request, Object... params) { |
| 39 | + return JdbcQueryContext.getInstance().getJdbcQuery().queryForPage(sql, clazz, request, params); |
| 40 | + } |
| 41 | + |
| 42 | + default Page<Map<String, Object>> dynamicNativePageMapQuery(String sql, String countSql, PageRequest request, Object... params) { |
| 43 | + return JdbcQueryContext.getInstance().getJdbcQuery().queryForPage(sql, countSql, request, params); |
| 44 | + } |
| 45 | + |
| 46 | + default Page<Map<String, Object>> dynamicNativePageMapQuery(String sql, PageRequest request, Object... params) { |
| 47 | + return JdbcQueryContext.getInstance().getJdbcQuery().queryForPage(sql, request, params); |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments