|
20 | 20 |
|
21 | 21 | import apijson.RequestMethod; |
22 | 22 | import apijson.orm.Join; |
23 | | -import apijson.orm.Join.On; |
24 | 23 | import apijson.orm.SQLConfig; |
| 24 | +import com.alibaba.fastjson.JSONArray; |
| 25 | +import com.alibaba.fastjson.JSONObject; |
25 | 26 |
|
26 | 27 |
|
27 | 28 | /**SQL配置 |
|
30 | 31 | * https://github.com/Tencent/APIJSON/blob/master/%E8%AF%A6%E7%BB%86%E7%9A%84%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3.md#c-1-1%E4%BF%AE%E6%94%B9%E6%95%B0%E6%8D%AE%E5%BA%93%E9%93%BE%E6%8E%A5 |
31 | 32 | * @author Lemon |
32 | 33 | */ |
33 | | -public class DemoSQLConfig extends AbstractSQLConfig<Long> { |
| 34 | +public class DemoSQLConfig extends AbstractSQLConfig<Long, JSONObject, JSONArray> { |
34 | 35 |
|
35 | 36 | public DemoSQLConfig() { |
36 | 37 | super(RequestMethod.GET); |
@@ -60,59 +61,55 @@ public DemoSQLConfig(RequestMethod method, String table) { |
60 | 61 |
|
61 | 62 |
|
62 | 63 | @Override |
63 | | - public String getDBVersion() { |
| 64 | + public String gainDBVersion() { |
64 | 65 | return "8.0.11"; //TODO 改成你自己的 MySQL 或 PostgreSQL 数据库版本号 //MYSQL 8 和 7 使用的 JDBC 配置不一样 |
65 | 66 | } |
66 | 67 | @Override |
67 | | - public String getDBUri() { |
| 68 | + public String gainDBUri() { |
68 | 69 | // 这个是 MySQL 8.0 及以上,要加 userSSL=false |
69 | 70 | return "jdbc:mysql://localhost:3306?userSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8"; |
70 | 71 | // 以下是 MySQL 5.7 及以下 |
71 | 72 | // return "jdbc:mysql://localhost:3306?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8"; //TODO 改成你自己的,TiDB 可以当成 MySQL 使用,默认端口为 4000 |
72 | 73 | } |
73 | 74 | @Override |
74 | | - public String getDBAccount() { |
| 75 | + public String gainDBAccount() { |
75 | 76 | return "root"; //TODO 改成你自己的 |
76 | 77 | } |
77 | 78 | @Override |
78 | | - public String getDBPassword() { |
| 79 | + public String gainDBPassword() { |
79 | 80 | return "apijson"; //TODO 改成你自己的,TiDB 可以当成 MySQL 使用, 默认密码为空字符串 "" |
80 | 81 | } |
81 | 82 |
|
82 | | - public static SQLConfig newSQLConfig(RequestMethod method, String table, String alias, com.alibaba.fastjson.JSONObject request, List<Join> joinList, boolean isProcedure) throws Exception { |
83 | | - return AbstractSQLConfig.newSQLConfig(method, table, alias, request, joinList, isProcedure, new SimpleCallback<Object>() { |
| 83 | + public static SQLConfig<Long, JSONObject, JSONArray> newSQLConfig(RequestMethod method, String table, String alias, com.alibaba.fastjson.JSONObject request, List<Join<Long, JSONObject, JSONArray>> joinList, boolean isProcedure) throws Exception { |
| 84 | + return AbstractSQLConfig.newSQLConfig(method, table, alias, request, joinList, isProcedure, new SimpleCallback<Long, JSONObject, JSONArray>() { |
84 | 85 | @Override |
85 | | - public SQLConfig getSQLConfig(RequestMethod method, String database, String schema, String datasource, String table) { |
| 86 | + public SQLConfig<Long, JSONObject, JSONArray> getSQLConfig(RequestMethod method, String database, String schema, String datasource, String table) { |
86 | 87 | return new DemoSQLConfig(method, table); |
87 | 88 | } |
88 | 89 | }); |
89 | 90 | } |
90 | 91 |
|
91 | | - |
92 | | - |
93 | | - @Override |
94 | | - public boolean isFakeDelete() { |
95 | | - return false; |
96 | | - } |
97 | | - |
98 | | - @Override |
99 | | - public Map<String, Object> onFakeDelete(Map map) { |
100 | | - return super.onFakeDelete(map); |
101 | | - } |
102 | | - |
103 | | - @Override |
104 | | - protected void onGetCrossJoinString(Join j) throws UnsupportedOperationException { |
105 | | - // 开启 CROSS JOIN 笛卡尔积联表 super.onGetCrossJoinString(j); |
106 | | - } |
107 | | - @Override |
108 | | - protected void onJoinNotRelation(String sql, String quote, Join j, String jt, List<On> onList, On on) { |
109 | | - // 开启 JOIN ON t1.c1 != t2.c2 等不等式关联 super.onJoinNotRelation(sql, quote, j, jt, onList, on); |
110 | | - } |
111 | | - @Override |
112 | | - protected void onJoinComplexRelation(String sql, String quote, Join j, String jt, List<On> onList, On on) { |
113 | | - // 开启 JOIN ON t1.c1 LIKE concat('%', t2.c2, '%') 等复杂关联 super.onJoinComplextRelation(sql, quote, j, jt, onList, on); |
114 | | - } |
115 | | - |
116 | | - |
| 92 | + // @Override |
| 93 | + // public boolean isFakeDelete() { |
| 94 | + // return false; |
| 95 | + // } |
| 96 | + // |
| 97 | + // @Override |
| 98 | + // public Map<String, Object> onFakeDelete(Map<String, Object> map) { |
| 99 | + // return super.onFakeDelete(map); |
| 100 | + // } |
| 101 | + |
| 102 | + // @Override |
| 103 | + // protected void onGainCrossJoinString(Join<Long, JSONObject, JSONArray> j) throws UnsupportedOperationException { |
| 104 | + // // 开启 CROSS JOIN 笛卡尔积联表 super.onGetCrossJoinString(j); |
| 105 | + // } |
| 106 | + // @Override |
| 107 | + // protected void onJoinNotRelation(String sql, String quote, Join<Long, JSONObject, JSONArray> j, String jt, List<On> onList, On on) { |
| 108 | + // // 开启 JOIN ON t1.c1 != t2.c2 等不等式关联 super.onJoinNotRelation(sql, quote, j, jt, onList, on); |
| 109 | + // } |
| 110 | + // @Override |
| 111 | + // protected void onJoinComplexRelation(String sql, String quote, Join<Long, JSONObject, JSONArray> j, String jt, List<On> onList, On on) { |
| 112 | + // // 开启 JOIN ON t1.c1 LIKE concat('%', t2.c2, '%') 等复杂关联 super.onJoinComplexRelation(sql, quote, j, jt, onList, on); |
| 113 | + // } |
117 | 114 |
|
118 | 115 | } |
0 commit comments