TestDbExecutePrintSql.java 2.12 KB
import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.dao.impl.SqlData;
import com.yanzuoguang.dao.impl.TableSqlCache;
import com.yanzuoguang.dao.impl.TableStruct;
import com.yanzuoguang.db.impl.DbPrintSqlDefault;
import com.yanzuoguang.util.helper.JsonHelper;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class TestDbExecutePrintSql {
    @Test
    public void test() {
        DbPrintSqlDefault printSql = new DbPrintSqlDefault();
        String stringSql = printSql.getStringSql("select * from where id = ? AND name = ? and removeFlag = 0 ", "1");
        System.out.println(stringSql);
    }

    @Test
    public void testTableStruct() {
        TableSqlCache cache = new TableSqlCache();

        TableStruct table = new TableStruct("test", TestTableGroupVo.class);
        table.init(cache);

        SqlData sqlData = cache.getNameCache().get(DaoConst.GROUP_ADD);
        System.out.println(JsonHelper.serialize(sqlData, true));
    }

    @Test
    public void testTableStruct1() {
        TableSqlCache cache = new TableSqlCache();

        TableStruct table = new TableStruct("test", TestTableGroupVo1.class);
        table.init(cache);

        SqlData sqlData = cache.getNameCache().get(DaoConst.GROUP_ADD);
        System.out.println(JsonHelper.serialize(sqlData, true));
    }

    @Test
    public void testTable() {
        TableSqlCache cache = new TableSqlCache();

        TableStruct table = new TableStruct("test", TestTableGroupVo.class);
        table.init(cache);

        System.out.println(JsonHelper.serialize(cache.getNameCache(), true));
    }


    @Test
    public void testTableStructSort() {
        TableSqlCache cache = new TableSqlCache();

        TableStruct table = new TableStruct("test", TestTableGroupVo.class);
        table.init(cache);

        List<TestTableGroupVo> list = new ArrayList<>();
        list.add(new TestTableGroupVo("2"));
        list.add(new TestTableGroupVo("1"));
        list.add(new TestTableGroupVo("3"));

        List listTo = cache.getKeySort(list);
        String json = JsonHelper.serialize(listTo, true);

        System.out.println(json);
    }
}