diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java index d98960de553b3cc3b6adfda6b0dcaecd687bbd27..cb3a06012d14ddeeaa480403963a245bb83887e7 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java @@ -3,6 +3,7 @@ package com.ctrip.framework.apollo.biz.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import com.ctrip.framework.apollo.biz.entity.Audit; import com.ctrip.framework.apollo.biz.entity.Item; @@ -23,7 +24,7 @@ public class ItemSetService { @Transactional public void updateSet(ItemChangeSets changeSet) { String owner = changeSet.getDataChangeLastModifiedBy(); - if (changeSet.getCreateItems() != null) { + if (!CollectionUtils.isEmpty(changeSet.getCreateItems())) { for (ItemDTO item : changeSet.getCreateItems()) { Item entity = BeanUtils.transfrom(Item.class, item); entity.setDataChangeCreatedBy(owner); @@ -33,7 +34,7 @@ public class ItemSetService { auditService.audit("ItemSet", null, Audit.OP.INSERT, owner); } - if (changeSet.getUpdateItems() != null) { + if (!CollectionUtils.isEmpty(changeSet.getUpdateItems())) { for (ItemDTO item : changeSet.getUpdateItems()) { Item entity = BeanUtils.transfrom(Item.class, item); Item managedItem = itemRepository.findOne(entity.getId()); @@ -44,7 +45,7 @@ public class ItemSetService { auditService.audit("ItemSet", null, Audit.OP.UPDATE, owner); } - if (changeSet.getDeleteItems() != null) { + if (!CollectionUtils.isEmpty(changeSet.getDeleteItems())) { for (ItemDTO item : changeSet.getDeleteItems()) { Item entity = BeanUtils.transfrom(Item.class, item); entity.setDataChangeLastModifiedBy(owner); diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java index ff2bee8abc6b6c66ec6053095f37a7923934ae4f..4bc0c6e7412dc29708e4215e1c987766891a80d5 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java @@ -218,7 +218,7 @@ public class BeanUtils { /** * The copy will ignore BaseEntity field - * + * * @param source * @param target */ @@ -226,5 +226,5 @@ public class BeanUtils { org.springframework.beans.BeanUtils.copyProperties(source, target, COPY_IGNORED_PROPERTIES); } - private static final String[] COPY_IGNORED_PROPERTIES = {"id", "dataChangeCreatedTime", "dataChangeLastModifiedTime"}; + private static final String[] COPY_IGNORED_PROPERTIES = {"id", "dataChangeCreatedBy", "dataChangeCreatedTime", "dataChangeLastModifiedTime"}; } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalServerConfigController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalServerConfigController.java index cb1922e252311b2f2b57d4c9c786cc105e494f21..e3b2c63736e158047baf4abe5cf522786e51bdba 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalServerConfigController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalServerConfigController.java @@ -4,6 +4,7 @@ package com.ctrip.framework.apollo.portal.controller; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.core.utils.StringUtils; +import com.ctrip.framework.apollo.portal.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.entity.po.ServerConfig; import com.ctrip.framework.apollo.portal.repository.ServerConfigRepository; @@ -21,6 +22,8 @@ public class PortalServerConfigController { @Autowired private ServerConfigRepository serverConfigRepository; + @Autowired + private UserInfoHolder userInfoHolder; @RequestMapping(value = "/server/config", method = RequestMethod.POST) public ServerConfig createOrUpdate(@RequestBody ServerConfig serverConfig) { @@ -29,8 +32,7 @@ public class PortalServerConfigController { throw new BadRequestException("request payload contains empty"); } - // TODO: 16/6/2 接入sso之后改成当前登录用户 - String modifiedBy = "admin"; + String modifiedBy = userInfoHolder.getUser().getUsername(); ServerConfig storedConfig = serverConfigRepository.findByKey(serverConfig.getKey());