diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java index 8eb8068..eb7b1a4 100644 --- a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java +++ b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java @@ -119,6 +119,7 @@ public class ApplicationServiceImpl implements IApplicationService { // 先查询,区分 新增APP、修改APP List addAppList = T.ListUtil.list(true); List updateAppList = T.ListUtil.list(true); + HashMap appMetaContentInDb = T.MapUtil.newHashMap(); try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(revTree); treeWalk.setRecursive(true); @@ -127,6 +128,11 @@ public class ApplicationServiceImpl implements IApplicationService { while (treeWalk.next()) { String appName = T.PathUtil.getPathEle(Path.of(treeWalk.getPathString()), 1).toString(); appNameListInDb.add(appName); + if (T.StrUtil.equals("meta.json", treeWalk.getNameString())) { + ObjectLoader loader = repository.open(treeWalk.getObjectId(0)); + JSONObject jsonObject = T.JSONUtil.parseObj(T.StrUtil.utf8Str(loader.getBytes())); + appMetaContentInDb.put(appName, jsonObject); + } } list.parallelStream().forEach(entity -> { if (appNameListInDb.contains(entity.getName())) { @@ -191,6 +197,15 @@ public class ApplicationServiceImpl implements IApplicationService { JSONObject jsonObject = T.JSONUtil.parseObj(entity); jsonObject.remove("signature"); + JSONObject metaInDb = appMetaContentInDb.get(entity.getName()); + if (null != metaInDb) { + // 还原 asw 部分属性值,此部分 tsg app 不记录 + jsonObject.set("id", metaInDb.getStr("id")); + jsonObject.set("developer", metaInDb.getStr("developer", "")); + jsonObject.set("website", metaInDb.getStr("website", "")); + jsonObject.set("packageName", metaInDb.getObj("packageName")); + } + String fileContent = T.JSONUtil.parse(jsonObject).toJSONString(2); ObjectId objectId = gitService.insertBlobFileToDatabase(repository, fileContent.getBytes()); DirCacheEntry dirCacheEntry = gitService.buildDirCacheEntry(T.StrUtil.concat(true, "applications/", entity.getName(), "/meta.json"), FileMode.REGULAR_FILE, objectId); diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/TSG2402ApplicationServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/TSG2402ApplicationServiceImpl.java index 2c7a718..5e1122d 100644 --- a/src/main/java/net/geedge/asw/module/app/service/impl/TSG2402ApplicationServiceImpl.java +++ b/src/main/java/net/geedge/asw/module/app/service/impl/TSG2402ApplicationServiceImpl.java @@ -134,14 +134,13 @@ public class TSG2402ApplicationServiceImpl implements ITSGApplicationService { for (Object condition : conditions) { JSONObject conditionJSONObj = (JSONObject) condition; - String attributeType = T.MapUtil.getStr(conditionJSONObj, "attributeType"); String attributeName = T.MapUtil.getStr(conditionJSONObj, "attributeName"); - AttributeEntity attributeEntity = attributeService.queryAttribute(attributeType, attributeName); + AttributeEntity attributeEntity = attributeService.queryAttribute(attributeName); if (null == attributeEntity || T.StrUtil.isEmpty(attributeEntity.getObjectType())) continue; Map or_condition_obj = T.MapUtil.builder() .put("lua_profile_id", 0) - .put("attribute_type", attributeType) + .put("attribute_type", attributeEntity.getType()) .put("attribute_name", attributeName) .put("protocol", attributeEntity.getProtocol()) .build(); @@ -491,7 +490,6 @@ public class TSG2402ApplicationServiceImpl implements ITSGApplicationService { .map(obj -> (JSONObject) obj) .forEach(application -> { // application - String app_id = application.getStr("app_id"); String app_name = application.getStr("app_name"); String app_longname = application.getStr("app_longname"); String description = application.getStr("description"); @@ -513,12 +511,12 @@ public class TSG2402ApplicationServiceImpl implements ITSGApplicationService { // meta.json ApplicationEntity entity = new ApplicationEntity(); - entity.setId(app_id); entity.setName(app_name); entity.setLongName(app_longname); entity.setDescription(description); entity.setProperties(properties); // default value + entity.setId(T.StrUtil.uuid()); entity.setDeveloper(""); entity.setWebsite(""); entity.setPackageName( @@ -603,11 +601,9 @@ public class TSG2402ApplicationServiceImpl implements ITSGApplicationService { JSONObject or_condition = (JSONObject) T.JSONUtil.getByPath(conditions, "or_conditions[0]"); String attribute_name = or_condition.getStr("attribute_name", ""); - String attribute_type = or_condition.getStr("attribute_type", ""); Map m = T.MapUtil.builder() .put("attributeName", attribute_name) - .put("attributeType", attribute_type) .put("negateOption", not_flag == 1 ? true : false) .put("description", "") .build(); diff --git a/src/main/java/net/geedge/asw/module/attribute/service/IAttributeService.java b/src/main/java/net/geedge/asw/module/attribute/service/IAttributeService.java index 7716ab1..01b45d7 100644 --- a/src/main/java/net/geedge/asw/module/attribute/service/IAttributeService.java +++ b/src/main/java/net/geedge/asw/module/attribute/service/IAttributeService.java @@ -9,5 +9,5 @@ import java.util.Map; public interface IAttributeService extends IService { Page queryList(Map params); - AttributeEntity queryAttribute(String type, String name); + AttributeEntity queryAttribute(String name); } diff --git a/src/main/java/net/geedge/asw/module/attribute/service/impl/AttributeServiceImpl.java b/src/main/java/net/geedge/asw/module/attribute/service/impl/AttributeServiceImpl.java index 359b8f4..9bee01e 100644 --- a/src/main/java/net/geedge/asw/module/attribute/service/impl/AttributeServiceImpl.java +++ b/src/main/java/net/geedge/asw/module/attribute/service/impl/AttributeServiceImpl.java @@ -25,9 +25,8 @@ public class AttributeServiceImpl extends ServiceImpl() - .eq(AttributeEntity::getType, type) .eq(AttributeEntity::getName, name) .last("limit 1") );