|
@@ -58,32 +58,38 @@ class UnidiaApplicationTests {
|
|
|
|
|
|
@Test
|
|
|
void testQuery(){
|
|
|
- HashMap<String, Object> p1 = new HashMap<>();
|
|
|
- p1.put("column","user_status");
|
|
|
- p1.put("comparison","=");
|
|
|
- p1.put("value","1");
|
|
|
- p1.put("connection","OR");
|
|
|
- p1.put("right","");
|
|
|
- HashMap<String, Object> p2 = new HashMap<>();
|
|
|
- p2.put("column","token_valid_duration");
|
|
|
- p2.put("comparison",">");
|
|
|
- p2.put("value","4000");
|
|
|
- p2.put("connection","AND");
|
|
|
- p2.put("left","(");
|
|
|
- HashMap<String, Object> p3 = new HashMap<>();
|
|
|
- p3.put("column","token_valid_duration");
|
|
|
- p3.put("comparison","<");
|
|
|
- p3.put("value","10000");
|
|
|
- p3.put("connection","AND"); // 连接符必须是大写
|
|
|
- p3.put("right",")");
|
|
|
- List<HashMap<String, Object>> maps = Arrays.asList(p1, p2, p3);
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("dataContent",Map.of("conditions",maps));
|
|
|
+ map.put("dataContent",Arrays.asList(
|
|
|
+ Map.of("conditions",Map.of("carrierFlights","CA123","carrierFlightsDate","2023-05-01","luggageNum","BAG001")),
|
|
|
+ Map.of("conditions",Map.of("carrierFlights","CA123","carrierFlightsDate","2023-05-01","luggageNum","BAG001"))
|
|
|
+
|
|
|
+ )
|
|
|
+ );
|
|
|
map.put("event","SELECT");
|
|
|
- map.put("page",2);
|
|
|
- map.put("pageSize",3);
|
|
|
- Result<List<Map<String, Object>>> res = dbExecutor.search(systemEnvCache.getDbInfo(), "t_user", map);
|
|
|
- List<Map<String, Object>> list = res.getData();
|
|
|
+// map.put("page",2);
|
|
|
+// map.put("pageSize",3);
|
|
|
+ Result<List<Map<String, Object>>> result = dbExecutor.find(
|
|
|
+ systemEnvCache.getDbInfo(),
|
|
|
+ "baggage_tracking",
|
|
|
+ map,
|
|
|
+ (rs) -> {
|
|
|
+ // 可自定义结果映射逻辑,这里使用默认 Map 映射
|
|
|
+ Map<String, Object> row = new HashMap<>();
|
|
|
+ try {
|
|
|
+ for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
|
|
+ row.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return row;
|
|
|
+ },
|
|
|
+ true // 是否启用缓存,根据实际需求调整
|
|
|
+ );
|
|
|
+ System.out.println(result.getError());
|
|
|
+ List<Map<String, Object>> list = result.getData();
|
|
|
+ System.out.println(list);
|
|
|
+ System.out.println("\n-----------------------------------");
|
|
|
System.out.println(JSONObject.wrap(map).toString());
|
|
|
|
|
|
}
|
|
@@ -97,15 +103,48 @@ class UnidiaApplicationTests {
|
|
|
@Test
|
|
|
void sqlQuery(){
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("dataContent",Map.of("conditions",Arrays.asList("$2a222","222","111")));
|
|
|
+ map.put("dataContent",Arrays.asList(
|
|
|
+ Map.of("conditions",Arrays.asList("$2a222","222","111")),
|
|
|
+ Map.of("conditions",Arrays.asList("$2a222","222","111"))
|
|
|
+ ));
|
|
|
map.put("event","SELECT");
|
|
|
String sql = "select * from t_user where user_pwd = ? and user_token = ? and token_valid_time=?";
|
|
|
- Result<List<Map<String, Object>>> res = dbExecutor.searchBySql(systemEnvCache.getDbInfo(), map,sql);
|
|
|
+ map.put("sql",sql);
|
|
|
+ Result<List<Map<String, Object>>> res = dbExecutor.searchBySql(systemEnvCache.getDbInfo(), map);
|
|
|
List<Map<String, Object>> list = res.getData();
|
|
|
+ System.out.println(JSONObject.wrap(list).toString());
|
|
|
System.out.println(JSONObject.wrap(map).toString());
|
|
|
// user_pwd user_token token_valid_time
|
|
|
// $2a222 222 111
|
|
|
}
|
|
|
+
|
|
|
+ public static List<Object> getList(){
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ list.add(getOneMap());
|
|
|
+// list.add(getTwoMap());
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String,Object> getOneMap(){
|
|
|
+ HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("conditions",Arrays.asList(
|
|
|
+ Map.of("carrierFlights","CA123","carrierFlightsDate","2023-05-01","luggageNum","BAG001"),
|
|
|
+ Map.of("carrierFlights","CA123","carrierFlightsDate","2023-05-01","luggageNum","BAG001")));
|
|
|
+ return hashMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String,Object> getTwoMap(){
|
|
|
+ HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("conditions",Map.of("user_pwd","$2a$10$xJ4Q2Lk9Xz1ZQ7Ew","user_token","eyJhbGciOiJIUzI1NiIs...","token_valid_time","1704067199000"));
|
|
|
+ return hashMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 获取解密参数和加密密码
|
|
|
@Test
|
|
|
void getPwd(){
|
|
@@ -121,3 +160,4 @@ class UnidiaApplicationTests {
|
|
|
// driverName=com.mysql.cj.jdbc.Driver
|
|
|
// url=jdbc:mysql://127.0.0.1:3306/unidia206?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf8
|
|
|
// username=db_admin
|
|
|
+//{"dataContent":{"conditions":["$2a222","222","111"]},"event":"SELECT"}
|