Commit d237cec2 by Yiming Liu

Merge pull request #122 from lepdou/lepdou_master

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