Browse Source

[FIX][DAO-12277] change t_ds_fav_task column task_name to task_type and related code (#12276)

* change t_ds_fav_task column task_name to task_type and related code

* change task_name to task_type

* change FavTask taskName to taskType, taskType to taskCategory

Co-authored-by: labbomb <739955946@qq.com>
3.2.0-release
Tq 2 years ago committed by GitHub
parent
commit
4b4d0b92a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavTaskController.java
  2. 21
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/FavTaskDto.java
  3. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/FavTaskService.java
  4. 12
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/FavTaskServiceImpl.java
  5. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/FavTask.java
  6. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.java
  7. 4
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.xml
  8. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
  9. 4
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
  10. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
  11. 1
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.1.0_schema/mysql/dolphinscheduler_dml.sql
  12. 19
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.1.1_schema/mysql/dolphinscheduler_ddl.sql
  13. 16
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.1.1_schema/postgresql/dolphinscheduler_ddl.sql
  14. 8
      dolphinscheduler-ui/src/service/modules/dag-menu/index.ts
  15. 36
      dolphinscheduler-ui/src/views/projects/workflow/components/dag/dag-sidebar.tsx

12
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavTaskController.java

@ -82,13 +82,13 @@ public class FavTaskController extends BaseController {
* @return
*/
@Operation(summary = "deleteTaskType", description = "DELETE_TASK_TYPE")
@DeleteMapping(value = "/{taskName}")
@DeleteMapping(value = "/{taskType}")
@ResponseStatus(HttpStatus.OK)
@ApiException(DELETE_TASK_TYPE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result deleteFavTask(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable("taskName") String taskName) {
boolean b = favTaskService.deleteFavTask(loginUser, taskName);
@PathVariable("taskType") String taskType) {
boolean b = favTaskService.deleteFavTask(loginUser, taskType);
return success(b);
}
@ -99,13 +99,13 @@ public class FavTaskController extends BaseController {
* @return
*/
@Operation(summary = "addTaskType", description = "ADD_TASK_TYPE")
@PostMapping(value = "/{taskName}")
@PostMapping(value = "/{taskType}")
@ResponseStatus(HttpStatus.OK)
@ApiException(ADD_TASK_TYPE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result addFavTask(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable("taskName") String taskName) {
int i = favTaskService.addFavTask(loginUser, taskName);
@PathVariable("taskType") String taskType) {
int i = favTaskService.addFavTask(loginUser, taskType);
return success(i > 0);
}
}

21
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/FavTaskDto.java

@ -28,24 +28,11 @@ import lombok.Setter;
@AllArgsConstructor
public class FavTaskDto implements Cloneable {
private String taskName;
private boolean isCollection;
// task type name
private String taskType;
@Override
public boolean equals(Object obj) {
if (obj instanceof FavTaskDto) {
FavTaskDto favDto = (FavTaskDto) obj;
return this.taskName.equals(favDto.getTaskName());
}
return super.equals(obj);
}
@Override
public int hashCode() {
return super.hashCode();
}
private boolean isCollection;
// task category the task type belongs to
private String taskCategory;
@Override
public Object clone() throws CloneNotSupportedException {

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/FavTaskService.java

@ -26,7 +26,7 @@ public interface FavTaskService {
List<FavTaskDto> getFavTaskList(User loginUser);
boolean deleteFavTask(User loginUser, String taskName);
boolean deleteFavTask(User loginUser, String taskType);
int addFavTask(User loginUser, String taskName);
int addFavTask(User loginUser, String taskType);
}

12
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/FavTaskServiceImpl.java

@ -50,7 +50,7 @@ public class FavTaskServiceImpl extends BaseServiceImpl implements FavTaskServic
defaultTaskTypes.forEach(e -> {
try {
FavTaskDto clone = (FavTaskDto) e.clone();
if (userFavTaskTypes.contains(clone.getTaskName())) {
if (userFavTaskTypes.contains(clone.getTaskType())) {
clone.setCollection(true);
}
result.add(clone);
@ -62,13 +62,13 @@ public class FavTaskServiceImpl extends BaseServiceImpl implements FavTaskServic
}
@Override
public boolean deleteFavTask(User loginUser, String taskName) {
return favMapper.deleteUserFavTask(loginUser.getId(), taskName);
public boolean deleteFavTask(User loginUser, String taskType) {
return favMapper.deleteUserFavTask(loginUser.getId(), taskType);
}
@Override
public int addFavTask(User loginUser, String taskName) {
favMapper.deleteUserFavTask(loginUser.getId(), taskName);
return favMapper.insert(new FavTask(null, taskName, loginUser.getId()));
public int addFavTask(User loginUser, String taskType) {
favMapper.deleteUserFavTask(loginUser.getId(), taskType);
return favMapper.insert(new FavTask(null, taskType, loginUser.getId()));
}
}

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/FavTask.java

@ -35,7 +35,7 @@ public class FavTask {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String taskName;
private String taskType;
private int userId;
}

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.java

@ -32,5 +32,5 @@ public interface FavTaskMapper extends BaseMapper<FavTask> {
Set<String> getUserFavTaskTypes(@Param("userId") int userId);
boolean deleteUserFavTask(@Param("userId") int userId, @Param("taskName") String taskName);
boolean deleteUserFavTask(@Param("userId") int userId, @Param("taskType") String taskType);
}

4
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.xml

@ -20,7 +20,7 @@
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.FavTaskMapper">
<select id="getUserFavTaskTypes" resultType="string">
select task_name
select task_type
from t_ds_fav_task
where user_id = #{userId}
</select>
@ -29,6 +29,6 @@
delete
from t_ds_fav_task
where user_id = #{userId}
and task_name = #{taskName}
and task_type = #{taskType}
</delete>
</mapper>

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql

@ -2028,7 +2028,7 @@ DROP TABLE IF EXISTS t_ds_fav_task CASCADE;
CREATE TABLE t_ds_fav_task
(
id bigint(20) NOT NULL AUTO_INCREMENT,
task_name varchar(64) NOT NULL,
task_type varchar(64) NOT NULL,
user_id int NOT NULL,
PRIMARY KEY (id)
);

4
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql

@ -2000,8 +2000,8 @@ CREATE TABLE `t_ds_cluster`(
DROP TABLE IF EXISTS `t_ds_fav_task`;
CREATE TABLE `t_ds_fav_task`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'favorite task id',
`task_name` varchar(64) NOT NULL COMMENT 'favorite task name',
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
`task_type` varchar(64) NOT NULL COMMENT 'favorite task type name',
`user_id` int NOT NULL COMMENT 'user id',
PRIMARY KEY (`id`)
) ENGINE = InnoDB

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql

@ -1979,7 +1979,7 @@ DROP TABLE IF EXISTS t_ds_fav_task;
CREATE TABLE t_ds_fav_task
(
id serial NOT NULL,
task_name varchar(64) NOT NULL,
task_type varchar(64) NOT NULL,
user_id int NOT NULL,
PRIMARY KEY (id)
);

1
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.1.0_schema/mysql/dolphinscheduler_dml.sql

@ -14,4 +14,3 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

19
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.1.1_schema/mysql/dolphinscheduler_ddl.sql

@ -14,6 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
--- rename t_ds_fav_task task_name to task_type
drop procedure if exists modify_t_ds_fav_task_task_name;
delimiter d//
CREATE PROCEDURE modify_t_ds_fav_task_task_name()
BEGIN
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='t_ds_fav_task'
AND TABLE_SCHEMA=(SELECT DATABASE())
AND COLUMN_NAME='task_name')
THEN
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
ALTER TABLE `t_ds_fav_task` change `task_name` `task_type` varchar(64) NOT NULL COMMENT 'favorite task type name';
END IF;
END;
d//
delimiter ;
CALL modify_t_ds_fav_task_task_name;
DROP PROCEDURE modify_t_ds_fav_task_task_name;
-- alter table `t_ds_worker_group` add `description` varchar(256);
drop procedure if exists add_column_safety;
delimiter d//

16
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.1.1_schema/postgresql/dolphinscheduler_ddl.sql

@ -14,5 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
--- rename t_ds_fav_task task_name to task_type
DO $$
DECLARE
v_schema varchar;
BEGIN
v_schema =current_schema();
IF EXISTS(SELECT *
FROM information_schema.columns
WHERE table_name='t_ds_fav_task' and column_name='task_name')
then
EXECUTE 'ALTER TABLE IF EXISTS ' || quote_ident(v_schema) ||'.t_ds_fav_task RENAME COLUMN task_name TO task_type';
END IF;
END $$;
--- add column
ALTER TABLE t_ds_task_group alter COLUMN description type varchar(255);

8
dolphinscheduler-ui/src/service/modules/dag-menu/index.ts

@ -24,16 +24,16 @@ export function getDagMenu(): any {
})
}
export function Collection(taskName: string): any {
export function Collection(taskType: string): any {
return axios({
url: `/favourite/${taskName}`,
url: `/favourite/${taskType}`,
method: 'post'
})
}
export function CancelCollection(taskName: string): any {
export function CancelCollection(taskType: string): any {
return axios({
url: `/favourite/${taskName}`,
url: `/favourite/${taskType}`,
method: 'delete'
})
}

36
dolphinscheduler-ui/src/views/projects/workflow/components/dag/dag-sidebar.tsx

@ -51,29 +51,29 @@ export default defineComponent({
return {
...item,
starHover: false,
type: item.taskName
type: item.taskType
}
})
variables.universal = variables.dataList.filter(
(item: any) => item.taskType === 'Universal'
(item: any) => item.taskCategory === 'Universal'
)
variables.cloud = variables.dataList.filter(
(item: any) => item.taskType === 'Cloud'
(item: any) => item.taskCategory === 'Cloud'
)
variables.logic = variables.dataList.filter(
(item: any) => item.taskType === 'Logic'
(item: any) => item.taskCategory === 'Logic'
)
variables.di = variables.dataList.filter(
(item: any) => item.taskType === 'DataIntegration'
(item: any) => item.taskCategory === 'DataIntegration'
)
variables.dq = variables.dataList.filter(
(item: any) => item.taskType === 'DataQuality'
(item: any) => item.taskCategory === 'DataQuality'
)
variables.ml = variables.dataList.filter(
(item: any) => item.taskType === 'MachineLearning'
(item: any) => item.taskCategory === 'MachineLearning'
)
variables.other = variables.dataList.filter(
(item: any) => item.taskType === 'Other'
(item: any) => item.taskCategory === 'Other'
)
variables.fav = variables.dataList.filter(
(item: any) => item.collection === true
@ -83,10 +83,10 @@ export default defineComponent({
const handleCollection = (item: any) => {
item.collection
? CancelCollection(item.taskName).then(() => {
? CancelCollection(item.taskType).then(() => {
handleDagMenu()
})
: Collection(item.taskName).then(() => {
: Collection(item.taskType).then(() => {
handleDagMenu()
})
item.collection = !item.collection
@ -120,7 +120,7 @@ export default defineComponent({
styles['icon-' + task.type.toLocaleLowerCase()]
]}
/>
<span>{task.taskName}</span>
<span>{task.taskType}</span>
<div
class={styles.stars}
onMouseenter={() => {
@ -173,7 +173,7 @@ export default defineComponent({
styles['icon-' + task.type.toLocaleLowerCase()]
]}
/>
<span>{task.taskName}</span>
<span>{task.taskType}</span>
<div
class={styles.stars}
onMouseenter={() => {
@ -226,7 +226,7 @@ export default defineComponent({
styles['icon-' + task.type.toLocaleLowerCase()]
]}
/>
<span>{task.taskName}</span>
<span>{task.taskType}</span>
<div
class={styles.stars}
onMouseenter={() => {
@ -279,7 +279,7 @@ export default defineComponent({
styles['icon-' + task.type.toLocaleLowerCase()]
]}
/>
<span>{task.taskName}</span>
<span>{task.taskType}</span>
<div
class={styles.stars}
onMouseenter={() => {
@ -332,7 +332,7 @@ export default defineComponent({
styles['icon-' + task.type.toLocaleLowerCase()]
]}
/>
<span>{task.taskName}</span>
<span>{task.taskType}</span>
<div
class={styles.stars}
onMouseenter={() => {
@ -385,7 +385,7 @@ export default defineComponent({
styles['icon-' + task.type.toLocaleLowerCase()]
]}
/>
<span>{task.taskName}</span>
<span>{task.taskType}</span>
<div
class={styles.stars}
onMouseenter={() => {
@ -438,7 +438,7 @@ export default defineComponent({
styles['icon-' + task.type.toLocaleLowerCase()]
]}
/>
<span>{task.taskName}</span>
<span>{task.taskType}</span>
<div
class={styles.stars}
onMouseenter={() => {
@ -491,7 +491,7 @@ export default defineComponent({
styles['icon-' + task.type.toLocaleLowerCase()]
]}
/>
<span>{task.taskName}</span>
<span>{task.taskType}</span>
<div
class={styles.stars}
onMouseenter={() => {

Loading…
Cancel
Save