import cn.stylefeng.team.meta.db.pojo.query.FilterItem;
import cn.stylefeng.team.meta.db.pojo.query.Group;
import cn.stylefeng.team.meta.db.querybuilder.QueryConditionBuilder;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

import java.util.Arrays;

public class Demo {
    public static void main(String[] args) {


        Group sex = new Group(Arrays.asList(new FilterItem("sex", "LIKE", "%3%", "and", null, null),
                new FilterItem("age", "LIKE", "3", "and", null, null)));


        Group real_name = new Group(Arrays.asList(new FilterItem("real_name", "LIKE", "%3%", "and", sex, "and"),
                new FilterItem("abcd", "LIKE", "%3%", "and", sex, "OR")));

        System.out.println(JSON.toJSONString(real_name, SerializerFeature.PrettyFormat));
        System.out.println(new QueryConditionBuilder().build(real_name));
        System.out.println();

        Group total = new Group(
                Arrays.asList(
                        new FilterItem("password", "LIKE", "%1%", "and", null, null),
                        new FilterItem("password_salt", "LIKE", "%2%", "and", real_name, "and")
                )
        );

        System.out.println(JSON.toJSONString(total, SerializerFeature.PrettyFormat));
        System.out.println(new QueryConditionBuilder().build(total));
        System.out.println();
    }

}