Browse Source
* task and relation entity * task and relation entity * task and relation entity * task and relation entity * task and relation entity * add timeout flag * task mapper and postgre * task mapper and postgre * 'postgre' Co-authored-by: JinyLeeChina <297062848@qq.com>pull/3/MERGE
JinyLeeChina
4 years ago
committed by
GitHub
8 changed files with 463 additions and 11 deletions
@ -0,0 +1,50 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* task definition log mapper interface
|
||||
*/ |
||||
public interface TaskDefinitionLogMapper extends BaseMapper<TaskDefinitionLog> { |
||||
|
||||
/** |
||||
* query task definition log by name |
||||
* |
||||
* @param projectCode projectCode |
||||
* @param name name |
||||
* @return task definition log list |
||||
*/ |
||||
List<TaskDefinitionLog> queryByDefinitionName(@Param("projectCode") Long projectCode, |
||||
@Param("taskDefinitionName") String name); |
||||
|
||||
/** |
||||
* query task definition log list |
||||
* |
||||
* @param taskDefinitionCode taskDefinitionCode |
||||
* @return task definition log list |
||||
*/ |
||||
List<TaskDefinitionLog> queryByDefinitionCode(@Param("taskDefinitionCode") long taskDefinitionCode); |
||||
} |
@ -0,0 +1,103 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.DefinitionGroupByUser; |
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
||||
|
||||
import org.apache.ibatis.annotations.MapKey; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* task definition mapper interface
|
||||
*/ |
||||
public interface TaskDefinitionMapper extends BaseMapper<TaskDefinition> { |
||||
|
||||
/** |
||||
* verify task definition by name |
||||
* |
||||
* @param projectCode projectCode |
||||
* @param name name |
||||
* @return task definition |
||||
*/ |
||||
TaskDefinition verifyByDefineName(@Param("projectCode") Long projectCode, |
||||
@Param("taskDefinitionName") String name); |
||||
|
||||
/** |
||||
* query task definition by name |
||||
* |
||||
* @param projectCode projectCode |
||||
* @param name name |
||||
* @return task definition |
||||
*/ |
||||
TaskDefinition queryByDefinitionName(@Param("projectCode") Long projectCode, |
||||
@Param("taskDefinitionName") String name); |
||||
|
||||
/** |
||||
* query task definition by id |
||||
* |
||||
* @param taskDefinitionId taskDefinitionId |
||||
* @return task definition |
||||
*/ |
||||
TaskDefinition queryByDefinitionId(@Param("taskDefinitionId") int taskDefinitionId); |
||||
|
||||
/** |
||||
* query all task definition list |
||||
* |
||||
* @param projectCode projectCode |
||||
* @return task definition list |
||||
*/ |
||||
List<TaskDefinition> queryAllDefinitionList(@Param("projectCode") Long projectCode); |
||||
|
||||
/** |
||||
* query task definition by ids |
||||
* |
||||
* @param ids ids |
||||
* @return task definition list |
||||
*/ |
||||
List<TaskDefinition> queryDefinitionListByIdList(@Param("ids") Integer[] ids); |
||||
|
||||
/** |
||||
* count task definition group by user |
||||
* |
||||
* @param projectCodes projectCodes |
||||
* @return task definition list |
||||
*/ |
||||
List<DefinitionGroupByUser> countDefinitionGroupByUser(@Param("projectCodes") Long[] projectCodes); |
||||
|
||||
/** |
||||
* list all resource ids |
||||
* |
||||
* @return task ids list |
||||
*/ |
||||
@MapKey("id") |
||||
List<Map<String, Object>> listResources(); |
||||
|
||||
/** |
||||
* list all resource ids by user id |
||||
* |
||||
* @return resource ids list |
||||
*/ |
||||
@MapKey("id") |
||||
List<Map<String, Object>> listResourcesByUser(@Param("userId") Integer userId); |
||||
} |
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
|
||||
<!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.TaskDefinitionLogMapper"> |
||||
<select id="queryByDefinitionName" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog"> |
||||
select td.id, td.code, td.name, td.version, td.description, td.project_code, td.user_id, td.task_type, td.task_params, |
||||
td.flag, td.task_priority, td.worker_group, td.fail_retry_times, td.fail_retry_interval, td.timeout_flag, |
||||
td.timeout_notify_strategy, td.timeout, td.resource_ids, td.operator,td.operate_time, td.create_time, td.update_time, |
||||
u.user_name,p.name as project_name |
||||
from t_ds_task_definition_log td |
||||
JOIN t_ds_user u ON td.user_id = u.id |
||||
JOIN t_ds_project p ON td.project_code = p.code |
||||
WHERE p.code = #{projectCode} |
||||
and td.name = #{taskDefinitionName} |
||||
</select> |
||||
<select id="queryByDefinitionCode" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog"> |
||||
select td.id, td.code, td.name, td.version, td.description, td.project_code, td.user_id, td.task_type, td.task_params, |
||||
td.flag, td.task_priority, td.worker_group, td.fail_retry_times, td.fail_retry_interval, td.timeout_flag, |
||||
td.timeout_notify_strategy, td.timeout, td.resource_ids, td.operator,td.operate_time, td.create_time, td.update_time, |
||||
u.user_name,p.name as project_name |
||||
from t_ds_task_definition_log td |
||||
JOIN t_ds_user u ON td.user_id = u.id |
||||
JOIN t_ds_project p ON td.project_code = p.code |
||||
WHERE td.code = #{taskDefinitionCode} |
||||
</select> |
||||
</mapper> |
@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
|
||||
<!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.TaskDefinitionMapper"> |
||||
<sql id="baseSql"> |
||||
id, code, `name`, version, description, project_code, user_id, task_type, task_params, flag, task_priority, |
||||
worker_group, fail_retry_times, fail_retry_interval, timeout_flag, timeout_notify_strategy, timeout, |
||||
resource_ids, create_time, update_time |
||||
</sql> |
||||
<select id="verifyByDefineName" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinition"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_task_definition |
||||
WHERE projectCode = #{projectCode} |
||||
and `name` = #{taskDefinitionName} |
||||
</select> |
||||
<select id="queryByDefinitionName" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinition"> |
||||
select td.id, td.code, td.name, td.version, td.description, td.project_code, td.user_id, td.task_type, td.task_params, |
||||
td.flag, td.task_priority, td.worker_group, td.fail_retry_times, td.fail_retry_interval, td.timeout_flag, |
||||
td.timeout_notify_strategy, td.timeout, td.resource_ids, td.create_time, td.update_time, u.user_name,p.name as project_name |
||||
from t_ds_task_definition td |
||||
JOIN t_ds_user u ON td.user_id = u.id |
||||
JOIN t_ds_project p ON td.project_code = p.code |
||||
WHERE p.code = #{projectCode} |
||||
and td.name = #{taskDefinitionName} |
||||
</select> |
||||
|
||||
<select id="queryAllDefinitionList" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinition"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_task_definition |
||||
where project_code = #{projectCode} |
||||
order by create_time desc |
||||
</select> |
||||
|
||||
<select id="queryDefinitionListByIdList" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinition"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_task_definition |
||||
where id in |
||||
<foreach collection="ids" index="index" item="i" open="(" separator="," close=")"> |
||||
#{i} |
||||
</foreach> |
||||
</select> |
||||
|
||||
<select id="countDefinitionGroupByUser" resultType="org.apache.dolphinscheduler.dao.entity.DefinitionGroupByUser"> |
||||
SELECT td.user_id as user_id, tu.user_name as user_name, count(0) as count |
||||
FROM t_ds_task_definition td |
||||
JOIN t_ds_user tu on tu.id=td.user_id |
||||
where 1 = 1 |
||||
<if test="projectCodes != null and projectCodes.length != 0"> |
||||
and td.project_id in |
||||
<foreach collection="projectCodes" index="index" item="i" open="(" separator="," close=")"> |
||||
#{i} |
||||
</foreach> |
||||
</if> |
||||
group by td.user_id,tu.user_name |
||||
</select> |
||||
<select id="queryByDefinitionId" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinition"> |
||||
select td.id, td.code, td.name, td.version, td.description, td.project_code, td.user_id, td.task_type, td.task_params, |
||||
td.flag, td.task_priority, td.worker_group, td.fail_retry_times, td.fail_retry_interval, td.timeout_flag, |
||||
td.timeout_notify_strategy, td.timeout, td.resource_ids, td.create_time, td.update_time, u.user_name,p.name as project_name |
||||
from t_ds_task_definition td |
||||
JOIN t_ds_user u ON td.user_id = u.id |
||||
JOIN t_ds_project p ON td.project_code = p.code |
||||
WHERE td.id = #{taskDefinitionId} |
||||
</select> |
||||
<select id="listResources" resultType="java.util.HashMap"> |
||||
SELECT id,resource_ids |
||||
FROM t_ds_task_definition |
||||
WHERE resource_ids is not null and resource_ids != '' |
||||
</select> |
||||
|
||||
<select id="listResourcesByUser" resultType="java.util.HashMap"> |
||||
SELECT id,resource_ids |
||||
FROM t_ds_task_definition |
||||
WHERE user_id = #{userId} resource_ids is not null and resource_ids != '' |
||||
</select> |
||||
</mapper> |
Loading…
Reference in new issue