From 725930f4c69d392751ad80abe971d5b5d6b5b7e8 Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Sun, 15 Sep 2024 14:11:26 +0800 Subject: [PATCH] Optimize mapper queries Signed-off-by: Zzm0809 <934230207@qq.com> --- dinky-admin/src/main/resources/mapper/AlertGroupMapper.xml | 1 - dinky-admin/src/main/resources/mapper/AlertHistoryMapper.xml | 1 - dinky-admin/src/main/resources/mapper/AlertInstanceMapper.xml | 1 - dinky-admin/src/main/resources/mapper/CatalogueMapper.xml | 2 +- .../src/main/resources/mapper/ClusterConfigurationMapper.xml | 2 +- .../src/main/resources/mapper/ClusterInstanceMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/DataBaseMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/DocumentMapper.xml | 2 +- .../src/main/resources/mapper/FragmentVariableMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/GitProjectMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/JobHistoryMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/JobInstanceMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/MenuMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/OperateLogMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/RoleMapper.xml | 4 ++-- .../src/main/resources/mapper/RoleSelectPermissionsMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/SavepointsMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/SysConfigMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/TaskMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/TaskVersionMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/TenantMapper.xml | 4 +--- dinky-admin/src/main/resources/mapper/TokenMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/UDFTemplateMapper.xml | 2 +- dinky-admin/src/main/resources/mapper/UserMapper.xml | 4 ++-- dinky-admin/src/main/resources/mapper/UserRoleMapper.xml | 2 +- 25 files changed, 24 insertions(+), 29 deletions(-) diff --git a/dinky-admin/src/main/resources/mapper/AlertGroupMapper.xml b/dinky-admin/src/main/resources/mapper/AlertGroupMapper.xml index a91ab0a448..2fb6087e46 100644 --- a/dinky-admin/src/main/resources/mapper/AlertGroupMapper.xml +++ b/dinky-admin/src/main/resources/mapper/AlertGroupMapper.xml @@ -8,7 +8,6 @@ from dinky_alert_group a - 1=1 and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/AlertHistoryMapper.xml b/dinky-admin/src/main/resources/mapper/AlertHistoryMapper.xml index cedc62a03a..1c9428bc71 100644 --- a/dinky-admin/src/main/resources/mapper/AlertHistoryMapper.xml +++ b/dinky-admin/src/main/resources/mapper/AlertHistoryMapper.xml @@ -8,7 +8,6 @@ from dinky_alert_history a - 1=1 and a.job_instance_id = #{param.jobInstanceId} diff --git a/dinky-admin/src/main/resources/mapper/AlertInstanceMapper.xml b/dinky-admin/src/main/resources/mapper/AlertInstanceMapper.xml index 8c8beac2e6..07abbd05e3 100644 --- a/dinky-admin/src/main/resources/mapper/AlertInstanceMapper.xml +++ b/dinky-admin/src/main/resources/mapper/AlertInstanceMapper.xml @@ -8,7 +8,6 @@ from dinky_alert_instance a - 1=1 and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/CatalogueMapper.xml b/dinky-admin/src/main/resources/mapper/CatalogueMapper.xml index 7d1235e4e3..3b1bf2be51 100644 --- a/dinky-admin/src/main/resources/mapper/CatalogueMapper.xml +++ b/dinky-admin/src/main/resources/mapper/CatalogueMapper.xml @@ -26,7 +26,7 @@ from dinky_catalogue a - 1=1 + and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/ClusterConfigurationMapper.xml b/dinky-admin/src/main/resources/mapper/ClusterConfigurationMapper.xml index 9201b9f600..c0260be076 100644 --- a/dinky-admin/src/main/resources/mapper/ClusterConfigurationMapper.xml +++ b/dinky-admin/src/main/resources/mapper/ClusterConfigurationMapper.xml @@ -27,7 +27,7 @@ from dinky_cluster_configuration a - 1=1 + and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/ClusterInstanceMapper.xml b/dinky-admin/src/main/resources/mapper/ClusterInstanceMapper.xml index d4ab493196..98acad0561 100644 --- a/dinky-admin/src/main/resources/mapper/ClusterInstanceMapper.xml +++ b/dinky-admin/src/main/resources/mapper/ClusterInstanceMapper.xml @@ -33,7 +33,7 @@ from dinky_cluster a - 1=1 + and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/DataBaseMapper.xml b/dinky-admin/src/main/resources/mapper/DataBaseMapper.xml index 2da2b8b39b..2786697240 100644 --- a/dinky-admin/src/main/resources/mapper/DataBaseMapper.xml +++ b/dinky-admin/src/main/resources/mapper/DataBaseMapper.xml @@ -8,7 +8,7 @@ from dinky_database a - 1=1 + and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/DocumentMapper.xml b/dinky-admin/src/main/resources/mapper/DocumentMapper.xml index 604c8fe14e..90e262d8aa 100644 --- a/dinky-admin/src/main/resources/mapper/DocumentMapper.xml +++ b/dinky-admin/src/main/resources/mapper/DocumentMapper.xml @@ -30,7 +30,7 @@ from dinky_flink_document a - 1=1 + and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/FragmentVariableMapper.xml b/dinky-admin/src/main/resources/mapper/FragmentVariableMapper.xml index faa8f46ee9..12f626c9c0 100644 --- a/dinky-admin/src/main/resources/mapper/FragmentVariableMapper.xml +++ b/dinky-admin/src/main/resources/mapper/FragmentVariableMapper.xml @@ -27,7 +27,7 @@ from dinky_fragment a - 1=1 + and a.id = #{param.id} diff --git a/dinky-admin/src/main/resources/mapper/GitProjectMapper.xml b/dinky-admin/src/main/resources/mapper/GitProjectMapper.xml index df66b3fac3..53eba0e37d 100644 --- a/dinky-admin/src/main/resources/mapper/GitProjectMapper.xml +++ b/dinky-admin/src/main/resources/mapper/GitProjectMapper.xml @@ -8,7 +8,7 @@ from dinky_git_project a - 1=1 + and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/JobHistoryMapper.xml b/dinky-admin/src/main/resources/mapper/JobHistoryMapper.xml index 2ad1c75dc1..be39ad2c14 100644 --- a/dinky-admin/src/main/resources/mapper/JobHistoryMapper.xml +++ b/dinky-admin/src/main/resources/mapper/JobHistoryMapper.xml @@ -15,7 +15,7 @@ from dinky_job_history a - 1=1 + and a.id = #{param.id} diff --git a/dinky-admin/src/main/resources/mapper/JobInstanceMapper.xml b/dinky-admin/src/main/resources/mapper/JobInstanceMapper.xml index 1d6144e803..b0934b8502 100644 --- a/dinky-admin/src/main/resources/mapper/JobInstanceMapper.xml +++ b/dinky-admin/src/main/resources/mapper/JobInstanceMapper.xml @@ -27,7 +27,7 @@ left join dinky_history dh on a.history_id = dh.id left join dinky_task dt on a.task_id = dt.id - 1=1 + and a.status = #{param.status} diff --git a/dinky-admin/src/main/resources/mapper/MenuMapper.xml b/dinky-admin/src/main/resources/mapper/MenuMapper.xml index c2095f3de8..f8c65c1365 100644 --- a/dinky-admin/src/main/resources/mapper/MenuMapper.xml +++ b/dinky-admin/src/main/resources/mapper/MenuMapper.xml @@ -130,7 +130,7 @@ from dinky_sys_menu a - 1=1 + and a.path like concat('%', #{param.path}, '%') diff --git a/dinky-admin/src/main/resources/mapper/OperateLogMapper.xml b/dinky-admin/src/main/resources/mapper/OperateLogMapper.xml index 49b6fe68f9..ad131b4d6f 100644 --- a/dinky-admin/src/main/resources/mapper/OperateLogMapper.xml +++ b/dinky-admin/src/main/resources/mapper/OperateLogMapper.xml @@ -8,7 +8,7 @@ from dinky_sys_operate_log a - 1=1 + and a.operate_user_id = #{param.userId} diff --git a/dinky-admin/src/main/resources/mapper/RoleMapper.xml b/dinky-admin/src/main/resources/mapper/RoleMapper.xml index 6f292bcfeb..9b7698c05e 100644 --- a/dinky-admin/src/main/resources/mapper/RoleMapper.xml +++ b/dinky-admin/src/main/resources/mapper/RoleMapper.xml @@ -29,7 +29,7 @@ a.* from dinky_role a - 1=1 + and tenant_id = #{param.tenantId} @@ -81,7 +81,7 @@ ,update_time from dinky_role - 1=1 + and tenant_id = #{tenantId} diff --git a/dinky-admin/src/main/resources/mapper/RoleSelectPermissionsMapper.xml b/dinky-admin/src/main/resources/mapper/RoleSelectPermissionsMapper.xml index cb8e152eca..036272565e 100644 --- a/dinky-admin/src/main/resources/mapper/RoleSelectPermissionsMapper.xml +++ b/dinky-admin/src/main/resources/mapper/RoleSelectPermissionsMapper.xml @@ -10,7 +10,7 @@ dinky_row_permissions a join dinky_role b on b.id = a.role_id - 1=1 + and b.role_code like concat('%',#{param.roleCode},'%') diff --git a/dinky-admin/src/main/resources/mapper/SavepointsMapper.xml b/dinky-admin/src/main/resources/mapper/SavepointsMapper.xml index 9a42cd472b..e9180be14e 100644 --- a/dinky-admin/src/main/resources/mapper/SavepointsMapper.xml +++ b/dinky-admin/src/main/resources/mapper/SavepointsMapper.xml @@ -8,7 +8,7 @@ from dinky_savepoints a - 1=1 + and a.task_id = #{param.taskId} diff --git a/dinky-admin/src/main/resources/mapper/SysConfigMapper.xml b/dinky-admin/src/main/resources/mapper/SysConfigMapper.xml index 165d718e29..2ee5110a68 100644 --- a/dinky-admin/src/main/resources/mapper/SysConfigMapper.xml +++ b/dinky-admin/src/main/resources/mapper/SysConfigMapper.xml @@ -8,7 +8,7 @@ from dinky_sys_config a - 1=1 + and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/TaskMapper.xml b/dinky-admin/src/main/resources/mapper/TaskMapper.xml index 4f1f731d7e..261258da20 100644 --- a/dinky-admin/src/main/resources/mapper/TaskMapper.xml +++ b/dinky-admin/src/main/resources/mapper/TaskMapper.xml @@ -26,7 +26,7 @@ from dinky_task a - 1=1 + and a.name like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/TaskVersionMapper.xml b/dinky-admin/src/main/resources/mapper/TaskVersionMapper.xml index c8075cd54a..73cc853fac 100644 --- a/dinky-admin/src/main/resources/mapper/TaskVersionMapper.xml +++ b/dinky-admin/src/main/resources/mapper/TaskVersionMapper.xml @@ -10,7 +10,7 @@ from dinky_task_version a - 1=1 + and a.version_id = #{param.versionId} diff --git a/dinky-admin/src/main/resources/mapper/TenantMapper.xml b/dinky-admin/src/main/resources/mapper/TenantMapper.xml index 5ea158c7fa..dc9f0432fb 100644 --- a/dinky-admin/src/main/resources/mapper/TenantMapper.xml +++ b/dinky-admin/src/main/resources/mapper/TenantMapper.xml @@ -10,7 +10,6 @@ from dinky_tenant a - 1=1 and tenant_code like concat('%',#{param.tenantCode},'%') @@ -36,8 +35,7 @@ ,create_time ,update_time from dinky_tenant a - where 1=1 - and id in + where id in #{id} diff --git a/dinky-admin/src/main/resources/mapper/TokenMapper.xml b/dinky-admin/src/main/resources/mapper/TokenMapper.xml index 4eedfee080..5ff2042b7e 100644 --- a/dinky-admin/src/main/resources/mapper/TokenMapper.xml +++ b/dinky-admin/src/main/resources/mapper/TokenMapper.xml @@ -14,7 +14,7 @@ join dinky_role c on a.role_id = c.id join dinky_tenant d on a.tenant_id = d.id - 1=1 + and a.token_value like concat('%',#{param.tokenValue},'%') diff --git a/dinky-admin/src/main/resources/mapper/UDFTemplateMapper.xml b/dinky-admin/src/main/resources/mapper/UDFTemplateMapper.xml index 499e57339d..35c79951cc 100644 --- a/dinky-admin/src/main/resources/mapper/UDFTemplateMapper.xml +++ b/dinky-admin/src/main/resources/mapper/UDFTemplateMapper.xml @@ -25,7 +25,7 @@ from dinky_udf_template a - 1=1 + and `name` like concat('%',#{param.name},'%') diff --git a/dinky-admin/src/main/resources/mapper/UserMapper.xml b/dinky-admin/src/main/resources/mapper/UserMapper.xml index c2ad372028..0efe9ccd03 100644 --- a/dinky-admin/src/main/resources/mapper/UserMapper.xml +++ b/dinky-admin/src/main/resources/mapper/UserMapper.xml @@ -8,7 +8,7 @@ from dinky_user a - 1=1 + and a.username like concat('%',#{param.username},'%') @@ -40,7 +40,7 @@ join dinky_user du on a.user_id = du.id join dinky_tenant c on a.tenant_id = c.id - 1=1 and du.tenant_admin_flag = 1 + du.tenant_admin_flag = 1 and a.tenant_id = #{tenantId} diff --git a/dinky-admin/src/main/resources/mapper/UserRoleMapper.xml b/dinky-admin/src/main/resources/mapper/UserRoleMapper.xml index 96deed312f..94eb50e2af 100644 --- a/dinky-admin/src/main/resources/mapper/UserRoleMapper.xml +++ b/dinky-admin/src/main/resources/mapper/UserRoleMapper.xml @@ -10,7 +10,7 @@ from dinky_user_role - 1=1 + and user_id = #{param.userId}