多表关联关系

最后更新:2024-09-12 21:50:18 | 状态:未完成
{
    "table": "FI_USER",                         //主表
    "alias": "FI",                              /别名
    "distinct": "distinct",                     //去重
    "joins": [                                  //关联表S
        {
            "table": "HR_USER",           //关联表名
            "alias": "HR",                //关联表别名
            "type": "LEFT",               //关联方式
            "conditions": {               //关联条件 这里是逆向生成的所以属性比较复杂(完整)具体参考 ConfigStore<>JSON互换
                "join": "AND",
                "items": [
                    {
                        "join": "AND",
                        "text": "FI.ID = HR.ID",
                        "compare": 10,
                        "over_condition": false,
                        "over_value": true,
                        "parser": {
                            "compare": 10,
                            "join": "AND",
                            "swt": "NONE"
                        }
                    }
                ]
            }
        }
    ],
    "columns": [                              //需要查询的列 默认*
        "FI.ID AS FI_ID",
        "HR.ID AS HR_ID"
    ]
}
因为上面的conditions是逆向生成的所以与查询条件的属性一样,比较复杂,可以简化成成:
{"conditions":"HR.ID = FI.HR_ID"}
或
{"conditions":"HR.ID = FI.HR_ID AND HR.CODE = FI.HR_CODE"}
或
{"conditions":["HR.ID = FI.HR_ID","HR.CODE = FI.HR_CODE"]}

后台后收JSON后
service.querys(TableBuilder.build(json), 查询条件...);
查询参数与其他查询一样,参考【查询条件】conditions部分的完整格式参考【ConfigStore与json相互转换
与之等效的Java实现
TableBuilder builder = TableBuilder.init("FI_USER AS FI")
	.left("HR_USER AS HR", "FI.ID = HR.ID")
	.columns("FI.ID AS FI_ID", "HR.ID AS HR_ID").distinct(true);
RunPrepare prepare = builder.build();
ServiceProxy.querys(prepare);

TableBuilder与JSON互换
String json = builder.json();

首页 最近更新 搜索 提交 回复