提交 bc9aa725 编写于 作者: L lepdou

fix datachange create by

上级 266f4d89
......@@ -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);
......
......@@ -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"};
}
......@@ -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());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册