ProcessDefinitionMapper.xml 4.4 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
        SELECT td.*,sc.schedule_release_state,tu.user_name
Q
qiaozhanwei 已提交
33 34
        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
35
        left join t_ds_user tu on  td.user_id = tu.id
B
bao liang 已提交
36 37 38 39 40 41 42 43 44
        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>
45

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


    <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 已提交
97
</mapper>