2121import com .alibaba .fastjson .JSONObject ;
2222import com .datastax .oss .driver .api .core .CqlSession ;
2323import com .datastax .oss .driver .api .core .cql .PreparedStatement ;
24- import com . datastax . oss . driver . api . core . cql .ResultSet ;
24+ import java . sql .ResultSet ;
2525import com .datastax .oss .driver .api .core .cql .Row ;
2626//import com.vesoft.nebula.jdbc.impl.NebulaDriver;
2727import com .zaxxer .hikari .HikariDataSource ;
3131import java .net .URL ;
3232import java .nio .file .Paths ;
3333import java .sql .Connection ;
34+ import java .sql .ResultSetMetaData ;
3435import java .sql .SQLException ;
3536import java .util .*;
3637import java .util .concurrent .TimeUnit ;
@@ -82,7 +83,7 @@ public class DemoSQLExecutor extends APIJSONSQLExecutor<Long> {
8283
8384 // 可重写以下方法,支持 Redis 等单机全局缓存或分布式缓存
8485 @ Override
85- public List <JSONObject > getCache (String sql , SQLConfig config ) {
86+ public List <JSONObject > getCache (String sql , SQLConfig < Long > config ) {
8687 List <JSONObject > list = super .getCache (sql , config );
8788 if (list == null ) {
8889 try {
@@ -95,7 +96,7 @@ public List<JSONObject> getCache(String sql, SQLConfig config) {
9596 }
9697
9798 @ Override
98- public synchronized void putCache (String sql , List <JSONObject > list , SQLConfig config ) {
99+ public synchronized void putCache (String sql , List <JSONObject > list , SQLConfig < Long > config ) {
99100 super .putCache (sql , list , config );
100101
101102 String table = config != null && config .isMain () ? config .getTable () : null ;
@@ -113,7 +114,7 @@ public synchronized void putCache(String sql, List<JSONObject> list, SQLConfig c
113114 }
114115
115116 @ Override
116- public synchronized void removeCache (String sql , SQLConfig config ) {
117+ public synchronized void removeCache (String sql , SQLConfig < Long > config ) {
117118 super .removeCache (sql , config );
118119 try {
119120 if (config .getMethod () == RequestMethod .DELETE ) { // 避免缓存击穿
@@ -130,9 +131,9 @@ public synchronized void removeCache(String sql, SQLConfig config) {
130131
131132 public static final String DATABASE_NEBULA = "NEBULA" ;
132133
133- // 适配连接池,如果这里能拿到连接池的有效 Connection,则 SQLConfig 不需要配置 dbVersion, dbUri, dbAccount, dbPassword
134+ // 适配连接池,如果这里能拿到连接池的有效 Connection,则 SQLConfig<Long> 不需要配置 dbVersion, dbUri, dbAccount, dbPassword
134135 @ Override
135- public Connection getConnection (SQLConfig config ) throws Exception {
136+ public Connection getConnection (SQLConfig < Long > config ) throws Exception {
136137// if (DATABASE_NEBULA.equals(config.getDatabase())) { // 3.0.0 及以下要这样连接
137138// String uri = config.getDBUri();
138139//
@@ -200,7 +201,7 @@ public Connection getConnection(SQLConfig config) throws Exception {
200201
201202
202203 @ Override
203- public JSONObject execute (@ NotNull SQLConfig config , boolean unknownType ) throws Exception {
204+ public JSONObject execute (@ NotNull SQLConfig < Long > config , boolean unknownType ) throws Exception {
204205 boolean isCassandra = config .isCassandra ();
205206 boolean isInfluxDB = config .isInfluxDB ();
206207
@@ -245,7 +246,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknownType) throws
245246 // sql = stt.getQuery();
246247 // }
247248
248- ResultSet rs = session .execute (sql );
249+ com . datastax . oss . driver . api . core . cql . ResultSet rs = session .execute (sql );
249250
250251 List <Row > list = rs .all ();
251252 if (list == null || list .isEmpty ()) {
@@ -366,9 +367,16 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknownType) throws
366367
367368 // 不需要隐藏字段这个功能时,取消注释来提升性能
368369 // @Override
369- // protected boolean isHideColumn(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition,
370+ // protected boolean isHideColumn(SQLConfig<Long> config, java.sql. ResultSet rs, ResultSetMetaData rsmd, int tablePosition,
370371 // JSONObject table, int columnIndex, Map<String, JSONObject> childMap) throws SQLException {
371372 // return false;
372373 // }
373374
375+ // 取消注释可将前端传参驼峰命名转为蛇形命名 aBCdEfg => upper ? A_B_CD_EFG : a_b_cd_efg
376+ // @Override
377+ // protected String getKey(SQLConfig<Long> config, java.sql.ResultSet rs, ResultSetMetaData rsmd, int tablePosition, JSONObject table, int columnIndex, Map<String, JSONObject> childMap) throws Exception {
378+ // String key = super.getKey(config, rs, rsmd, tablePosition, table, columnIndex, childMap);
379+ // return JSONResponse.formatUnderline(key, true);
380+ // }
381+
374382}
0 commit comments