|
@@ -33,23 +33,23 @@ public class SysDeptRelationHandler extends AbstractCanalDbHandler {
|
|
|
String ancestor = "";
|
|
|
String descendant = "";
|
|
|
boolean ignoreDeptId = false;
|
|
|
- for(CanalEntry.Column column : columns){
|
|
|
- if(column.getName().equals("ancestor")){
|
|
|
+ for (CanalEntry.Column column : columns) {
|
|
|
+ if (column.getName().equals("ancestor")) {
|
|
|
ancestor = column.getValue();
|
|
|
|
|
|
- if(ignoreDeptId(dataSourceEnum, ancestor, column)){
|
|
|
+ if (ignoreDeptId(dataSourceEnum, ancestor, column)) {
|
|
|
ignoreDeptId = true;
|
|
|
}
|
|
|
- }else if(column.getName().equals("descendant")){
|
|
|
+ } else if (column.getName().equals("descendant")) {
|
|
|
descendant = column.getValue();
|
|
|
|
|
|
- if(ignoreDeptId(dataSourceEnum, descendant, column)){
|
|
|
+ if (ignoreDeptId(dataSourceEnum, descendant, column)) {
|
|
|
ignoreDeptId = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(ignoreDeptId){
|
|
|
+ if (ignoreDeptId) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -58,61 +58,31 @@ public class SysDeptRelationHandler extends AbstractCanalDbHandler {
|
|
|
.eq(SysDeptRelation::getDescendant, descendant)
|
|
|
.eq(SysDeptRelation::getDbSourceId, valSource);
|
|
|
sysDeptRelationService.delete(queryWrapper);
|
|
|
- } else if (eventType == CanalEntry.EventType.INSERT) {
|
|
|
- List<CanalEntry.Column> columns = rowData.getAfterColumnsList();
|
|
|
- String jsonStr = columnsToJson(columns);
|
|
|
-
|
|
|
- String ancestor = "";
|
|
|
- String descendant = "";
|
|
|
- boolean ignoreDeptId = false;
|
|
|
- for(CanalEntry.Column column : columns){
|
|
|
- if(column.getName().equals("ancestor")){
|
|
|
- ancestor = column.getValue();
|
|
|
-
|
|
|
- if(ignoreDeptId(dataSourceEnum, ancestor, column)){
|
|
|
- ignoreDeptId = true;
|
|
|
- }
|
|
|
- }else if(column.getName().equals("descendant")){
|
|
|
- descendant = column.getValue();
|
|
|
-
|
|
|
- if(ignoreDeptId(dataSourceEnum, descendant, column)){
|
|
|
- ignoreDeptId = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(ignoreDeptId){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- SysDeptRelation sysDeptRelation = JSON.parseObject(jsonStr, SysDeptRelation.class);
|
|
|
- sysDeptRelation.setDbSourceId(valSource);
|
|
|
-
|
|
|
- sysDeptRelationService.save(sysDeptRelation);
|
|
|
- } else if (eventType == CanalEntry.EventType.UPDATE) {
|
|
|
+ } else if (eventType == CanalEntry.EventType.UPDATE
|
|
|
+ || eventType == CanalEntry.EventType.INSERT) {
|
|
|
List<CanalEntry.Column> afterColumns = rowData.getAfterColumnsList();
|
|
|
String jsonStr = columnsToJson(afterColumns);
|
|
|
|
|
|
String ancestor = "";
|
|
|
String descendant = "";
|
|
|
boolean ignoreDeptId = false;
|
|
|
- for(CanalEntry.Column column : afterColumns){
|
|
|
- if(column.getName().equals("ancestor")){
|
|
|
+ for (CanalEntry.Column column : afterColumns) {
|
|
|
+ if (column.getName().equals("ancestor")) {
|
|
|
ancestor = column.getValue();
|
|
|
|
|
|
- if(ignoreDeptId(dataSourceEnum, ancestor, column)){
|
|
|
+ if (ignoreDeptId(dataSourceEnum, ancestor, column)) {
|
|
|
ignoreDeptId = true;
|
|
|
}
|
|
|
- }else if(column.getName().equals("descendant")){
|
|
|
+ } else if (column.getName().equals("descendant")) {
|
|
|
descendant = column.getValue();
|
|
|
|
|
|
- if(ignoreDeptId(dataSourceEnum, descendant, column)){
|
|
|
+ if (ignoreDeptId(dataSourceEnum, descendant, column)) {
|
|
|
ignoreDeptId = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(ignoreDeptId){
|
|
|
+ if (ignoreDeptId) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -124,9 +94,9 @@ public class SysDeptRelationHandler extends AbstractCanalDbHandler {
|
|
|
SysDeptRelation sysDeptRelation = JSON.parseObject(jsonStr, SysDeptRelation.class);
|
|
|
sysDeptRelation.setDbSourceId(valSource);
|
|
|
|
|
|
- if(!sysDeptRelationService.exists(queryWrapper)){
|
|
|
+ if (!sysDeptRelationService.exists(queryWrapper)) {
|
|
|
sysDeptRelationService.save(sysDeptRelation);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
sysDeptRelationService.update(sysDeptRelation, queryWrapper);
|
|
|
}
|
|
|
}
|