ProcessDefinitionMapper.xml 4.6 KB
Newer Older
B
bao liang 已提交
1
<?xml version="1.0" encoding="UTF-8" ?>
B
bao liang 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

B
bao liang 已提交
19
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
Q
qiaozhanwei 已提交
20 21
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper">
    <select id="queryByDefineName" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
B
bao liang 已提交
22
        select pd.*,u.user_name,p.name as project_name,t.tenant_code,t.tenant_name,q.queue,q.queue_name
Q
qiaozhanwei 已提交
23 24 25 26 27
        from t_ds_process_definition pd
        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_tenant t ON t.id = u.tenant_id
        JOIN t_ds_queue q ON t.queue_id = q.id
B
bao liang 已提交
28 29 30
        WHERE p.id = #{projectId}
        and pd.name = #{processDefinitionName}
    </select>
Q
qiaozhanwei 已提交
31
    <select id="queryDefineListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
32 33 34
        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,
               sc.schedule_release_state, tu.user_name
Q
qiaozhanwei 已提交
35 36
        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
37
        left join t_ds_user tu on  td.user_id = tu.id
B
bao liang 已提交
38 39 40 41 42 43 44 45 46
        where td.project_id = #{projectId}
        <if test=" searchVal != null and searchVal != ''">
            and td.name like concat('%', #{searchVal}, '%')
        </if>
        <if test=" userId != 0">
            and td.user_id = #{userId}
        </if>
        order by sc.schedule_release_state desc,td.update_time desc
    </select>
47

Q
qiaozhanwei 已提交
48
    <select id="queryAllDefinitionList" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
B
bao liang 已提交
49
        select *
Q
qiaozhanwei 已提交
50
        from t_ds_process_definition
B
bao liang 已提交
51 52 53
        where project_id = #{projectId}
        order by create_time desc
    </select>
54 55 56 57 58
    <select id="queryDefinitionListByTenant" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
        select *
        from t_ds_process_definition
        where tenant_id = #{tenantId}
    </select>
Q
qiaozhanwei 已提交
59
    <select id="queryDefinitionListByIdList" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
B
bao liang 已提交
60
        select *
Q
qiaozhanwei 已提交
61
        from t_ds_process_definition
B
bao liang 已提交
62 63 64 65 66
        where id in
        <foreach collection="ids" index="index" item="i" open="(" separator="," close=")">
            #{i}
        </foreach>
    </select>
Q
qiaozhanwei 已提交
67
    <select id="countDefinitionGroupByUser" resultType="org.apache.dolphinscheduler.dao.entity.DefinitionGroupByUser">
B
bao liang 已提交
68
        SELECT td.user_id as user_id, tu.user_name as user_name, count(0) as count
Q
qiaozhanwei 已提交
69 70
        FROM t_ds_process_definition td
        JOIN t_ds_user tu on tu.id=td.user_id
B
bao liang 已提交
71
        where 1 = 1
72 73 74 75 76
        <if test="projectIds != null and projectIds.length != 0">
            and td.project_id in
            <foreach collection="projectIds" index="index" item="i" open="(" separator="," close=")">
                #{i}
            </foreach>
B
bao liang 已提交
77
        </if>
78
        group by td.user_id,tu.user_name
B
bao liang 已提交
79
    </select>
80 81 82
    <select id="queryByDefineId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
        SELECT
            pd.*, u.user_name,
B
bao liang 已提交
83
            p.name AS project_name
84 85 86 87 88 89 90 91
        FROM
            t_ds_process_definition pd,
            t_ds_user u,
            t_ds_project p
        WHERE
            pd.user_id = u.id AND pd.project_id = p.id
        AND pd.id = #{processDefineId}
    </select>
92 93 94 95 96 97 98


    <select id="listResources" resultType="java.util.HashMap">
        SELECT id,resource_ids
        FROM t_ds_process_definition
        WHERE release_state = 1 and resource_ids is not null and resource_ids != ''
    </select>
B
bao liang 已提交
99
</mapper>