Browse Source
* commit 'f8223844d316e4cf9c88e03ee563a9e72f5542c0': REPORT-80695 模板全局级别查找替换二期 为了通过插件校验,增加一下注释 REPORT-80695 模板全局级别查找替换二期 校验 REPORT-80690 增加注释 REPORT-83313 数据脱敏-点击“数据脱敏设置”后预览页面没有消失 【问题原因】原本做的是"数据脱敏设置"面板是预览面板为parent的另一个dialog,没按照产品文档里做 【改动方案】修改下,打开脱敏设置面板的同时,预览页面消失 【review建议】 REPORT-83624 模板查找替换提示语句key合并 REPORT-80690 修改传入格式数据 REPORT-80690 修改传入格式数据 REPORT-80690 添加适配适配埋点feature/x
superman
2 years ago
13 changed files with 238 additions and 19 deletions
@ -0,0 +1,135 @@
|
||||
package com.fr.design.actions.replace.action; |
||||
|
||||
import com.fr.design.actions.replace.info.Info; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 校验JS、公式、控件、组件 |
||||
* 比较用户的所有对应类别的改动,不论是否选中要替换,只要整体类别改动过就算模板内容改动过 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @version 11.0 |
||||
* created by Destiny.Lin on 2022-11-03 |
||||
*/ |
||||
public enum ITChecker { |
||||
/** |
||||
* 控件 |
||||
*/ |
||||
WIDGET_CHECK_TAG(Toolkit.i18nText("Fine-Design_Basic_Widget")), |
||||
/** |
||||
* 公式 |
||||
*/ |
||||
FORMULA_CHECK_TAG(Toolkit.i18nText("Fine-Design_Basic_Formula")), |
||||
/** |
||||
* JS |
||||
*/ |
||||
JS_CHECK_TAG(Toolkit.i18nText("Fine-Design_Replace_JS")), |
||||
/** |
||||
* 组件 |
||||
*/ |
||||
COMPONENT_CHECK_TAG(Toolkit.i18nText("Fine-Design_Replace_Component")) |
||||
; |
||||
|
||||
|
||||
String name; |
||||
|
||||
ITChecker(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 匹配 |
||||
* |
||||
* @param name 对应的检查类型 |
||||
* @return 对应的检查checker |
||||
*/ |
||||
@Nullable |
||||
public static ITChecker match(String name) { |
||||
ITChecker[] values = ITChecker.values(); |
||||
for (ITChecker value : values) { |
||||
if (value.name.equals(name)) { |
||||
return value; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static List<? extends Info> checkList = new ArrayList<>(); |
||||
public static Map<String, Integer> appearTimesMap = new HashMap<>(); |
||||
|
||||
|
||||
/** |
||||
* 更新对应的check列表 |
||||
* |
||||
* @param list 查找后的searchList |
||||
*/ |
||||
public static void updateCheckInfo(List<? extends Info> list) { |
||||
checkList = list; |
||||
updateCheckMapFromList(list); |
||||
} |
||||
|
||||
/** |
||||
* 根据列表来更新对应元素的匹配Map |
||||
* |
||||
* @param list 更新后的checkList |
||||
*/ |
||||
private static void updateCheckMapFromList(List<? extends Info> list) { |
||||
appearTimesMap.clear(); |
||||
for (Info info : list) { |
||||
String showStr = info.getContent().getOldShowStr(); |
||||
if (appearTimesMap.containsKey(showStr)) { |
||||
//如果已经存过了就个数+1
|
||||
appearTimesMap.put(showStr, appearTimesMap.get(showStr) + 1); |
||||
} else { |
||||
//没有的话就把个数初始化为1个
|
||||
appearTimesMap.put(showStr, 1); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 判断是否修改过 |
||||
* |
||||
* @param list 重新获取的当前模板最新的list |
||||
* @return 修改过返回true |
||||
*/ |
||||
public boolean isChanged(List<? extends Info> list) { |
||||
if (list.size() != checkList.size()) { |
||||
//如果总的数据的数量变了,就说明肯定修改过,没必要再进行下一步
|
||||
return true; |
||||
} |
||||
return isChangedCheckByMap(list); |
||||
} |
||||
|
||||
/** |
||||
* 通过检查Map来比较是否修改过 |
||||
* |
||||
* @param list 传入的用于比较的list |
||||
* @return 修改过则返回true |
||||
*/ |
||||
private boolean isChangedCheckByMap(List<? extends Info> list) { |
||||
for (Info info : list) { |
||||
String showStr = info.getContent().getOldShowStr(); |
||||
if (appearTimesMap.containsKey(showStr)) { |
||||
//如果map中存在对应的值,就抵消,个数-1
|
||||
appearTimesMap.put(showStr, appearTimesMap.get(showStr) - 1); |
||||
if (appearTimesMap.get(showStr) < 0) { |
||||
//如果map中的值小于0了,就说明数量对不上,修改过
|
||||
return true; |
||||
} |
||||
} else { |
||||
//如果存在map中没存的值就没必要继续下去了,肯定改过
|
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
Loading…
Reference in new issue