Commit d237cec2 authored by Yiming Liu's avatar Yiming Liu

Merge pull request #122 from lepdou/lepdou_master

item lastModifiedBy
parents fed39e80 e4d3ba56
package com.ctrip.apollo.adminservice.controller; package com.ctrip.apollo.adminservice.controller;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -59,7 +60,15 @@ public class ItemController { ...@@ -59,7 +60,15 @@ public class ItemController {
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) { @PathVariable("namespaceName") String namespaceName) {
List<Item> items = viewService.findItems(appId, clusterName, namespaceName); List<Item> items = viewService.findItems(appId, clusterName, namespaceName);
return BeanUtils.batchTransform(ItemDTO.class, items); List<ItemDTO> itemDTOs = new LinkedList<>();
for (Item item: items){
ItemDTO itemDTO = BeanUtils.transfrom(ItemDTO.class, item);
itemDTO.setLastModifiedBy(item.getDataChangeLastModifiedBy());
itemDTO.setLastModifiedTime(item.getDataChangeLastModifiedTime());
itemDTOs.add(itemDTO);
}
return itemDTOs;
} }
@RequestMapping("/items/{itemId}") @RequestMapping("/items/{itemId}")
......
...@@ -90,6 +90,7 @@ public abstract class BaseEntity { ...@@ -90,6 +90,7 @@ public abstract class BaseEntity {
@PrePersist @PrePersist
protected void prePersist() { protected void prePersist() {
if (this.dataChangeCreatedTime == null) dataChangeCreatedTime = new Date(); if (this.dataChangeCreatedTime == null) dataChangeCreatedTime = new Date();
if (this.dataChangeLastModifiedTime == null) dataChangeLastModifiedTime = new Date();
} }
@PreUpdate @PreUpdate
......
...@@ -27,7 +27,6 @@ public class ItemSetService { ...@@ -27,7 +27,6 @@ public class ItemSetService {
if (changeSet.getCreateItems() != null) { if (changeSet.getCreateItems() != null) {
for (ItemDTO item : changeSet.getCreateItems()) { for (ItemDTO item : changeSet.getCreateItems()) {
Item entity = BeanUtils.transfrom(Item.class, item); Item entity = BeanUtils.transfrom(Item.class, item);
entity.setDataChangeCreatedTime(new Date());
entity.setDataChangeCreatedBy(owner); entity.setDataChangeCreatedBy(owner);
entity.setDataChangeLastModifiedBy(owner); entity.setDataChangeLastModifiedBy(owner);
itemRepository.save(entity); itemRepository.save(entity);
......
package com.ctrip.apollo.core.dto; package com.ctrip.apollo.core.dto;
import java.util.Date;
public class ItemDTO { public class ItemDTO {
private long id; private long id;
...@@ -14,6 +16,10 @@ public class ItemDTO { ...@@ -14,6 +16,10 @@ public class ItemDTO {
private int lineNum; private int lineNum;
private String lastModifiedBy;
private Date lastModifiedTime;
public ItemDTO() { public ItemDTO() {
} }
...@@ -73,6 +79,21 @@ public class ItemDTO { ...@@ -73,6 +79,21 @@ public class ItemDTO {
this.lineNum = lineNum; this.lineNum = lineNum;
} }
public String getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
public Date getLastModifiedTime() {
return lastModifiedTime;
}
public void setLastModifiedTime(Date lastModifiedTime) {
this.lastModifiedTime = lastModifiedTime;
}
@Override @Override
public String toString() { public String toString() {
...@@ -83,6 +104,8 @@ public class ItemDTO { ...@@ -83,6 +104,8 @@ public class ItemDTO {
", value='" + value + '\'' + ", value='" + value + '\'' +
", comment='" + comment + '\'' + ", comment='" + comment + '\'' +
", lineNum=" + lineNum + ", lineNum=" + lineNum +
", lastModifiedBy='" + lastModifiedBy + '\'' +
", lastModifiedTime=" + lastModifiedTime +
'}'; '}';
} }
} }
...@@ -148,10 +148,10 @@ ...@@ -148,10 +148,10 @@
{{config.item.comment}} {{config.item.comment}}
</td> </td>
<td> <td>
{{config.item.dataChangeLastModifiedBy}} {{config.item.lastModifiedBy}}
</td> </td>
<td> <td>
{{config.item.dataChangeLastModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'}} {{config.item.lastModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'}}
</td> </td>
</tr> </tr>
......
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