fix: 调整 application 导入导出接口,asw 不记录 condition.attributeType 属性
This commit is contained in:
@@ -119,6 +119,7 @@ public class ApplicationServiceImpl implements IApplicationService {
|
|||||||
// 先查询,区分 新增APP、修改APP
|
// 先查询,区分 新增APP、修改APP
|
||||||
List<ApplicationEntity> addAppList = T.ListUtil.list(true);
|
List<ApplicationEntity> addAppList = T.ListUtil.list(true);
|
||||||
List<ApplicationEntity> updateAppList = T.ListUtil.list(true);
|
List<ApplicationEntity> updateAppList = T.ListUtil.list(true);
|
||||||
|
HashMap<String, JSONObject> appMetaContentInDb = T.MapUtil.newHashMap();
|
||||||
try (TreeWalk treeWalk = new TreeWalk(repository)) {
|
try (TreeWalk treeWalk = new TreeWalk(repository)) {
|
||||||
treeWalk.addTree(revTree);
|
treeWalk.addTree(revTree);
|
||||||
treeWalk.setRecursive(true);
|
treeWalk.setRecursive(true);
|
||||||
@@ -127,6 +128,11 @@ public class ApplicationServiceImpl implements IApplicationService {
|
|||||||
while (treeWalk.next()) {
|
while (treeWalk.next()) {
|
||||||
String appName = T.PathUtil.getPathEle(Path.of(treeWalk.getPathString()), 1).toString();
|
String appName = T.PathUtil.getPathEle(Path.of(treeWalk.getPathString()), 1).toString();
|
||||||
appNameListInDb.add(appName);
|
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 -> {
|
list.parallelStream().forEach(entity -> {
|
||||||
if (appNameListInDb.contains(entity.getName())) {
|
if (appNameListInDb.contains(entity.getName())) {
|
||||||
@@ -191,6 +197,15 @@ public class ApplicationServiceImpl implements IApplicationService {
|
|||||||
JSONObject jsonObject = T.JSONUtil.parseObj(entity);
|
JSONObject jsonObject = T.JSONUtil.parseObj(entity);
|
||||||
jsonObject.remove("signature");
|
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);
|
String fileContent = T.JSONUtil.parse(jsonObject).toJSONString(2);
|
||||||
ObjectId objectId = gitService.insertBlobFileToDatabase(repository, fileContent.getBytes());
|
ObjectId objectId = gitService.insertBlobFileToDatabase(repository, fileContent.getBytes());
|
||||||
DirCacheEntry dirCacheEntry = gitService.buildDirCacheEntry(T.StrUtil.concat(true, "applications/", entity.getName(), "/meta.json"), FileMode.REGULAR_FILE, objectId);
|
DirCacheEntry dirCacheEntry = gitService.buildDirCacheEntry(T.StrUtil.concat(true, "applications/", entity.getName(), "/meta.json"), FileMode.REGULAR_FILE, objectId);
|
||||||
|
|||||||
@@ -134,14 +134,13 @@ public class TSG2402ApplicationServiceImpl implements ITSGApplicationService {
|
|||||||
for (Object condition : conditions) {
|
for (Object condition : conditions) {
|
||||||
JSONObject conditionJSONObj = (JSONObject) condition;
|
JSONObject conditionJSONObj = (JSONObject) condition;
|
||||||
|
|
||||||
String attributeType = T.MapUtil.getStr(conditionJSONObj, "attributeType");
|
|
||||||
String attributeName = T.MapUtil.getStr(conditionJSONObj, "attributeName");
|
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;
|
if (null == attributeEntity || T.StrUtil.isEmpty(attributeEntity.getObjectType())) continue;
|
||||||
|
|
||||||
Map<Object, Object> or_condition_obj = T.MapUtil.builder()
|
Map<Object, Object> or_condition_obj = T.MapUtil.builder()
|
||||||
.put("lua_profile_id", 0)
|
.put("lua_profile_id", 0)
|
||||||
.put("attribute_type", attributeType)
|
.put("attribute_type", attributeEntity.getType())
|
||||||
.put("attribute_name", attributeName)
|
.put("attribute_name", attributeName)
|
||||||
.put("protocol", attributeEntity.getProtocol())
|
.put("protocol", attributeEntity.getProtocol())
|
||||||
.build();
|
.build();
|
||||||
@@ -491,7 +490,6 @@ public class TSG2402ApplicationServiceImpl implements ITSGApplicationService {
|
|||||||
.map(obj -> (JSONObject) obj)
|
.map(obj -> (JSONObject) obj)
|
||||||
.forEach(application -> {
|
.forEach(application -> {
|
||||||
// application
|
// application
|
||||||
String app_id = application.getStr("app_id");
|
|
||||||
String app_name = application.getStr("app_name");
|
String app_name = application.getStr("app_name");
|
||||||
String app_longname = application.getStr("app_longname");
|
String app_longname = application.getStr("app_longname");
|
||||||
String description = application.getStr("description");
|
String description = application.getStr("description");
|
||||||
@@ -513,12 +511,12 @@ public class TSG2402ApplicationServiceImpl implements ITSGApplicationService {
|
|||||||
|
|
||||||
// meta.json
|
// meta.json
|
||||||
ApplicationEntity entity = new ApplicationEntity();
|
ApplicationEntity entity = new ApplicationEntity();
|
||||||
entity.setId(app_id);
|
|
||||||
entity.setName(app_name);
|
entity.setName(app_name);
|
||||||
entity.setLongName(app_longname);
|
entity.setLongName(app_longname);
|
||||||
entity.setDescription(description);
|
entity.setDescription(description);
|
||||||
entity.setProperties(properties);
|
entity.setProperties(properties);
|
||||||
// default value
|
// default value
|
||||||
|
entity.setId(T.StrUtil.uuid());
|
||||||
entity.setDeveloper("");
|
entity.setDeveloper("");
|
||||||
entity.setWebsite("");
|
entity.setWebsite("");
|
||||||
entity.setPackageName(
|
entity.setPackageName(
|
||||||
@@ -603,11 +601,9 @@ public class TSG2402ApplicationServiceImpl implements ITSGApplicationService {
|
|||||||
|
|
||||||
JSONObject or_condition = (JSONObject) T.JSONUtil.getByPath(conditions, "or_conditions[0]");
|
JSONObject or_condition = (JSONObject) T.JSONUtil.getByPath(conditions, "or_conditions[0]");
|
||||||
String attribute_name = or_condition.getStr("attribute_name", "");
|
String attribute_name = or_condition.getStr("attribute_name", "");
|
||||||
String attribute_type = or_condition.getStr("attribute_type", "");
|
|
||||||
|
|
||||||
Map<Object, Object> m = T.MapUtil.builder()
|
Map<Object, Object> m = T.MapUtil.builder()
|
||||||
.put("attributeName", attribute_name)
|
.put("attributeName", attribute_name)
|
||||||
.put("attributeType", attribute_type)
|
|
||||||
.put("negateOption", not_flag == 1 ? true : false)
|
.put("negateOption", not_flag == 1 ? true : false)
|
||||||
.put("description", "")
|
.put("description", "")
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ import java.util.Map;
|
|||||||
public interface IAttributeService extends IService<AttributeEntity> {
|
public interface IAttributeService extends IService<AttributeEntity> {
|
||||||
Page queryList(Map<String, Object> params);
|
Page queryList(Map<String, Object> params);
|
||||||
|
|
||||||
AttributeEntity queryAttribute(String type, String name);
|
AttributeEntity queryAttribute(String name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,8 @@ public class AttributeServiceImpl extends ServiceImpl<AttributeDao, AttributeEnt
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttributeEntity queryAttribute(String type, String name) {
|
public AttributeEntity queryAttribute(String name) {
|
||||||
AttributeEntity one = this.getOne(new LambdaQueryWrapper<AttributeEntity>()
|
AttributeEntity one = this.getOne(new LambdaQueryWrapper<AttributeEntity>()
|
||||||
.eq(AttributeEntity::getType, type)
|
|
||||||
.eq(AttributeEntity::getName, name)
|
.eq(AttributeEntity::getName, name)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user