Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
e2070b74
Unverified
Commit
e2070b74
authored
May 12, 2024
by
suxinshuo
Committed by
GitHub
May 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix-3450][admin] Fix the issue of copying tasks with create time (#3472)
Co-authored-by:
suxinshuo
<
suxinshuo@itiger.com
>
parent
38049f46
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
19 deletions
+99
-19
Task.java
dinky-admin/src/main/java/org/dinky/data/model/Task.java
+1
-0
DateMetaObjectHandler.java
...java/org/dinky/mybatis/handler/DateMetaObjectHandler.java
+6
-1
MybatisPlusFillProperties.java
...g/dinky/mybatis/properties/MybatisPlusFillProperties.java
+2
-0
CatalogueFactory.java
...org/dinky/service/catalogue/factory/CatalogueFactory.java
+83
-0
CatalogueServiceImpl.java
...rg/dinky/service/catalogue/impl/CatalogueServiceImpl.java
+7
-18
No files found.
dinky-admin/src/main/java/org/dinky/data/model/Task.java
View file @
e2070b74
...
@@ -55,6 +55,7 @@ public class Task extends SuperEntity<Task> {
...
@@ -55,6 +55,7 @@ public class Task extends SuperEntity<Task> {
@ApiModelProperty
(
value
=
"Dialect"
,
dataType
=
"String"
,
notes
=
"Dialect for the task"
)
@ApiModelProperty
(
value
=
"Dialect"
,
dataType
=
"String"
,
notes
=
"Dialect for the task"
)
private
String
dialect
;
private
String
dialect
;
@TableField
(
fill
=
FieldFill
.
INSERT
)
@ApiModelProperty
(
@ApiModelProperty
(
value
=
"Tenant ID"
,
value
=
"Tenant ID"
,
dataType
=
"Integer"
,
dataType
=
"Integer"
,
...
...
dinky-admin/src/main/java/org/dinky/mybatis/handler/DateMetaObjectHandler.java
View file @
e2070b74
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
org
.
dinky
.
mybatis
.
handler
;
package
org
.
dinky
.
mybatis
.
handler
;
import
org.dinky.context.TenantContextHolder
;
import
org.dinky.mybatis.properties.MybatisPlusFillProperties
;
import
org.dinky.mybatis.properties.MybatisPlusFillProperties
;
import
org.apache.ibatis.reflection.MetaObject
;
import
org.apache.ibatis.reflection.MetaObject
;
...
@@ -57,7 +58,6 @@ public class DateMetaObjectHandler implements MetaObjectHandler {
...
@@ -57,7 +58,6 @@ public class DateMetaObjectHandler implements MetaObjectHandler {
@Override
@Override
public
void
insertFill
(
MetaObject
metaObject
)
{
public
void
insertFill
(
MetaObject
metaObject
)
{
Object
createTime
=
getFieldValByName
(
mybatisPlusFillProperties
.
getCreateTimeField
(),
metaObject
);
Object
createTime
=
getFieldValByName
(
mybatisPlusFillProperties
.
getCreateTimeField
(),
metaObject
);
Object
updateTime
=
getFieldValByName
(
mybatisPlusFillProperties
.
getUpdateTimeField
(),
metaObject
);
Object
updateTime
=
getFieldValByName
(
mybatisPlusFillProperties
.
getUpdateTimeField
(),
metaObject
);
if
(
createTime
==
null
)
{
if
(
createTime
==
null
)
{
...
@@ -83,6 +83,7 @@ public class DateMetaObjectHandler implements MetaObjectHandler {
...
@@ -83,6 +83,7 @@ public class DateMetaObjectHandler implements MetaObjectHandler {
Object
creator
=
getFieldValByName
(
mybatisPlusFillProperties
.
getCreatorField
(),
metaObject
);
Object
creator
=
getFieldValByName
(
mybatisPlusFillProperties
.
getCreatorField
(),
metaObject
);
Object
updater
=
getFieldValByName
(
mybatisPlusFillProperties
.
getUpdaterField
(),
metaObject
);
Object
updater
=
getFieldValByName
(
mybatisPlusFillProperties
.
getUpdaterField
(),
metaObject
);
Object
operator
=
getFieldValByName
(
mybatisPlusFillProperties
.
getOperatorField
(),
metaObject
);
Object
operator
=
getFieldValByName
(
mybatisPlusFillProperties
.
getOperatorField
(),
metaObject
);
Object
tenantId
=
getFieldValByName
(
mybatisPlusFillProperties
.
getTenantIdField
(),
metaObject
);
if
(
creator
==
null
)
{
if
(
creator
==
null
)
{
setFieldValByName
(
mybatisPlusFillProperties
.
getCreatorField
(),
userId
,
metaObject
);
setFieldValByName
(
mybatisPlusFillProperties
.
getCreatorField
(),
userId
,
metaObject
);
...
@@ -93,6 +94,10 @@ public class DateMetaObjectHandler implements MetaObjectHandler {
...
@@ -93,6 +94,10 @@ public class DateMetaObjectHandler implements MetaObjectHandler {
if
(
operator
==
null
)
{
if
(
operator
==
null
)
{
setFieldValByName
(
mybatisPlusFillProperties
.
getOperatorField
(),
userId
,
metaObject
);
setFieldValByName
(
mybatisPlusFillProperties
.
getOperatorField
(),
userId
,
metaObject
);
}
}
if
(
tenantId
==
null
)
{
int
loginTenantId
=
(
Integer
)
TenantContextHolder
.
get
();
setFieldValByName
(
mybatisPlusFillProperties
.
getTenantIdField
(),
loginTenantId
,
metaObject
);
}
}
}
@Override
@Override
...
...
dinky-admin/src/main/java/org/dinky/mybatis/properties/MybatisPlusFillProperties.java
View file @
e2070b74
...
@@ -49,4 +49,6 @@ public class MybatisPlusFillProperties {
...
@@ -49,4 +49,6 @@ public class MybatisPlusFillProperties {
private
String
updaterField
=
"updater"
;
private
String
updaterField
=
"updater"
;
private
String
operatorField
=
"operator"
;
private
String
operatorField
=
"operator"
;
private
String
tenantIdField
=
"tenantId"
;
}
}
dinky-admin/src/main/java/org/dinky/service/catalogue/factory/CatalogueFactory.java
0 → 100644
View file @
e2070b74
/*
*
* 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
.
dinky
.
service
.
catalogue
.
factory
;
import
org.dinky.data.enums.JobLifeCycle
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.data.model.Task
;
import
java.util.Objects
;
import
org.springframework.stereotype.Component
;
import
cn.hutool.core.bean.BeanUtil
;
import
lombok.extern.slf4j.Slf4j
;
/**
* CatalogueFactory
*
* @since 2024/5/8 19:12
*/
@Slf4j
@Component
public
class
CatalogueFactory
{
public
Task
getNewTask
(
Task
oldTask
,
String
newTaskName
)
{
if
(
Objects
.
isNull
(
oldTask
))
{
return
null
;
}
Task
newTask
=
new
Task
();
BeanUtil
.
copyProperties
(
oldTask
,
newTask
);
newTask
.
setId
(
null
);
newTask
.
setJobInstanceId
(
null
);
newTask
.
setName
(
newTaskName
);
// set tasks to be in development status by default
newTask
.
setStep
(
JobLifeCycle
.
DEVELOP
.
getValue
());
newTask
.
setVersionId
(
null
);
// mybatis auto fill
newTask
.
setCreateTime
(
null
);
newTask
.
setUpdateTime
(
null
);
newTask
.
setCreator
(
null
);
newTask
.
setUpdater
(
null
);
newTask
.
setOperator
(
null
);
newTask
.
setTenantId
(
null
);
return
newTask
;
}
public
Catalogue
getNewCatalogue
(
Catalogue
paramCatalogue
,
Catalogue
oldCatalogue
,
Task
newTask
)
{
Catalogue
newCatalogue
=
new
Catalogue
();
BeanUtil
.
copyProperties
(
paramCatalogue
,
newCatalogue
);
newCatalogue
.
setName
(
newTask
.
getName
());
newCatalogue
.
setIsLeaf
(
oldCatalogue
.
getIsLeaf
());
newCatalogue
.
setTaskId
(
newTask
.
getId
());
newCatalogue
.
setType
(
oldCatalogue
.
getType
());
newCatalogue
.
setParentId
(
oldCatalogue
.
getParentId
());
newCatalogue
.
setId
(
null
);
// mybatis auto fill
newCatalogue
.
setCreateTime
(
null
);
newCatalogue
.
setUpdateTime
(
null
);
newCatalogue
.
setCreator
(
null
);
newCatalogue
.
setUpdater
(
null
);
newCatalogue
.
setTenantId
(
null
);
return
newCatalogue
;
}
}
dinky-admin/src/main/java/org/dinky/service/catalogue/impl/CatalogueServiceImpl.java
View file @
e2070b74
...
@@ -49,6 +49,7 @@ import org.dinky.service.JobInstanceService;
...
@@ -49,6 +49,7 @@ import org.dinky.service.JobInstanceService;
import
org.dinky.service.MonitorService
;
import
org.dinky.service.MonitorService
;
import
org.dinky.service.TaskService
;
import
org.dinky.service.TaskService
;
import
org.dinky.service.catalogue.CatalogueService
;
import
org.dinky.service.catalogue.CatalogueService
;
import
org.dinky.service.catalogue.factory.CatalogueFactory
;
import
org.dinky.service.catalogue.factory.CatalogueTreeSortFactory
;
import
org.dinky.service.catalogue.factory.CatalogueTreeSortFactory
;
import
org.dinky.service.catalogue.strategy.CatalogueTreeSortStrategy
;
import
org.dinky.service.catalogue.strategy.CatalogueTreeSortStrategy
;
...
@@ -101,6 +102,8 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
...
@@ -101,6 +102,8 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
private
final
CatalogueTreeSortFactory
catalogueTreeSortFactory
;
private
final
CatalogueTreeSortFactory
catalogueTreeSortFactory
;
private
final
CatalogueFactory
catalogueFactory
;
/**
/**
* @return
* @return
*/
*/
...
@@ -394,29 +397,15 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
...
@@ -394,29 +397,15 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
}
}
// 查询作业名称
// 查询作业名称
int
size
=
taskService
.
queryAllSizeByName
(
oldTask
.
getName
());
int
size
=
taskService
.
queryAllSizeByName
(
oldTask
.
getName
());
Task
newTask
=
new
Task
();
BeanUtil
.
copyProperties
(
oldTask
,
newTask
);
newTask
.
setId
(
null
);
newTask
.
setJobInstanceId
(
null
);
newTask
.
setType
(
oldTask
.
getType
());
// 设置复制后的作业名称为:原名称+自增序列
// 设置复制后的作业名称为:原名称+自增序列
size
=
size
+
1
;
String
newTaskName
=
oldTask
.
getName
()
+
"-"
+
(++
size
);
newTask
.
setName
(
oldTask
.
getName
()
+
"-"
+
size
);
Task
newTask
=
catalogueFactory
.
getNewTask
(
oldTask
,
newTaskName
);
newTask
.
setStep
(
JobLifeCycle
.
DEVELOP
.
getValue
());
taskService
.
save
(
newTask
);
taskService
.
save
(
newTask
);
Catalogue
singleCatalogue
=
Catalogue
singleCatalogue
=
this
.
getOne
(
new
LambdaQueryWrapper
<
Catalogue
>().
eq
(
Catalogue:
:
getTaskId
,
catalogue
.
getTaskId
()));
this
.
getOne
(
new
LambdaQueryWrapper
<
Catalogue
>().
eq
(
Catalogue:
:
getTaskId
,
catalogue
.
getTaskId
()));
Catalogue
newCatalogue
=
catalogueFactory
.
getNewCatalogue
(
catalogue
,
singleCatalogue
,
newTask
);
catalogue
.
setName
(
newTask
.
getName
());
return
this
.
save
(
newCatalogue
);
catalogue
.
setIsLeaf
(
singleCatalogue
.
getIsLeaf
());
catalogue
.
setTaskId
(
newTask
.
getId
());
catalogue
.
setType
(
singleCatalogue
.
getType
());
catalogue
.
setParentId
(
singleCatalogue
.
getParentId
());
catalogue
.
setId
(
null
);
return
this
.
save
(
catalogue
);
}
}
@Override
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment