Browse Source

[Improvement-3933][db operation] Improve the performance of sql query (#3940)

* optimize select * case

* emove redundancy

* bug fixed

* Update en_US.js

* Update startup.sh

* optimize

* optimize code

* optimize

* bug fixed

* add ut

* bug fixed

* bug fixed

* bug fixed

* bug fixed

* Delete WorkFlowLineageMapper.xml

* Delete createTenement.vue

* recove wrongly deleted file

* Update WorkFlowLineageMapper.xml

* Update createTenement.vue
pull/3/MERGE
Yarlung 4 years ago committed by GitHub
parent
commit
bd156b312d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      docker/build/Dockerfile
  2. 6
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/WorkFlowLineageMapper.java
  3. 3
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapper.xml
  4. 21
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml
  5. 7
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertMapper.xml
  6. 9
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml
  7. 30
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/DataSourceMapper.xml
  8. 1
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapper.xml
  9. 34
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml
  10. 17
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionVersionMapper.xml
  11. 10
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapper.xml
  12. 56
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml
  13. 46
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml
  14. 6
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.xml
  15. 9
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/QueueMapper.xml
  16. 39
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.xml
  17. 25
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.xml
  18. 9
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/SessionMapper.xml
  19. 31
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml
  20. 22
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TenantMapper.xml
  21. 44
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapper.xml
  22. 9
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapper.xml
  23. 49
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserMapper.xml
  24. 95
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java
  25. 6
      dolphinscheduler-ui/src/js/conf/home/pages/security/pages/tenement/_source/createTenement.vue

2
docker/build/Dockerfile

@ -42,7 +42,7 @@ ADD ./apache-dolphinscheduler-incubating-${VERSION}-dolphinscheduler-bin.tar.gz
RUN mv /opt/apache-dolphinscheduler-incubating-${VERSION}-dolphinscheduler-bin/ /opt/dolphinscheduler/ RUN mv /opt/apache-dolphinscheduler-incubating-${VERSION}-dolphinscheduler-bin/ /opt/dolphinscheduler/
ENV DOLPHINSCHEDULER_HOME /opt/dolphinscheduler ENV DOLPHINSCHEDULER_HOME /opt/dolphinscheduler
#4. install database, if use mysql as your backend database, you should append `mysql-client` at the end of the sentence #4. install database, if use mysql as your backend database, the `mysql-client` package should be installed
RUN apk add --update --no-cache postgresql postgresql-contrib RUN apk add --update --no-cache postgresql postgresql-contrib
#5. modify nginx #5. modify nginx

6
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/WorkFlowLineageMapper.java

@ -24,9 +24,9 @@ import java.util.Set;
public interface WorkFlowLineageMapper { public interface WorkFlowLineageMapper {
public List<WorkFlowLineage> queryByName(@Param("searchVal") String searchVal, @Param("projectId") int projectId); List<WorkFlowLineage> queryByName(@Param("searchVal") String searchVal, @Param("projectId") int projectId);
public List<WorkFlowLineage> queryByIds(@Param("ids") Set<Integer> ids, @Param("projectId") int projectId); List<WorkFlowLineage> queryByIds(@Param("ids") Set<Integer> ids, @Param("projectId") int projectId);
public List<WorkFlowRelation> querySourceTarget(@Param("id") int id); List<WorkFlowRelation> querySourceTarget(@Param("id") int id);
} }

3
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapper.xml

@ -19,7 +19,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper">
<select id="selectAccessTokenPage" resultType="org.apache.dolphinscheduler.dao.entity.AccessToken"> <select id="selectAccessTokenPage" resultType="org.apache.dolphinscheduler.dao.entity.AccessToken">
select * from t_ds_access_token t select t.id, t.user_id, t.token, t.expire_time, t.create_time, t.update_time
from t_ds_access_token t
left join t_ds_user u on t.user_id = u.id left join t_ds_user u on t.user_id = u.id
where 1 = 1 where 1 = 1
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">

21
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml

@ -18,8 +18,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper">
<sql id="baseSql">
id, group_name, group_type, description, create_time, update_time
</sql>
<select id="queryAlertGroupPage" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup"> <select id="queryAlertGroupPage" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select * from t_ds_alertgroup select
<include refid="baseSql"/>
from t_ds_alertgroup
where 1 = 1 where 1 = 1
<if test="groupName != null and groupName != ''"> <if test="groupName != null and groupName != ''">
and group_name like concat('%', #{groupName}, '%') and group_name like concat('%', #{groupName}, '%')
@ -27,20 +32,26 @@
order by update_time desc order by update_time desc
</select> </select>
<select id="queryByGroupName" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup"> <select id="queryByGroupName" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select * from t_ds_alertgroup select
<include refid="baseSql"/>
from t_ds_alertgroup
where group_name=#{groupName} where group_name=#{groupName}
</select> </select>
<select id="queryByUserId" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup"> <select id="queryByUserId" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select * from t_ds_alertgroup t select t.id, t.group_name, t.group_type, t.description, t.create_time, t.update_time
from t_ds_alertgroup t
left join t_ds_relation_user_alertgroup r on t.id=r.alertgroup_id left join t_ds_relation_user_alertgroup r on t.id=r.alertgroup_id
where r.user_id=#{userId} where r.user_id=#{userId}
</select> </select>
<select id="queryByAlertType" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup"> <select id="queryByAlertType" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select * from t_ds_alertgroup select
<include refid="baseSql"/>
from t_ds_alertgroup
where group_type=#{alertType} where group_type=#{alertType}
</select> </select>
<select id="queryAllGroupList" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup"> <select id="queryAllGroupList" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select * select
<include refid="baseSql"/>
from t_ds_alertgroup from t_ds_alertgroup
order by update_time desc order by update_time desc
</select> </select>

7
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertMapper.xml

@ -18,8 +18,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.AlertMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.AlertMapper">
<sql id="baseSql">
id, title, show_type, content, alert_type, alert_status, log,
alertgroup_id, receivers, receivers_cc, create_time, update_time
</sql>
<select id="listAlertByStatus" resultType="org.apache.dolphinscheduler.dao.entity.Alert"> <select id="listAlertByStatus" resultType="org.apache.dolphinscheduler.dao.entity.Alert">
select * select
<include refid="baseSql"/>
from t_ds_alert from t_ds_alert
where alert_status = #{alertStatus} where alert_status = #{alertStatus}
</select> </select>

9
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml

@ -19,10 +19,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.CommandMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.CommandMapper">
<select id="getOneToRun" resultType="org.apache.dolphinscheduler.dao.entity.Command"> <select id="getOneToRun" resultType="org.apache.dolphinscheduler.dao.entity.Command">
select command.* from t_ds_command command select cmd.id, cmd.command_type, cmd.process_definition_id, cmd.command_param, cmd.task_depend_type, cmd.failure_strategy,
join t_ds_process_definition definition on command.process_definition_id = definition.id cmd.warning_type, cmd.warning_group_id, cmd.schedule_time, cmd.start_time, cmd.executor_id, cmd.dependence, cmd.update_time,
cmd.process_instance_priority, cmd.worker_group
from t_ds_command cmd
join t_ds_process_definition definition on cmd.process_definition_id = definition.id
where definition.release_state = 1 AND definition.flag = 1 where definition.release_state = 1 AND definition.flag = 1
order by command.update_time asc order by cmd.update_time asc
limit 1 limit 1
</select> </select>
<select id="countCommandState" resultType="org.apache.dolphinscheduler.dao.entity.CommandCount"> <select id="countCommandState" resultType="org.apache.dolphinscheduler.dao.entity.CommandCount">

30
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/DataSourceMapper.xml

@ -18,8 +18,12 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.DataSourceMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.DataSourceMapper">
<sql id="baseSql">
id, name, note, type, user_id, connection_params, create_time, update_time
</sql>
<select id="queryDataSourceByType" resultType="org.apache.dolphinscheduler.dao.entity.DataSource"> <select id="queryDataSourceByType" resultType="org.apache.dolphinscheduler.dao.entity.DataSource">
select * select
<include refid="baseSql"/>
from t_ds_datasource from t_ds_datasource
where type=#{type} where type=#{type}
<if test="userId != 0"> <if test="userId != 0">
@ -32,11 +36,11 @@
where user_id=#{userId} where user_id=#{userId}
) )
</if> </if>
</select> </select>
<select id="selectPaging" resultType="org.apache.dolphinscheduler.dao.entity.DataSource"> <select id="selectPaging" resultType="org.apache.dolphinscheduler.dao.entity.DataSource">
select * select
<include refid="baseSql"/>
from t_ds_datasource from t_ds_datasource
where 1 =1 where 1 =1
<if test="userId != 0"> <if test="userId != 0">
@ -55,27 +59,31 @@
order by update_time desc order by update_time desc
</select> </select>
<select id="queryDataSourceByName" resultType="org.apache.dolphinscheduler.dao.entity.DataSource"> <select id="queryDataSourceByName" resultType="org.apache.dolphinscheduler.dao.entity.DataSource">
select * select
<include refid="baseSql"/>
from t_ds_datasource from t_ds_datasource
where name=#{name} where name=#{name}
</select> </select>
<select id="queryAuthedDatasource" resultType="org.apache.dolphinscheduler.dao.entity.DataSource"> <select id="queryAuthedDatasource" resultType="org.apache.dolphinscheduler.dao.entity.DataSource">
select datasource.* select ds.id, ds.name, ds.note, ds.type, ds.user_id, ds.connection_params, ds.create_time, ds.update_time
from t_ds_datasource datasource, t_ds_relation_datasource_user rel from t_ds_datasource ds, t_ds_relation_datasource_user rel
where datasource.id = rel.datasource_id AND rel.user_id = #{userId} where ds.id = rel.datasource_id AND rel.user_id = #{userId}
</select> </select>
<select id="queryDatasourceExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.DataSource"> <select id="queryDatasourceExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.DataSource">
select * select
<include refid="baseSql"/>
from t_ds_datasource from t_ds_datasource
where user_id <![CDATA[ <> ]]> #{userId} where user_id <![CDATA[ <> ]]> #{userId}
</select> </select>
<select id="listAllDataSourceByType" resultType="org.apache.dolphinscheduler.dao.entity.DataSource"> <select id="listAllDataSourceByType" resultType="org.apache.dolphinscheduler.dao.entity.DataSource">
select * select
<include refid="baseSql"/>
from t_ds_datasource from t_ds_datasource
where type = #{type} where type = #{type}
</select> </select>
<select id="listAuthorizedDataSource" resultType="org.apache.dolphinscheduler.dao.entity.DataSource"> <select id="listAuthorizedDataSource" resultType="org.apache.dolphinscheduler.dao.entity.DataSource">
select * select
<include refid="baseSql"/>
from t_ds_datasource from t_ds_datasource
where where
id in (select datasource_id from t_ds_relation_datasource_user where user_id=#{userId} id in (select datasource_id from t_ds_relation_datasource_user where user_id=#{userId}
@ -87,6 +95,4 @@
</foreach> </foreach>
</if> </if>
</select> </select>
</mapper> </mapper>

1
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapper.xml

@ -21,7 +21,6 @@
<delete id="deleteByUserId"> <delete id="deleteByUserId">
delete from t_ds_relation_datasource_user delete from t_ds_relation_datasource_user
where user_id = #{userId} where user_id = #{userId}
</delete> </delete>
<delete id="deleteByDatasourceId"> <delete id="deleteByDatasourceId">
delete from t_ds_relation_datasource_user delete from t_ds_relation_datasource_user

34
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml

@ -18,14 +18,24 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper">
<sql id="baseSql">
id, name, version, release_state, project_id, user_id, process_definition_json, description,
global_params, flag, locations, connects, receivers, receivers_cc, create_time, timeout,
tenant_id, update_time, modify_by, resource_ids
</sql>
<select id="verifyByDefineName" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition"> <select id="verifyByDefineName" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select pd.* select pd.id, pd.name, pd.version, pd.release_state, pd.project_id, pd.user_id, pd.process_definition_json, pd.description,
pd.global_params, pd.flag, pd.locations, pd.connects, pd.receivers, pd.receivers_cc, pd.create_time, pd.timeout,
pd.tenant_id, pd.update_time, pd.modify_by, pd.resource_ids
from t_ds_process_definition pd from t_ds_process_definition pd
WHERE pd.project_id = #{projectId} WHERE pd.project_id = #{projectId}
and pd.name = #{processDefinitionName} and pd.name = #{processDefinitionName}
</select> </select>
<select id="queryByDefineName" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition"> <select id="queryByDefineName" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select pd.*,u.user_name,p.name as project_name,t.tenant_code,q.queue,q.queue_name select pd.id, pd.name, pd.version, pd.release_state, pd.project_id, pd.user_id, pd.process_definition_json, pd.description,
pd.global_params, pd.flag, pd.locations, pd.connects, pd.receivers, pd.receivers_cc, pd.create_time, pd.timeout,
pd.tenant_id, pd.update_time, pd.modify_by, pd.resource_ids,
u.user_name,p.name as project_name,t.tenant_code,q.queue,q.queue_name
from t_ds_process_definition pd from t_ds_process_definition pd
JOIN t_ds_user u ON pd.user_id = u.id JOIN t_ds_user u ON pd.user_id = u.id
JOIN t_ds_project p ON pd.project_id = p.id JOIN t_ds_project p ON pd.project_id = p.id
@ -35,11 +45,13 @@
and pd.name = #{processDefinitionName} and pd.name = #{processDefinitionName}
</select> </select>
<select id="queryDefineListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition"> <select id="queryDefineListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
SELECT td.id, td.name, td.version, td.release_state, td.project_id, td.user_id, td.description, td.global_params, SELECT td.id, td.name, td.version, td.release_state, td.project_id, td.user_id, td.description,
td.global_params,
td.flag, td.receivers, td.receivers_cc, td.timeout, td.tenant_id, td.modify_by, td.update_time, td.create_time, td.flag, td.receivers, td.receivers_cc, td.timeout, td.tenant_id, td.modify_by, td.update_time, td.create_time,
sc.schedule_release_state, tu.user_name sc.schedule_release_state, tu.user_name
FROM t_ds_process_definition td FROM t_ds_process_definition td
left join (select process_definition_id,release_state as schedule_release_state from t_ds_schedules group by process_definition_id,release_state) sc on sc.process_definition_id = td.id left join (select process_definition_id,release_state as schedule_release_state from t_ds_schedules group by
process_definition_id,release_state) sc on sc.process_definition_id = td.id
left join t_ds_user tu on td.user_id = tu.id left join t_ds_user tu on td.user_id = tu.id
where td.project_id = #{projectId} where td.project_id = #{projectId}
<if test=" searchVal != null and searchVal != ''"> <if test=" searchVal != null and searchVal != ''">
@ -52,18 +64,21 @@
</select> </select>
<select id="queryAllDefinitionList" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition"> <select id="queryAllDefinitionList" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select * select
<include refid="baseSql"/>
from t_ds_process_definition from t_ds_process_definition
where project_id = #{projectId} where project_id = #{projectId}
order by create_time desc order by create_time desc
</select> </select>
<select id="queryDefinitionListByTenant" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition"> <select id="queryDefinitionListByTenant" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select * select
<include refid="baseSql"/>
from t_ds_process_definition from t_ds_process_definition
where tenant_id = #{tenantId} where tenant_id = #{tenantId}
</select> </select>
<select id="queryDefinitionListByIdList" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition"> <select id="queryDefinitionListByIdList" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select * select
<include refid="baseSql"/>
from t_ds_process_definition from t_ds_process_definition
where id in where id in
<foreach collection="ids" index="index" item="i" open="(" separator="," close=")"> <foreach collection="ids" index="index" item="i" open="(" separator="," close=")">
@ -85,7 +100,10 @@
</select> </select>
<select id="queryByDefineId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition"> <select id="queryByDefineId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
SELECT SELECT
pd.*, u.user_name, pd.id, pd.name, pd.version, pd.release_state, pd.project_id, pd.user_id, pd.process_definition_json, pd.description,
pd.global_params, pd.flag, pd.locations, pd.connects, pd.receivers, pd.receivers_cc, pd.create_time, pd.timeout,
pd.tenant_id, pd.update_time, pd.modify_by, pd.resource_ids,
u.user_name,
p.name AS project_name p.name AS project_name
FROM FROM
t_ds_process_definition pd, t_ds_process_definition pd,

17
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionVersionMapper.xml

@ -18,21 +18,29 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionVersionMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionVersionMapper">
<sql id="baseSql">
id, process_definition_id, version, process_definition_json, description, global_params,locations,connects, receivers,
receivers_cc, create_time, timeout, resource_ids
</sql>
<select id="queryMaxVersionByProcessDefinitionId" resultType="java.lang.Long"> <select id="queryMaxVersionByProcessDefinitionId" resultType="java.lang.Long">
select max(version) select max(version)
from t_ds_process_definition_version from t_ds_process_definition_version
where process_definition_id = #{processDefinitionId} where process_definition_id = #{processDefinitionId}
</select> </select>
<select id="queryProcessDefinitionVersionsPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion"> <select id="queryProcessDefinitionVersionsPaging"
select * resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion">
select
<include refid="baseSql"/>
from t_ds_process_definition_version from t_ds_process_definition_version
where process_definition_id = #{processDefinitionId} where process_definition_id = #{processDefinitionId}
order by version desc order by version desc
</select> </select>
<select id="queryByProcessDefinitionIdAndVersion" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion"> <select id="queryByProcessDefinitionIdAndVersion"
select * resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion">
select
<include refid="baseSql"/>
from t_ds_process_definition_version from t_ds_process_definition_version
where process_definition_id = #{processDefinitionId} where process_definition_id = #{processDefinitionId}
and version = #{version} and version = #{version}
@ -44,4 +52,5 @@
where process_definition_id = #{processDefinitionId} where process_definition_id = #{processDefinitionId}
and version = #{version} and version = #{version}
</delete> </delete>
</mapper> </mapper>

10
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapper.xml

@ -18,20 +18,24 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapMapper">
<sql id="baseSql">
id, parent_process_instance_id, parent_task_instance_id, process_instance_id
</sql>
<delete id="deleteByParentProcessId"> <delete id="deleteByParentProcessId">
delete delete
from t_ds_relation_process_instance from t_ds_relation_process_instance
where parent_process_instance_id=#{parentProcessId} where parent_process_instance_id=#{parentProcessId}
</delete> </delete>
<select id="queryByParentId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap"> <select id="queryByParentId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap">
select * select
<include refid="baseSql"/>
from t_ds_relation_process_instance from t_ds_relation_process_instance
where parent_process_instance_id = #{parentProcessId} where parent_process_instance_id = #{parentProcessId}
and parent_task_instance_id = #{parentTaskId} and parent_task_instance_id = #{parentTaskId}
</select> </select>
<select id="queryBySubProcessId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap"> <select id="queryBySubProcessId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap">
select * select
<include refid="baseSql"/>
from t_ds_relation_process_instance from t_ds_relation_process_instance
where process_instance_id = #{subProcessId} where process_instance_id = #{subProcessId}
</select> </select>

56
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml

@ -18,13 +18,22 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper">
<sql id="baseSql">
id, name, process_definition_id, state, recovery, start_time, end_time, run_times,host,
command_type, command_param, task_depend_type, max_try_times, failure_strategy, warning_type,
warning_group_id, schedule_time, command_start_time, global_params, process_instance_json, flag,
update_time, is_sub_process, executor_id, locations, connects, history_cmd, dependence_schedule_times,
process_instance_priority, worker_group, timeout, tenant_id, var_pool
</sql>
<select id="queryDetailById" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryDetailById" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select inst.* select
from t_ds_process_instance inst <include refid="baseSql"/>
where inst.id = #{processId} from t_ds_process_instance
where id = #{processId}
</select> </select>
<select id="queryByHostAndStatus" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryByHostAndStatus" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where 1=1 where 1=1
<if test="host != null and host != ''"> <if test="host != null and host != ''">
@ -38,7 +47,8 @@
</select> </select>
<select id="queryTopNProcessInstance" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryTopNProcessInstance" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where state = #{status} where state = #{status}
and start_time between and start_time between
@ -48,7 +58,8 @@
</select> </select>
<select id="queryByTenantIdAndStatus" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryByTenantIdAndStatus" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where 1=1 where 1=1
<if test="tenantId != -1"> <if test="tenantId != -1">
@ -62,7 +73,8 @@
</select> </select>
<select id="queryByWorkerGroupIdAndStatus" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryByWorkerGroupIdAndStatus" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where 1=1 where 1=1
<if test="workerGroupId != -1"> <if test="workerGroupId != -1">
@ -76,10 +88,17 @@
</select> </select>
<select id="queryProcessInstanceListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryProcessInstanceListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select instance.id,instance.name,instance.process_definition_id,instance.state,instance.recovery,instance.start_time,instance.end_time,instance.run_times,instance.host,instance.command_type,instance.command_param, select
instance.task_depend_type,instance.max_try_times,instance.failure_strategy,instance.warning_type,instance.warning_group_id,instance.schedule_time,instance.command_start_time,instance.global_params,instance.flag, instance.id, instance.name, instance.process_definition_id, instance.state, instance.recovery,
instance.update_time,instance.is_sub_process,instance.executor_id,instance.locations,instance.connects,instance.history_cmd,instance.dependence_schedule_times,instance.process_instance_priority,instance.worker_group, instance.start_time, instance.end_time, instance.run_times, instance.host,
instance.timeout,instance.tenant_id instance.command_type, instance.command_param, instance.task_depend_type, instance.max_try_times,
instance.failure_strategy, instance.warning_type,
instance.warning_group_id, instance.schedule_time, instance.command_start_time, instance.global_params,
instance.process_instance_json, instance.flag,
instance.update_time, instance.is_sub_process, instance.executor_id, instance.locations, instance.connects,
instance.history_cmd, instance.dependence_schedule_times,
instance.process_instance_priority, instance.worker_group, instance.timeout, instance.tenant_id,
instance.var_pool
from t_ds_process_instance instance from t_ds_process_instance instance
join t_ds_process_definition define ON instance.process_definition_id = define.id join t_ds_process_definition define ON instance.process_definition_id = define.id
where 1=1 where 1=1
@ -153,13 +172,15 @@
group by t.state group by t.state
</select> </select>
<select id="queryByProcessDefineId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryByProcessDefineId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where process_definition_id=#{processDefinitionId} where process_definition_id=#{processDefinitionId}
order by start_time desc limit #{size} order by start_time desc limit #{size}
</select> </select>
<select id="queryLastSchedulerProcess" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryLastSchedulerProcess" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where process_definition_id=#{processDefinitionId} where process_definition_id=#{processDefinitionId}
<if test="startTime!=null and endTime != null "> <if test="startTime!=null and endTime != null ">
@ -168,7 +189,8 @@
order by end_time desc limit 1 order by end_time desc limit 1
</select> </select>
<select id="queryLastRunningProcess" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryLastRunningProcess" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where process_definition_id=#{processDefinitionId} where process_definition_id=#{processDefinitionId}
<if test="states !=null and states.length != 0"> <if test="states !=null and states.length != 0">
@ -184,7 +206,8 @@
order by start_time desc limit 1 order by start_time desc limit 1
</select> </select>
<select id="queryLastManualProcess" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> <select id="queryLastManualProcess" resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where process_definition_id=#{processDefinitionId} where process_definition_id=#{processDefinitionId}
and schedule_time is null and schedule_time is null
@ -195,7 +218,8 @@
</select> </select>
<select id="queryByProcessDefineIdAndStatus" <select id="queryByProcessDefineIdAndStatus"
resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance"> resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
select * select
<include refid="baseSql"/>
from t_ds_process_instance from t_ds_process_instance
where process_definition_id=#{processDefinitionId} where process_definition_id=#{processDefinitionId}
and state in and state in

46
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml

@ -18,23 +18,45 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectMapper">
<sql id="baseSql">
id, name, description, user_id, flag, create_time, update_time
</sql>
<sql id="baseSqlV2">
${alias}.id, ${alias}.name, ${alias}.description, ${alias}.user_id, ${alias}.flag, ${alias}.create_time, ${alias}.update_time
</sql>
<select id="queryDetailById" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryDetailById" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select p.*,u.user_name as user_name select
<include refid="baseSqlV2">
<property name="alias" value="p"/>
</include>
,
u.user_name as user_name
from t_ds_project p from t_ds_project p
join t_ds_user u on p.user_id = u.id join t_ds_user u on p.user_id = u.id
where p.id = #{projectId} where p.id = #{projectId}
</select> </select>
<select id="queryByName" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryByName" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select p.*,u.user_name as user_name select
<include refid="baseSqlV2">
<property name="alias" value="p"/>
</include>
,
u.user_name as user_name
from t_ds_project p from t_ds_project p
join t_ds_user u on p.user_id = u.id join t_ds_user u on p.user_id = u.id
where p.name = #{projectName} where p.name = #{projectName}
limit 1 limit 1
</select> </select>
<select id="queryProjectListPaging" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryProjectListPaging" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select p.*,u.user_name as user_name, select
<include refid="baseSqlV2">
<property name="alias" value="p"/>
</include>
,
u.user_name as user_name,
(SELECT COUNT(*) FROM t_ds_process_definition AS def WHERE def.project_id = p.id) AS def_count, (SELECT COUNT(*) FROM t_ds_process_definition AS def WHERE def.project_id = p.id) AS def_count,
(SELECT COUNT(*) FROM t_ds_process_definition def, t_ds_process_instance inst WHERE def.id = inst.process_definition_id AND def.project_id = p.id AND inst.state=1 ) as inst_running_count (SELECT COUNT(*) FROM t_ds_process_definition def, t_ds_process_instance inst WHERE def.id =
inst.process_definition_id AND def.project_id = p.id AND inst.state=1 ) as inst_running_count
from t_ds_project p from t_ds_project p
join t_ds_user u on u.id=p.user_id join t_ds_user u on u.id=p.user_id
where 1=1 where 1=1
@ -50,23 +72,29 @@
order by p.create_time desc order by p.create_time desc
</select> </select>
<select id="queryAuthedProjectListByUserId" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryAuthedProjectListByUserId" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select p.* select
<include refid="baseSqlV2">
<property name="alias" value="p"/>
</include>
,
from t_ds_project p,t_ds_relation_project_user rel from t_ds_project p,t_ds_relation_project_user rel
where p.id = rel.project_id and rel.user_id= #{userId} where p.id = rel.project_id and rel.user_id= #{userId}
</select> </select>
<select id="queryProjectExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryProjectExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select * select
<include refid="baseSql"/>
from t_ds_project from t_ds_project
where user_id <![CDATA[ <> ]]> #{userId} where user_id <![CDATA[ <> ]]> #{userId}
</select> </select>
<select id="queryProjectCreatedByUser" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryProjectCreatedByUser" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select * select
<include refid="baseSql"/>
from t_ds_project from t_ds_project
where user_id = #{userId} where user_id = #{userId}
</select> </select>
<select id="queryProjectCreatedAndAuthorizedByUserId" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryProjectCreatedAndAuthorizedByUserId" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select * from t_ds_project where id in (select project_id from t_ds_relation_project_user where user_id=#{userId} select * from t_ds_project where id in
(select project_id from t_ds_relation_project_user where user_id=#{userId}
union select id as project_id from t_ds_project where user_id=#{userId}) union select id as project_id from t_ds_project where user_id=#{userId})
</select> </select>
</mapper> </mapper>

6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.xml

@ -18,6 +18,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper">
<sql id="baseSql">
id, user_id, project_id, perm, create_time, update_time
</sql>
<delete id="deleteProjectRelation"> <delete id="deleteProjectRelation">
delete from t_ds_relation_project_user delete from t_ds_relation_project_user
where 1=1 where 1=1
@ -27,7 +30,8 @@
</if> </if>
</delete> </delete>
<select id="queryProjectRelation" resultType="org.apache.dolphinscheduler.dao.entity.ProjectUser"> <select id="queryProjectRelation" resultType="org.apache.dolphinscheduler.dao.entity.ProjectUser">
select * select
<include refid="baseSql"/>
from t_ds_relation_project_user from t_ds_relation_project_user
where project_id = #{projectId} where project_id = #{projectId}
and user_id = #{userId} and user_id = #{userId}

9
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/QueueMapper.xml

@ -18,8 +18,12 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.QueueMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.QueueMapper">
<sql id="baseSql">
id, queue_name, queue, create_time, update_time
</sql>
<select id="queryQueuePaging" resultType="org.apache.dolphinscheduler.dao.entity.Queue"> <select id="queryQueuePaging" resultType="org.apache.dolphinscheduler.dao.entity.Queue">
select * select
<include refid="baseSql"/>
from t_ds_queue from t_ds_queue
where 1= 1 where 1= 1
<if test="searchVal != null and searchVal != ''"> <if test="searchVal != null and searchVal != ''">
@ -28,7 +32,8 @@
order by update_time desc order by update_time desc
</select> </select>
<select id="queryAllQueueList" resultType="org.apache.dolphinscheduler.dao.entity.Queue"> <select id="queryAllQueueList" resultType="org.apache.dolphinscheduler.dao.entity.Queue">
select * select
<include refid="baseSql"/>
from t_ds_queue from t_ds_queue
where 1=1 where 1=1
<if test="queue != null and queue != ''"> <if test="queue != null and queue != ''">

39
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.xml

@ -18,8 +18,17 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ResourceMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ResourceMapper">
<sql id="baseSql">
id, alias, file_name, description, user_id, type, size, create_time, update_time,
pid, full_name, is_directory
</sql>
<sql id="baseSqlV2">
${alias}.id, ${alias}.alias, ${alias}.file_name, ${alias}.description, ${alias}.user_id, ${alias}.type, ${alias}.size, ${alias}.create_time, ${alias}.update_time,
${alias}.pid, ${alias}.full_name, ${alias}.is_directory
</sql>
<select id="queryResourceList" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="queryResourceList" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select * select
<include refid="baseSql"/>
from t_ds_resources from t_ds_resources
where 1= 1 where 1= 1
<if test="fullName != null and fullName != ''"> <if test="fullName != null and fullName != ''">
@ -33,7 +42,8 @@
</if> </if>
</select> </select>
<select id="queryResourceListAuthored" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="queryResourceListAuthored" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select * select
<include refid="baseSql"/>
from t_ds_resources from t_ds_resources
where 1 = 1 where 1 = 1
<if test="type != -1"> <if test="type != -1">
@ -49,7 +59,8 @@
</if> </if>
</select> </select>
<select id="queryResourcePaging" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="queryResourcePaging" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select * select
<include refid="baseSql"/>
from t_ds_resources from t_ds_resources
where type=#{type} and pid=#{id} where type=#{type} and pid=#{id}
<if test="userId != 0"> <if test="userId != 0">
@ -62,12 +73,16 @@
order by update_time desc order by update_time desc
</select> </select>
<select id="queryAuthorizedResourceList" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="queryAuthorizedResourceList" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select r.* select
<include refid="baseSqlV2">
<property name="alias" value="r"/>
</include>
from t_ds_resources r,t_ds_relation_resources_user rel from t_ds_resources r,t_ds_relation_resources_user rel
where r.id = rel.resources_id AND rel.user_id = #{userId} and perm=7 where r.id = rel.resources_id AND rel.user_id = #{userId} and perm=7
</select> </select>
<select id="queryResourceExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="queryResourceExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select * select
<include refid="baseSql"/>
from t_ds_resources from t_ds_resources
where user_id <![CDATA[ <> ]]> #{userId} where user_id <![CDATA[ <> ]]> #{userId}
</select> </select>
@ -78,7 +93,8 @@
and res.full_name= #{resName} and res.full_name= #{resName}
</select> </select>
<select id="listAuthorizedResource" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="listAuthorizedResource" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select * select
<include refid="baseSql"/>
from t_ds_resources from t_ds_resources
where type=0 where type=0
and id in (select resources_id from t_ds_relation_resources_user where user_id=#{userId} and perm=7 and id in (select resources_id from t_ds_relation_resources_user where user_id=#{userId} and perm=7
@ -91,7 +107,8 @@
</if> </if>
</select> </select>
<select id="listAuthorizedResourceById" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="listAuthorizedResourceById" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select * select
<include refid="baseSql"/>
from t_ds_resources from t_ds_resources
where id in (select resources_id from t_ds_relation_resources_user where user_id=#{userId} and perm=7 where id in (select resources_id from t_ds_relation_resources_user where user_id=#{userId} and perm=7
union select id as resources_id from t_ds_resources where user_id=#{userId}) union select id as resources_id from t_ds_resources where user_id=#{userId})
@ -117,14 +134,15 @@
</select> </select>
<select id="queryResource" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="queryResource" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select * select
<include refid="baseSql"/>
from t_ds_resources from t_ds_resources
where type = #{type} where type = #{type}
and full_name = #{fullName} and full_name = #{fullName}
</select> </select>
<update id="batchUpdateResource" parameterType="java.util.List"> <update id="batchUpdateResource" parameterType="java.util.List">
<foreach collection="resourceList" item="resource" index="index" open="" close="" separator =";"> <foreach collection="resourceList" item="resource" index="index" open="" close="" separator=";">
update t_ds_resources update t_ds_resources
<set> <set>
full_name=#{resource.fullName}, full_name=#{resource.fullName},
@ -137,7 +155,8 @@
</update> </update>
<select id="listResourceByIds" resultType="org.apache.dolphinscheduler.dao.entity.Resource"> <select id="listResourceByIds" resultType="org.apache.dolphinscheduler.dao.entity.Resource">
select * select
<include refid="baseSql"/>
from t_ds_resources from t_ds_resources
where id in where id in
<foreach collection="resIds" item="i" open="(" close=")" separator=","> <foreach collection="resIds" item="i" open="(" close=")" separator=",">

25
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.xml

@ -18,8 +18,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ScheduleMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ScheduleMapper">
<sql id="baseSql">
id, process_definition_id, start_time, end_time, crontab, failure_strategy, user_id, release_state,
warning_type, warning_group_id, process_instance_priority, worker_group, create_time, update_time
</sql>
<sql id="baseSqlV2">
${alias}.id, ${alias}.process_definition_id, ${alias}.start_time, ${alias}.end_time, ${alias}.crontab, ${alias}.failure_strategy, ${alias}.user_id, ${alias}.release_state,
${alias}.warning_type, ${alias}.warning_group_id, ${alias}.process_instance_priority, ${alias}.worker_group, ${alias}.create_time, ${alias}.update_time
</sql>
<select id="queryByProcessDefineIdPaging" resultType="org.apache.dolphinscheduler.dao.entity.Schedule"> <select id="queryByProcessDefineIdPaging" resultType="org.apache.dolphinscheduler.dao.entity.Schedule">
select p_f.name as process_definition_name, p.name as project_name,u.user_name,s.* select p_f.name as process_definition_name, p.name as project_name,u.user_name,
<include refid="baseSqlV2">
<property name="alias" value="s"/>
</include>
from t_ds_schedules s from t_ds_schedules s
join t_ds_process_definition p_f on s.process_definition_id = p_f.id join t_ds_process_definition p_f on s.process_definition_id = p_f.id
join t_ds_project as p on p_f.project_id = p.id join t_ds_project as p on p_f.project_id = p.id
@ -39,7 +50,8 @@
where p.name = #{projectName} where p.name = #{projectName}
</select> </select>
<select id="selectAllByProcessDefineArray" resultType="org.apache.dolphinscheduler.dao.entity.Schedule"> <select id="selectAllByProcessDefineArray" resultType="org.apache.dolphinscheduler.dao.entity.Schedule">
select * select
<include refid="baseSql"/>
from t_ds_schedules from t_ds_schedules
where 1= 1 where 1= 1
<if test="processDefineIds != null and processDefineIds.length != 0 "> <if test="processDefineIds != null and processDefineIds.length != 0 ">
@ -51,12 +63,15 @@
and release_state = 1 and release_state = 1
</select> </select>
<select id="queryByProcessDefinitionId" resultType="org.apache.dolphinscheduler.dao.entity.Schedule"> <select id="queryByProcessDefinitionId" resultType="org.apache.dolphinscheduler.dao.entity.Schedule">
select * select
<include refid="baseSql"/>
from t_ds_schedules from t_ds_schedules
where process_definition_id =#{processDefinitionId} where process_definition_id =#{processDefinitionId}
</select> </select>
<select id="queryReleaseSchedulerListByProcessDefinitionId" resultType="org.apache.dolphinscheduler.dao.entity.Schedule"> <select id="queryReleaseSchedulerListByProcessDefinitionId"
select * resultType="org.apache.dolphinscheduler.dao.entity.Schedule">
select
<include refid="baseSql"/>
from t_ds_schedules from t_ds_schedules
where process_definition_id =#{processDefinitionId} and release_state = 1 where process_definition_id =#{processDefinitionId} and release_state = 1
</select> </select>

9
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/SessionMapper.xml

@ -18,14 +18,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.SessionMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.SessionMapper">
<sql id="baseSql">
id, user_id, ip, last_login_time
</sql>
<select id="queryByUserId" resultType="org.apache.dolphinscheduler.dao.entity.Session"> <select id="queryByUserId" resultType="org.apache.dolphinscheduler.dao.entity.Session">
select * select
<include refid="baseSql"/>
from t_ds_session from t_ds_session
where user_id = #{userId} where user_id = #{userId}
</select> </select>
<select id="queryByUserIdAndIp" resultType="org.apache.dolphinscheduler.dao.entity.Session"> <select id="queryByUserIdAndIp" resultType="org.apache.dolphinscheduler.dao.entity.Session">
select * select
<include refid="baseSql"/>
from t_ds_session from t_ds_session
where user_id = #{userId} AND ip = #{ip} where user_id = #{userId} AND ip = #{ip}
</select> </select>

31
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml

@ -18,6 +18,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper">
<sql id="baseSql">
id, name, task_type, process_definition_id, process_instance_id, task_json, state, submit_time,
start_time, end_time, host, execute_path, log_path, alert_flag, retry_times, pid, app_link,
flag, retry_interval, max_retry_times, task_instance_priority, worker_group, executor_id,
first_submit_time, delay_time, var_pool
</sql>
<sql id="baseSqlV2">
${alias}.id, ${alias}.name, ${alias}.task_type, ${alias}.process_definition_id, ${alias}.process_instance_id, ${alias}.task_json, ${alias}.state, ${alias}.submit_time,
${alias}.start_time, ${alias}.end_time, ${alias}.host, ${alias}.execute_path, ${alias}.log_path, ${alias}.alert_flag, ${alias}.retry_times, ${alias}.pid, ${alias}.app_link,
${alias}.flag, ${alias}.retry_interval, ${alias}.max_retry_times, ${alias}.task_instance_priority, ${alias}.worker_group, ${alias}.executor_id,
${alias}.first_submit_time, ${alias}.delay_time, ${alias}.var_pool
</sql>
<update id="setFailoverByHostAndStateArray"> <update id="setFailoverByHostAndStateArray">
update t_ds_task_instance update t_ds_task_instance
set state = #{destStatus} set state = #{destStatus}
@ -35,14 +47,16 @@
and flag = 1 and flag = 1
</select> </select>
<select id="findValidTaskListByProcessId" resultType="org.apache.dolphinscheduler.dao.entity.TaskInstance"> <select id="findValidTaskListByProcessId" resultType="org.apache.dolphinscheduler.dao.entity.TaskInstance">
select * select
<include refid="baseSql"/>
from t_ds_task_instance from t_ds_task_instance
WHERE process_instance_id = #{processInstanceId} WHERE process_instance_id = #{processInstanceId}
and flag = #{flag} and flag = #{flag}
order by start_time desc order by start_time desc
</select> </select>
<select id="queryByHostAndStatus" resultType="org.apache.dolphinscheduler.dao.entity.TaskInstance"> <select id="queryByHostAndStatus" resultType="org.apache.dolphinscheduler.dao.entity.TaskInstance">
select * select
<include refid="baseSql"/>
from t_ds_task_instance from t_ds_task_instance
where 1 = 1 where 1 = 1
<if test="host != null and host != ''"> <if test="host != null and host != ''">
@ -73,7 +87,8 @@
group by t.state group by t.state
</select> </select>
<select id="queryByInstanceIdAndName" resultType="org.apache.dolphinscheduler.dao.entity.TaskInstance"> <select id="queryByInstanceIdAndName" resultType="org.apache.dolphinscheduler.dao.entity.TaskInstance">
select * select
<include refid="baseSql"/>
from t_ds_task_instance from t_ds_task_instance
where process_instance_id = #{processInstanceId} where process_instance_id = #{processInstanceId}
and name = #{name} and name = #{name}
@ -98,10 +113,14 @@
</if> </if>
</select> </select>
<select id="queryTaskInstanceListPaging" resultType="org.apache.dolphinscheduler.dao.entity.TaskInstance"> <select id="queryTaskInstanceListPaging" resultType="org.apache.dolphinscheduler.dao.entity.TaskInstance">
select instance.id,instance.name,instance.task_type,instance.process_definition_id,instance.process_instance_id,instance.state,instance.submit_time,instance.start_time,instance.end_time, select
instance.host,instance.execute_path,instance.log_path,instance.alert_flag,instance.retry_times,instance.pid,instance.app_link,instance.flag,instance.retry_interval,instance.max_retry_times,instance.task_instance_priority,instance.worker_group,instance.executor_id,process.name as process_instance_name <include refid="baseSqlV2">
<property name="alias" value="instance"/>
</include>
,
process.name as process_instance_name
from t_ds_task_instance instance from t_ds_task_instance instance
join t_ds_process_definition define ON instance.process_definition_id = define.id join t_ds_process_definition define on instance.process_definition_id = define.id
join t_ds_process_instance process on process.id=instance.process_instance_id join t_ds_process_instance process on process.id=instance.process_instance_id
where define.project_id = #{projectId} where define.project_id = #{projectId}
<if test="startTime != null"> <if test="startTime != null">

22
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TenantMapper.xml

@ -18,19 +18,35 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.TenantMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.TenantMapper">
<sql id="baseSql">
id, tenant_code, description, queue_id, create_time, update_time
</sql>
<sql id="baseSqlV2">
${alias}.id, ${alias}.tenant_code, ${alias}.description, ${alias}.queue_id, ${alias}.create_time, ${alias}.update_time
</sql>
<select id="queryById" resultType="org.apache.dolphinscheduler.dao.entity.Tenant"> <select id="queryById" resultType="org.apache.dolphinscheduler.dao.entity.Tenant">
SELECT t.*,q.queue_name,q.queue SELECT
<include refid="baseSqlV2">
<property name="alias" value="t"/>
</include>
,
q.queue_name,q.queue
FROM t_ds_tenant t,t_ds_queue q FROM t_ds_tenant t,t_ds_queue q
WHERE t.queue_id = q.id WHERE t.queue_id = q.id
and t.id = #{tenantId} and t.id = #{tenantId}
</select> </select>
<select id="queryByTenantCode" resultType="org.apache.dolphinscheduler.dao.entity.Tenant"> <select id="queryByTenantCode" resultType="org.apache.dolphinscheduler.dao.entity.Tenant">
select * select
<include refid="baseSql"/>
from t_ds_tenant from t_ds_tenant
where tenant_code = #{tenantCode} where tenant_code = #{tenantCode}
</select> </select>
<select id="queryTenantPaging" resultType="org.apache.dolphinscheduler.dao.entity.Tenant"> <select id="queryTenantPaging" resultType="org.apache.dolphinscheduler.dao.entity.Tenant">
SELECT t.*,q.queue_name SELECT
<include refid="baseSqlV2">
<property name="alias" value="t"/>
</include>
, q.queue_name
FROM t_ds_tenant t,t_ds_queue q FROM t_ds_tenant t,t_ds_queue q
WHERE t.queue_id = q.id WHERE t.queue_id = q.id
<if test="searchVal != null and searchVal != ''"> <if test="searchVal != null and searchVal != ''">

44
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapper.xml

@ -19,13 +19,17 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper">
<select id="selectUdfById" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="selectUdfById" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
select * select
id, user_id, func_name, class_name, type, arg_types,
database, description, resource_id, resource_name, create_time, update_time
from t_ds_udfs from t_ds_udfs
where id = #{id} where id = #{id}
</select> </select>
<select id="queryUdfByIdStr" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="queryUdfByIdStr" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
select * select
id, user_id, func_name, class_name, type, arg_types,
database, description, resource_id, resource_name, create_time, update_time
from t_ds_udfs from t_ds_udfs
where 1 = 1 where 1 = 1
<if test="ids != null and ids != ''"> <if test="ids != null and ids != ''">
@ -40,7 +44,7 @@
order by id asc order by id asc
</select> </select>
<select id="queryUdfFuncPaging" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="queryUdfFuncPaging" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
select * select id, user_id, func_name, class_name, type, arg_types, database, description, resource_id, resource_name, create_time, update_time
from t_ds_udfs from t_ds_udfs
where 1=1 where 1=1
<if test="searchVal!= null and searchVal != ''"> <if test="searchVal!= null and searchVal != ''">
@ -54,7 +58,9 @@
order by create_time desc order by create_time desc
</select> </select>
<select id="getUdfFuncByType" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="getUdfFuncByType" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
select * select
id, user_id, func_name, class_name, type, arg_types,
database, description, resource_id, resource_name, create_time, update_time
from t_ds_udfs from t_ds_udfs
where type=#{type} where type=#{type}
<if test="userId != 0"> <if test="userId != 0">
@ -64,19 +70,25 @@
</if> </if>
</select> </select>
<select id="queryUdfFuncExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="queryUdfFuncExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
select * select
id, user_id, func_name, class_name, type, arg_types,
database, description, resource_id, resource_name, create_time, update_time
from t_ds_udfs from t_ds_udfs
where user_id <![CDATA[ <> ]]> #{userId} where user_id <![CDATA[ <> ]]> #{userId}
</select> </select>
<select id="queryAuthedUdfFunc" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="queryAuthedUdfFunc" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
SELECT u.* SELECT
u.id, u.user_id, u.func_name, u.class_name, u.type, u.arg_types,
u.database, u.description, u.resource_id, u.resource_name, u.create_time, u.update_time
from t_ds_udfs u,t_ds_relation_udfs_user rel from t_ds_udfs u,t_ds_relation_udfs_user rel
WHERE u.id = rel.udf_id WHERE u.id = rel.udf_id
AND rel.user_id = #{userId} AND rel.user_id = #{userId}
</select> </select>
<select id="listAuthorizedUdfFunc" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="listAuthorizedUdfFunc" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
select * select
from t_ds_udfs u.id, u.user_id, u.func_name, u.class_name, u.type, u.arg_types,
u.database, u.description, u.resource_id, u.resource_name, u.create_time, u.update_time
from t_ds_udfs u
where where
id in (select udf_id from t_ds_relation_udfs_user where user_id=#{userId} id in (select udf_id from t_ds_relation_udfs_user where user_id=#{userId}
union select id as udf_id from t_ds_udfs where user_id=#{userId}) union select id as udf_id from t_ds_udfs where user_id=#{userId})
@ -88,8 +100,10 @@
</if> </if>
</select> </select>
<select id="listUdfByResourceId" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="listUdfByResourceId" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
select * select
from t_ds_udfs u.id, u.user_id, u.func_name, u.class_name, u.type, u.arg_types,
u.database, u.description, u.resource_id, u.resource_name, u.create_time, u.update_time
from t_ds_udfs u
where 1=1 where 1=1
<if test="resourceIds != null and resourceIds != ''"> <if test="resourceIds != null and resourceIds != ''">
and resource_id in and resource_id in
@ -99,8 +113,10 @@
</if> </if>
</select> </select>
<select id="listAuthorizedUdfByResourceId" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc"> <select id="listAuthorizedUdfByResourceId" resultType="org.apache.dolphinscheduler.dao.entity.UdfFunc">
select * select
from t_ds_udfs u.id, u.user_id, u.func_name, u.class_name, u.type, u.arg_types,
u.database, u.description, u.resource_id, u.resource_name, u.create_time, u.update_time
from t_ds_udfs u
where where
id in (select udf_id from t_ds_relation_udfs_user where user_id=#{userId} id in (select udf_id from t_ds_relation_udfs_user where user_id=#{userId}
union select id as udf_id from t_ds_udfs where user_id=#{userId}) union select id as udf_id from t_ds_udfs where user_id=#{userId})
@ -111,9 +127,8 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<update id="batchUpdateUdfFunc" parameterType="java.util.List"> <update id="batchUpdateUdfFunc" parameterType="java.util.List">
<foreach collection="udfFuncList" item="udf" index="index" open="" close="" separator =";"> <foreach collection="udfFuncList" item="udf" index="index" open="" close="" separator=";">
update t_ds_udfs update t_ds_udfs
<set> <set>
resource_name=#{udf.resourceName}, resource_name=#{udf.resourceName},
@ -125,3 +140,4 @@
</foreach> </foreach>
</update> </update>
</mapper> </mapper>

9
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapper.xml

@ -18,12 +18,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper">
<sql id="baseSql">
${alias}.id, ${alias}.user_name, ${alias}.user_password, ${alias}.user_type, ${alias}.email, ${alias}.phone, ${alias}.tenant_id,
${alias}.create_time, ${alias}.update_time, ${alias}.queue, ${alias}.state
</sql>
<delete id="deleteByAlertgroupId"> <delete id="deleteByAlertgroupId">
delete from t_ds_relation_user_alertgroup delete from t_ds_relation_user_alertgroup
where alertgroup_id = #{alertgroupId} where alertgroup_id = #{alertgroupId}
</delete> </delete>
<select id="listUserByAlertgroupId" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="listUserByAlertgroupId" resultType="org.apache.dolphinscheduler.dao.entity.User">
SELECT u.* SELECT
<include refid="baseSql">
<property name="alias" value="u"/>
</include>
FROM t_ds_relation_user_alertgroup g_u FROM t_ds_relation_user_alertgroup g_u
JOIN t_ds_user u on g_u.user_id = u.id JOIN t_ds_user u on g_u.user_id = u.id
WHERE g_u.alertgroup_id = #{alertgroupId} WHERE g_u.alertgroup_id = #{alertgroupId}

49
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserMapper.xml

@ -18,16 +18,29 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.UserMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.UserMapper">
<sql id="baseSql">
id, user_name, user_password, user_type, email, phone, tenant_id, create_time, update_time, queue, state
</sql>
<sql id="baseSqlV2">
${alias}.id, ${alias}.user_name, ${alias}.user_password, ${alias}.user_type, ${alias}.email, ${alias}.phone, ${alias}.tenant_id,
${alias}.create_time, ${alias}.update_time, ${alias}.queue, ${alias}.state
</sql>
<select id="queryAllGeneralUser" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryAllGeneralUser" resultType="org.apache.dolphinscheduler.dao.entity.User">
select * from t_ds_user select
<include refid="baseSql"/>
from t_ds_user
where user_type=1; where user_type=1;
</select> </select>
<select id="queryByUserNameAccurately" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryByUserNameAccurately" resultType="org.apache.dolphinscheduler.dao.entity.User">
select * from t_ds_user select
<include refid="baseSql"/>
from t_ds_user
where user_name=#{userName} where user_name=#{userName}
</select> </select>
<select id="queryUserByNamePassword" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryUserByNamePassword" resultType="org.apache.dolphinscheduler.dao.entity.User">
select * from t_ds_user select
<include refid="baseSql"/>
from t_ds_user
where user_name=#{userName} and user_password = #{password} where user_name=#{userName} and user_password = #{password}
</select> </select>
<select id="queryUserPaging" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryUserPaging" resultType="org.apache.dolphinscheduler.dao.entity.User">
@ -38,13 +51,17 @@
left join t_ds_tenant t on u.tenant_id=t.id left join t_ds_tenant t on u.tenant_id=t.id
left join t_ds_queue q on t.queue_id = q.id left join t_ds_queue q on t.queue_id = q.id
where 1=1 where 1=1
<if test="userName!=null and userName != ''" > <if test="userName!=null and userName != ''">
and u.user_name like concat ('%', #{userName}, '%') and u.user_name like concat ('%', #{userName}, '%')
</if> </if>
order by u.update_time desc order by u.update_time desc
</select> </select>
<select id="queryDetailsById" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryDetailsById" resultType="org.apache.dolphinscheduler.dao.entity.User">
select u.*, t.tenant_code, select
<include refid="baseSqlV2">
<property name="alias" value="u"/>
</include>
,
case when u.queue <![CDATA[ <> ]]> '' then u.queue else q.queue_name end as queue_name case when u.queue <![CDATA[ <> ]]> '' then u.queue else q.queue_name end as queue_name
from t_ds_user u from t_ds_user u
left join t_ds_tenant t on u.tenant_id=t.id left join t_ds_tenant t on u.tenant_id=t.id
@ -52,27 +69,39 @@
WHERE u.id = #{userId} WHERE u.id = #{userId}
</select> </select>
<select id="queryUserListByAlertGroupId" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryUserListByAlertGroupId" resultType="org.apache.dolphinscheduler.dao.entity.User">
select u.* select
<include refid="baseSqlV2">
<property name="alias" value="u"/>
</include>
from t_ds_user u, t_ds_relation_user_alertgroup rel from t_ds_user u, t_ds_relation_user_alertgroup rel
where u.id = rel.user_id AND rel.alertgroup_id = #{alertgroupId} where u.id = rel.user_id AND rel.alertgroup_id = #{alertgroupId}
</select> </select>
<select id="queryUserListByTenant" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryUserListByTenant" resultType="org.apache.dolphinscheduler.dao.entity.User">
select * select
<include refid="baseSql"/>
from t_ds_user from t_ds_user
where tenant_id = #{tenantId} where tenant_id = #{tenantId}
</select> </select>
<select id="queryTenantCodeByUserId" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryTenantCodeByUserId" resultType="org.apache.dolphinscheduler.dao.entity.User">
SELECT u.*,t.tenant_code SELECT
<include refid="baseSqlV2">
<property name="alias" value="u"/>
</include>
, t.tenant_code
FROM t_ds_user u, t_ds_tenant t FROM t_ds_user u, t_ds_tenant t
WHERE u.tenant_id = t.id AND u.id = #{userId} WHERE u.tenant_id = t.id AND u.id = #{userId}
</select> </select>
<select id="queryUserByToken" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryUserByToken" resultType="org.apache.dolphinscheduler.dao.entity.User">
select u.* select
<include refid="baseSqlV2">
<property name="alias" value="u"/>
</include>
from t_ds_user u ,t_ds_access_token t from t_ds_user u ,t_ds_access_token t
where u.id = t.user_id and token=#{token} and t.expire_time > NOW() where u.id = t.user_id and token=#{token} and t.expire_time > NOW()
</select> </select>
<select id="queryUserListByQueue" resultType="org.apache.dolphinscheduler.dao.entity.User"> <select id="queryUserListByQueue" resultType="org.apache.dolphinscheduler.dao.entity.User">
select * select
<include refid="baseSql"/>
from t_ds_user from t_ds_user
where queue = #{queueName} where queue = #{queueName}
</select> </select>

95
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java

@ -134,6 +134,43 @@ public class ProcessDefinitionMapperTest {
Assert.assertNotEquals(dataSources.size(), 0); Assert.assertNotEquals(dataSources.size(), 0);
} }
/**
* test verifyByDefineName
*/
@Test
public void testVerifyByDefineName() {
Project project = new Project();
project.setName("ut project");
project.setUserId(4);
projectMapper.insert(project);
Queue queue = new Queue();
queue.setQueue("queue");
queue.setQueueName("queue name");
queueMapper.insert(queue);
Tenant tenant = new Tenant();
tenant.setTenantCode("tenant");
tenant.setQueueId(queue.getId());
tenant.setDescription("t");
tenantMapper.insert(tenant);
User user = new User();
user.setUserName("hello");
user.setUserPassword("pwd");
user.setUserType(UserType.GENERAL_USER);
user.setTenantId(tenant.getId());
userMapper.insert(user);
//insertOne
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setName("def 1");
processDefinition.setProjectId(project.getId());
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
processDefinition.setTenantId(tenant.getId());
processDefinition.setUserId(user.getId());
processDefinitionMapper.insert(processDefinition);
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(10, "xxx");
Assert.assertEquals(definition, null);
}
/** /**
* test query by definition name * test query by definition name
*/ */
@ -178,6 +215,64 @@ public class ProcessDefinitionMapperTest {
Assert.assertNotEquals(processDefinition1, null); Assert.assertNotEquals(processDefinition1, null);
} }
/**
* test queryDefinitionListByTenant
*/
@Test
public void testQueryDefinitionListByTenant() {
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setName("def 1");
processDefinition.setProjectId(888);
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
processDefinition.setTenantId(999);
processDefinition.setUserId(1234);
processDefinitionMapper.insert(processDefinition);
List<ProcessDefinition> definitions = processDefinitionMapper.queryDefinitionListByTenant(999);
Assert.assertNotEquals(definitions.size(), 0);
}
/**
* test queryByDefineId
*/
@Test
public void testQueryByDefineId() {
Project project = new Project();
project.setName("ut project");
project.setUserId(4);
projectMapper.insert(project);
Queue queue = new Queue();
queue.setQueue("queue");
queue.setQueueName("queue name");
queueMapper.insert(queue);
Tenant tenant = new Tenant();
tenant.setTenantCode("tenant");
tenant.setQueueId(queue.getId());
tenant.setDescription("t");
tenantMapper.insert(tenant);
User user = new User();
user.setUserName("hello");
user.setUserPassword("pwd");
user.setUserType(UserType.GENERAL_USER);
user.setTenantId(tenant.getId());
userMapper.insert(user);
//insertOne
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setName("def 1");
processDefinition.setProjectId(project.getId());
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
processDefinition.setTenantId(tenant.getId());
processDefinition.setUserId(user.getId());
processDefinitionMapper.insert(processDefinition);
ProcessDefinition definition = processDefinitionMapper.queryByDefineId(333);
Assert.assertEquals(definition, null);
}
/** /**
* test page * test page
*/ */

6
dolphinscheduler-ui/src/js/conf/home/pages/security/pages/tenement/_source/createTenement.vue

@ -68,7 +68,6 @@
import store from '@/conf/home/store' import store from '@/conf/home/store'
import mPopup from '@/module/components/popup/popup' import mPopup from '@/module/components/popup/popup'
import mListBoxF from '@/module/components/listBoxF/listBoxF' import mListBoxF from '@/module/components/listBoxF/listBoxF'
export default { export default {
name: 'create-tenement', name: 'create-tenement',
data () { data () {
@ -120,17 +119,14 @@
}, },
_verification () { _verification () {
let isEn = /^[0-9a-zA-Z_.-]{1,}$/ let isEn = /^[0-9a-zA-Z_.-]{1,}$/
if (!this.tenantCode.replace(/\s*/g,"")) { if (!this.tenantCode.replace(/\s*/g,"")) {
this.$message.warning(`${i18n.$t('Please enter the tenant code in English')}`) this.$message.warning(`${i18n.$t('Please enter the tenant code in English')}`)
return false return false
} }
if (!isEn.test(this.tenantCode) || _.startsWith(this.tenantCode, '_', 0) || _.startsWith(this.tenantCode, '.', 0)) { if (!isEn.test(this.tenantCode) || _.startsWith(this.tenantCode, '_', 0) || _.startsWith(this.tenantCode, '.', 0)) {
this.$message.warning(`${i18n.$t('Please enter tenant code in English')}`) this.$message.warning(`${i18n.$t('Please enter tenant code in English')}`)
return false return false
} }
return true return true
}, },
_submit () { _submit () {
@ -143,7 +139,6 @@
if (this.item) { if (this.item) {
param.id = this.item.id param.id = this.item.id
} }
this.$refs['popup'].spinnerLoading = true this.$refs['popup'].spinnerLoading = true
this.store.dispatch(`security/${this.item ? 'updateQueue' : 'createQueue'}`, param).then(res => { this.store.dispatch(`security/${this.item ? 'updateQueue' : 'createQueue'}`, param).then(res => {
this.$emit('onUpdate') this.$emit('onUpdate')
@ -171,7 +166,6 @@
}) })
}, },
mounted () { mounted () {
}, },
components: { mPopup, mListBoxF } components: { mPopup, mListBoxF }
} }

Loading…
Cancel
Save