复杂条件的合成

最后更新:2023-11-15 05:30:22 | 状态:未完成
        ConfigStore a1 = new DefaultConfigStore().and(  "id11", 11).and("id12", 12);
        ConfigStore a2 = new DefaultConfigStore().and(  "id21", 21).and("id22", 22);
        ConfigStore a3 = new DefaultConfigStore().and(  "id31", 31).and("id32", 32);
        ConfigStore a = new DefaultConfigStore();
        //a.integrality(false); //删除最外层的()
        //以下两行作用是一样的
        //最外层加一个a,a1,a2,a3都作为一个整体加入a
        service.querys("crm_user", a.and(a1, false).or(a2, false).or(a3, false));

        //因为a1中有11,12 在a2加入时需要把11,12合并成一个,不让a2与11,12平级
        service.querys("crm_user", a1.or(a2, true).or(a3, false));
生成SQL
SELECT 
	*
FROM
	crm_user
WHERE (id11 = ?  AND  id12 = ?)
 OR (id21 = ?  AND  id22 = ?)
 OR (id31 = ?  AND  id32 = ?)

apart是指合并条件时,新条件是否插入到原条件的那个list中

 integrality是指生成完了SQL后 是否需要在最外层加()

最近更新 搜索 提交