Skip to content

Commit

Permalink
[IMP] 修改批量修改版本无效以及保存筛选报错
Browse files Browse the repository at this point in the history
  • Loading branch information
phyear committed Sep 1, 2020
1 parent 4b36965 commit 0ed8bd6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ public void handlerPredefinedFields(Long projectId, List<Long> issueIds, JSONObj
if (CollectionUtils.isEmpty(issueDTOS)) {
throw new CommonException("error.issues.null");
}
List<VersionIssueRelVO> fixVersion = StringUtil.cast(predefinedFields.get("fixVersion"));
List<VersionIssueRelVO> influenceVersion = StringUtil.cast(predefinedFields.get("influenceVersion"));
List<VersionIssueRelVO> fixVersion = ObjectUtils.isEmpty(predefinedFields.get("fixVersion")) ? null : EncryptionUtils.jsonToList(predefinedFields.get("fixVersion"),VersionIssueRelVO.class);
List<VersionIssueRelVO> influenceVersion = ObjectUtils.isEmpty(predefinedFields.get("influenceVersion")) ? null : EncryptionUtils.jsonToList(predefinedFields.get("influenceVersion"),VersionIssueRelVO.class);
predefinedFields.remove("fixVersion");
predefinedFields.remove("influenceVersion");
issueDTOS.forEach(v -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,16 @@ private void migrateData() {
LOGGER.info("开始迁移状态机相关表的数据");
// 迁移状态机方案配置表
statusMachineSchemeConfigMapper.migrateStatusMachineSchemeConfig();
LOGGER.info("完成迁移状态机方案配置表");
// 迁移状态机表
statusMachineMapper.migrateStatusMachine();
LOGGER.info("完成迁移状态机表");
// 迁移状态机node表
statusMachineNodeMapper.migrateStatusMachineNode();
LOGGER.info("完成迁移状态机node表");
// 迁移状态机转换表
statusMachineTransformMapper.migrateStatusMachineTransform();
LOGGER.info("完成迁移状态机转换表");
LOGGER.info("完成迁移状态机相关的表");
}

Expand Down Expand Up @@ -543,6 +547,7 @@ private void fixStateMachineTransform(){
});
// 批量增加
statusMachineTransformMapper.batchInsert(addTransform);
LOGGER.info("修复状态机:{}-{}的转换完成",statusMachineDTO.getId(),statusMachineDTO.getName());
}
// 删除所有type为transform_all的转换
StatusMachineTransformDTO statusMachineTransformDTO = new StatusMachineTransformDTO();
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/io/choerodon/agile/infra/utils/EncryptionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public static Long decrypt(String crypt, String tableName) {
}

public static String decrypt(String crypt) {
if (!EncryptContext.isEncrypt()){
return crypt;
}
return encryptionService.decrypt(crypt, BLANK_KEY);
}

Expand Down Expand Up @@ -153,7 +156,7 @@ public static List<Long> decryptList(List<String> crypts, String tableName, Stri
public static List jsonToList(Object object, Class clazz) {
List list = new ArrayList();
try {
JsonNode jsonNode = objectMapper.readTree(object.toString());
JsonNode jsonNode = objectMapper.readTree(objectMapper.writeValueAsString(object));
if (jsonNode.isArray()) {
Iterator<JsonNode> elements = jsonNode.elements();
while (elements.hasNext()) {
Expand Down Expand Up @@ -204,7 +207,7 @@ public static void handlerObject(String jsonString, Object object, Class clazz)
&& Arrays.asList(encrypt.ignoreValue()).contains(valueNode.textValue())) {
field.set(object, Long.valueOf(valueNode.textValue()));
} else {
field.set(object, valueNode == null ? null : Long.valueOf(valueNode.toString()));
field.set(object, valueNode == null ? null : Long.valueOf(valueNode.textValue()));
}
} else if (field.getType() == Date.class) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Expand Down Expand Up @@ -498,7 +501,7 @@ public static String handlerPersonFilterJson(String filterJson, boolean encrypt)
objectNode.set("otherArgs",objectMapper.readTree(objectMapper.writeValueAsString(handlerOtherArgs(oAMap, encrypt))));
}
else {
objectNode.put("otherArgs", objectMapper.readTree(objectMapper.writeValueAsString(new HashMap())));
objectNode.set("otherArgs", objectMapper.readTree(objectMapper.writeValueAsString(new HashMap())));
}
if(!ObjectUtils.isEmpty(jsonNode.get("quickFilterIds"))){
List<String> list = objectMapper.readValue(objectMapper.writeValueAsString(jsonNode.get("quickFilterIds")),new TypeReference<List<String>>() {});
Expand Down Expand Up @@ -533,7 +536,7 @@ private static Map<String, Object> handlerOtherArgs(Map<String, Object> map, boo
e.printStackTrace();
}
if (!CollectionUtils.isEmpty(value)) {
object = value.stream().map(v -> encrypt ? encryptionService.encrypt(v, BLANK_KEY) : encryptionService.decrypt(v, BLANK_KEY)).collect(Collectors.toList());
object = value.stream().map(v -> encrypt ? encrypt(Long.valueOf(v)) : decrypt(v)).collect(Collectors.toList());
}
else {
object = new ArrayList<>();
Expand Down Expand Up @@ -626,6 +629,9 @@ public static String encrypt(Long value) {
if (Objects.isNull(value)){
return null;
}
if (!EncryptContext.isEncrypt()){
return value.toString();
}
return encryptionService.encrypt(value.toString(), BLANK_KEY);
}

Expand Down

0 comments on commit 0ed8bd6

Please sign in to comment.