forked from apolloconfig/apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apolloconfig#286 from lepdou/0620_27
commit history & bugfix empty value
- Loading branch information
Showing
26 changed files
with
568 additions
and
157 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...ce/src/main/java/com/ctrip/framework/apollo/adminservice/controller/CommitController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.ctrip.framework.apollo.adminservice.controller; | ||
|
||
import com.ctrip.framework.apollo.biz.entity.Commit; | ||
import com.ctrip.framework.apollo.biz.service.CommitService; | ||
import com.ctrip.framework.apollo.common.utils.BeanUtils; | ||
import com.ctrip.framework.apollo.core.dto.CommitDTO; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
|
||
@RestController | ||
public class CommitController { | ||
|
||
@Autowired | ||
private CommitService commitService; | ||
|
||
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit") | ||
public List<CommitDTO> find(@PathVariable String appId, @PathVariable String clusterName, | ||
@PathVariable String namespaceName, Pageable pageable){ | ||
|
||
List<Commit> commits = commitService.find(appId, clusterName, namespaceName, pageable); | ||
return BeanUtils.batchTransform(CommitDTO.class, commits); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...lo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.ctrip.framework.apollo.biz.utils; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
import com.ctrip.framework.apollo.biz.entity.Item; | ||
import com.ctrip.framework.apollo.common.utils.BeanUtils; | ||
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; | ||
import com.ctrip.framework.apollo.core.dto.ItemDTO; | ||
|
||
import java.util.Date; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
|
||
public class ConfigChangeContentBuilder { | ||
|
||
private static final Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); | ||
|
||
private List<Item> createItems = new LinkedList<>(); | ||
private List<ItemPair> updateItems = new LinkedList<>(); | ||
private List<Item> deleteItems = new LinkedList<>(); | ||
|
||
|
||
public ConfigChangeContentBuilder createItem(Item item) { | ||
createItems.add(item); | ||
return this; | ||
} | ||
|
||
public ConfigChangeContentBuilder updateItem(Item oldItem, Item newItem) { | ||
ItemPair itemPair = new ItemPair(oldItem, newItem); | ||
updateItems.add(itemPair); | ||
return this; | ||
} | ||
|
||
public ConfigChangeContentBuilder deleteItem(Item item) { | ||
deleteItems.add(item); | ||
return this; | ||
} | ||
|
||
public String build() { | ||
//因为事务第一段提交并没有更新时间,所以build时统一更新 | ||
for (Item item : createItems) { | ||
item.setDataChangeLastModifiedTime(new Date()); | ||
} | ||
|
||
for (ItemPair item : updateItems) { | ||
item.newItem.setDataChangeLastModifiedTime(new Date()); | ||
} | ||
|
||
for (Item item : deleteItems) { | ||
item.setDataChangeLastModifiedTime(new Date()); | ||
} | ||
return gson.toJson(this); | ||
} | ||
|
||
class ItemPair { | ||
|
||
Item oldItem; | ||
Item newItem; | ||
|
||
public ItemPair(Item oldItem, Item newItem) { | ||
this.oldItem = oldItem; | ||
this.newItem = newItem; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.