1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| public void testAllEq(){ Map<String,Object> params = new HashMap<>(); params.put("name", "李四"); params.put("age", "20"); params.put("password", null); QueryWrapper<User> wrapper = new QueryWrapper<>(); //SELECT id,user_name,name,age,email AS mail FROM tb_user WHERE password IS NULL AND name = ? AND age = ? //wrapper.allEq(params); //SELECT id,user_name,name,age,email AS mail FROM tb_user WHERE name = ? AND age = ? //wrapper.allEq(params, false); //SELECT id,user_name,name,age,email AS mail FROM tb_user WHERE age = ? //wrapper.allEq((k, v) -> (k.equals("age") || k.equals("id")) , params); //SELECT id,user_name,name,age,email AS mail FROM tb_user WHERE name = ? AND age = ? wrapper.allEq((k, v) -> (k.equals("age") || k.equals("id") || k.equals("name")) , params); List<User> users = this.userMapper.selectList(wrapper); for (User user : users) { System.out.println(user); } }
|