Selaa lähdekoodia

add 数据迁移 删除、查询日志接口 入参出参调整为与中台一致

lvxianyun 2 vuotta sitten
vanhempi
commit
fb05738c39

+ 31 - 19
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/controller/DataMigrationController.java

@@ -130,17 +130,7 @@ public class DataMigrationController {
             e.printStackTrace();
             return AdmResponse.failure(MigrationConstant.ERROR +":"+ e.getMessage());
         }
-
         dataMigrationHandler.handleAndSaveLog(context, migrationInfo);
-
-        AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
-        admQueryCriteria.addFilters("targetId = 'error'");
-        admQueryCriteria.addFilters("projectId = '" + context.getProjectId() + "'");
-        admQueryCriteria.setOnlyCount(true);
-        AdmResponse response = queryMigrateForLog(admQueryCriteria);
-        if(response.getMessage().equals(DmpResult.SUCCESS) && response.getCount() > 5){
-            return AdmResponse.failure("出现错误次数:"+ response.getCount()+"次,请使用导出检查数据是否迁移成功");
-        }
         return AdmResponse.success();
     }
 
@@ -195,29 +185,51 @@ public class DataMigrationController {
     /**
      * 获取迁移数据日志
      *
-     * @AdmQueryCriteria
+     * @param request
      * {
-     *     "order": "lastUpdate asc, objId asc",
-     *     "pageNumber": 1,
-     *     "pageSize": 15,
-     *     "filters": "projectId='Pj9909990004';sign=2;type='create';objectType='building'"
+     *     "onlyCount": false,
+     *     "withoutCount": false,
+     *     "criteria": {
+     *         "sign": 2,
+     *         "type": "create",
+     *         "tableName": "dt_relation",
+     *         "creationTime":{
+     *             "$gte":20220120121146,
+     *             "$lte":20220123121146
+     *         },
+     *         "valid": 1
+     *     }
      * }
      *
-     *  return AdmResponse
+     *  return CommonResult
      */
     @PostMapping("/log")
-    public AdmResponse queryMigrateForLog(@RequestBody AdmQueryCriteria request) {
+    public CommonResult queryMigrateForLog(@RequestBody QueryCriteria request) {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return logService.queryMigrationLog(context, request);
     }
 
     /**
-     *
+     * 根据条件 删除操作日志 物理删除
      * @param request
+     * {
+     *     "onlyCount": false,
+     *     "withoutCount": false,
+     *     "criteria": {
+     *         "sign": 2,
+     *         "type": "create",
+     *         "tableName": "dt_relation",
+     *         "creationTime":{
+     *             "$gte":20220120121146,
+     *             "$lte":20220123121146
+     *         },
+     *         "valid": 1
+     *     }
+     * }
      * @return
      */
     @PostMapping("/deleteLog")
-    public AdmResponse deleteMigrateForLog(@RequestBody AdmQueryCriteria request) {
+    public CommonResult deleteMigrateForLog(@RequestBody QueryCriteria request) {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return logService.deleteMigrationLog(context, request);
     }

+ 3 - 4
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/service/IMigrationLogService.java

@@ -1,8 +1,7 @@
 package com.persagy.proxy.migration.service;
 
 import com.persagy.dmp.basic.model.QueryCriteria;
-import com.persagy.proxy.adm.request.AdmQueryCriteria;
-import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 
 /**
@@ -14,6 +13,6 @@ import com.persagy.proxy.common.entity.InstanceUrlParam;
  */
 public interface IMigrationLogService {
 
-    AdmResponse queryMigrationLog(InstanceUrlParam context, AdmQueryCriteria request);
-    AdmResponse deleteMigrationLog(InstanceUrlParam context, AdmQueryCriteria request);
+    CommonResult queryMigrationLog(InstanceUrlParam context, QueryCriteria queryCriteria);
+    CommonResult deleteMigrationLog(InstanceUrlParam context, QueryCriteria queryCriteria);
 }

+ 6 - 23
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/service/Impl/MigrationLogServiceImpl.java

@@ -37,45 +37,28 @@ import java.util.stream.Collectors;
 @Slf4j
 public class MigrationLogServiceImpl implements IMigrationLogService {
     @Override
-    public AdmResponse queryMigrationLog(InstanceUrlParam context, AdmQueryCriteria request) {
-        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
+    public CommonResult queryMigrationLog(InstanceUrlParam context, QueryCriteria queryCriteria) {
         String groupCode = context.getGroupCode();
         String projectId = context.getProjectId();
         CommonResult<List<SyncData>> result = DigitalMigrateLogFacade.query(groupCode, projectId, context.getAppId(), context.getUserId(),queryCriteria);
         if(result.getResult().equals(DmpResult.SUCCESS)){
             if(CollUtil.isEmpty(result.getData())){
-                return AdmResponse.success();
+                return result;
             }
             // 处理返回值
             List<SyncData> syncDatas = result.getData();
             processSynDatas(groupCode, projectId, syncDatas);
-            AdmResponse response = AdmResponse.success(syncDatas);
-            Long total = result.getCount() == null ? null : result.getCount().longValue();
-            if(request.isOnlyCount()){
-                response.setTotal(null);
-                response.setCount(total);
-            }else {
-                response.setTotal(total);
-            }
-            response.setPageNumber(request.getPageNumber());
-            response.setPageSize(request.getPageSize());
-            return response;
-        } else {
-            return AdmResponse.failure(result.getMessage());
+            result.setData(syncDatas);
         }
+        return result;
     }
 
     @Override
-    public AdmResponse deleteMigrationLog(InstanceUrlParam context, AdmQueryCriteria request) {
-        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
+    public CommonResult deleteMigrationLog(InstanceUrlParam context, QueryCriteria queryCriteria) {
         String groupCode = context.getGroupCode();
         String projectId = context.getProjectId();
         CommonResult result = DigitalMigrateLogFacade.deleteAllLog(groupCode, projectId, context.getAppId(), context.getUserId(),queryCriteria);
-        if(result.getMessage().equals(DmpResult.SUCCESS)){
-            return AdmResponse.success();
-        }else{
-            return AdmResponse.failure(result.getMessage());
-        }
+        return result;
     }