Commit e0ec9f9c by Jason Song Committed by GitHub

Merge pull request #456 from lepdou/bugfix_1123

bugfix: branch modify master's item should ignore some field
parents c06d5eee d689fe5b
...@@ -52,6 +52,8 @@ public class ItemController { ...@@ -52,6 +52,8 @@ public class ItemController {
toCreate.setLineNum(0); toCreate.setLineNum(0);
toCreate.setId(0); toCreate.setId(0);
toCreate.setDataChangeLastModifiedBy(toCreate.getDataChangeCreatedBy()); toCreate.setDataChangeLastModifiedBy(toCreate.getDataChangeCreatedBy());
toCreate.setDataChangeLastModifiedTime(null);
toCreate.setDataChangeCreatedTime(null);
ItemDTO createdItem = itemService.createItem(appId, Env.fromString(env), ItemDTO createdItem = itemService.createItem(appId, Env.fromString(env),
clusterName, namespaceName, toCreate); clusterName, namespaceName, toCreate);
......
...@@ -58,6 +58,15 @@ public class ItemController { ...@@ -58,6 +58,15 @@ public class ItemController {
@RequestBody ItemDTO item) { @RequestBody ItemDTO item) {
checkModel(isValidItem(item)); checkModel(isValidItem(item));
//protect
item.setLineNum(0);
item.setId(0);
String userId = userInfoHolder.getUser().getUserId();
item.setDataChangeCreatedBy(userId);
item.setDataChangeLastModifiedBy(userId);
item.setDataChangeCreatedTime(null);
item.setDataChangeLastModifiedTime(null);
return configService.createItem(appId, Env.valueOf(env), clusterName, namespaceName, item); return configService.createItem(appId, Env.valueOf(env), clusterName, namespaceName, item);
} }
......
...@@ -91,12 +91,6 @@ public class ItemService { ...@@ -91,12 +91,6 @@ public class ItemService {
} }
item.setNamespaceId(namespace.getId()); item.setNamespaceId(namespace.getId());
if (StringUtils.isEmpty(item.getDataChangeCreatedBy())) {
String username = userInfoHolder.getUser().getUserId();
item.setDataChangeCreatedBy(username);
item.setDataChangeLastModifiedBy(username);
}
ItemDTO itemDTO = itemAPI.createItem(appId, env, clusterName, namespaceName, item); ItemDTO itemDTO = itemAPI.createItem(appId, env, clusterName, namespaceName, item);
Cat.logEvent(CatEventType.MODIFY_NAMESPACE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); Cat.logEvent(CatEventType.MODIFY_NAMESPACE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName));
return itemDTO; return itemDTO;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment