🎨 优化代码,去掉之前PR引入的lambda表达式,保证兼容java7

This commit is contained in:
Binary Wang 2020-03-28 21:30:56 +08:00
parent 73ecaabdb4
commit 1f49ac0781

View File

@ -49,7 +49,6 @@ public class WxMaCloudServiceImpl implements WxMaCloudService {
@Override @Override
public List<String> add(String collection, List list) throws WxErrorException { public List<String> add(String collection, List list) throws WxErrorException {
String jsonData = WxMaGsonBuilder.create().toJson(list); String jsonData = WxMaGsonBuilder.create().toJson(list);
String query = JoinerUtils.blankJoiner.join( String query = JoinerUtils.blankJoiner.join(
"db.collection('", collection, "')", "db.collection('", collection, "')",
@ -67,9 +66,7 @@ public class WxMaCloudServiceImpl implements WxMaCloudService {
} }
JsonArray idArray = jsonObject.getAsJsonArray("id_list"); JsonArray idArray = jsonObject.getAsJsonArray("id_list");
List<String> idList = new ArrayList<>(); List<String> idList = new ArrayList<>();
Iterator<JsonElement> idIterator = idArray.iterator(); for (JsonElement id : idArray) {
while (idIterator.hasNext()) {
JsonElement id = idIterator.next();
idList.add(id.getAsString()); idList.add(id.getAsString());
} }
return idList; return idList;
@ -124,8 +121,7 @@ public class WxMaCloudServiceImpl implements WxMaCloudService {
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent)); throw new WxErrorException(WxError.fromJson(responseContent));
} }
Integer deletedNum = jsonObject.get("deleted").getAsInt(); return jsonObject.get("deleted").getAsInt();
return deletedNum;
} }
@Override @Override
@ -174,10 +170,11 @@ public class WxMaCloudServiceImpl implements WxMaCloudService {
} }
StringBuilder orderBySb = new StringBuilder(); StringBuilder orderBySb = new StringBuilder();
if (null != orderBy && !orderBy.isEmpty()) { if (null != orderBy && !orderBy.isEmpty()) {
orderBy.entrySet().forEach( for (Map.Entry<String, String> entry : orderBy.entrySet()) {
e -> orderBySb.append(".orderBy('").append(e.getKey()).append("', '").append(e.getValue()).append("')") orderBySb.append(".orderBy('").append(entry.getKey()).append("', '").append(entry.getValue()).append("')");
);
} }
}
if (null == limit) { if (null == limit) {
limit = 100; limit = 100;
} }