SQLParamCleaner 不定条件查询

    @Test
    public void testQuerySQLParamCleaner() {
        // sql 有条件查询
        SQLParamCleaner.FormatParam formatParam =
                SQLParamCleaner.formatSql("select * from mm_incoterm where description = :description OR code like :code ",
                        Map.of("description", "work", "code", "CI")
                );

        List<Incoterm> incotermList = baseService.getTableDAO().select(Incoterm.class, formatParam.formatSql(), formatParam.formatMap());
        print(incotermList);

        System.out.println("-------------------");

        formatParam =
                SQLParamCleaner.formatSql("description = :description AND code like :code",
                        Map.of("description", "work"),
                        true // 如果没有值,条件设置NULL,这里没有给 code 值,formatSql = description = :description AND code IS NULL
                );
        // condition 有条件查询
        incotermList = baseService.select(formatParam.formatSql(), formatParam.formatMap());
        print(incotermList);
    }

    private void print(List<Incoterm> incotermList) {
        for (Incoterm incoterm : incotermList) {
            System.out.println(incoterm.getCode() + ":" + incoterm.getDescription());
        }
    }