Browse Source

fix controller 中 create 接口返回类型

lvxianyun 3 years ago
parent
commit
643c604d64
1 changed files with 19 additions and 40 deletions
  1. 19 40
      src/main/java/com/persagy/proxy/adm/request/AdmCreateResponse.java

+ 19 - 40
src/main/java/com/persagy/proxy/adm/request/AdmCreateResponse.java

@@ -1,8 +1,6 @@
 package com.persagy.proxy.adm.request;
 
-import com.alibaba.fastjson.JSONArray;
-import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
-import com.persagy.proxy.common.entity.DmpResult;
+import cn.hutool.core.collection.CollUtil;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -18,53 +16,34 @@ import java.util.List;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
-public class AdmCreateResponse {
+public class AdmCreateResponse extends AdmResponse {
     private final static String SUCCESS = "success";
     private final static String FAILURE = "failure";
-    /** 结果 */
-    private String result;
-    /** 消息 */
-    private String message;
     /** 错误数据主从对象 1 主对象  2 从对象 */
     private String errorType;
-    /** 查询到的数据列表 */
+    /**
+     * 查询到的数据列表
+     */
     private List<?> entityList;
 
-    public static AdmCreateResponse success() {
-        return new AdmCreateResponse(SUCCESS, null, null, null);
+    public AdmCreateResponse(String result, String message, Long total, Long count, Integer pageNumber, Integer pageSize, List<?> content, String floorId, String zoneType, List<?> entityList, String errorType) {
+        super(result, message, total, count, pageNumber, pageSize, content, floorId, zoneType);
+        this.entityList = entityList;
+        this.errorType = errorType;
     }
-
-    public static AdmCreateResponse success(String message) {
-        return new AdmCreateResponse(SUCCESS, message, null, null);
-    }
-
     public static AdmCreateResponse failure(String message) {
-        return new AdmCreateResponse(FAILURE, message, null, new ArrayList<>());
+        return new AdmCreateResponse(FAILURE, message, null, null, null, null, new ArrayList<>(1), null, null, null, null);
     }
-
     public static AdmCreateResponse failure(String message,String errorType) {
-        return new AdmCreateResponse(FAILURE, message, errorType, new ArrayList<>());
+        return new AdmCreateResponse(FAILURE, message,null, null, null, null, new ArrayList<>(1), null, null, new ArrayList<>(), errorType);
     }
-
-    public static AdmCreateResponse success(List<?> content) {
-        return new AdmCreateResponse(SUCCESS, null, null, content);
+    public static AdmCreateResponse success() {
+        return new AdmCreateResponse(SUCCESS, "", 0L,null, 1, 500, new ArrayList<>(1),null,null,null,null);
     }
-
-    /**
-     * 从数据中台结果转换
-     * @param admRequest
-     * @param dmpResult
-     * @param clazz
-     * @param <T>
-     * @return
-     */
-    public static <T> AdmCreateResponse fromDmp(AdmQueryCriteria admRequest, DmpResult<JSONArray> dmpResult, Class<T> clazz) {
-        if(!DmpResult.SUCCESS.equals(dmpResult.getResult())) {
-            return failure("调用中台查询接口出错:" + dmpResult.getMessage());
-        }
-        // 转换为结果
-        List<T> admVOs = AdmEntityTransferUtil.toAdmMultiEntity(dmpResult.getData(), admRequest.getProjection(), clazz);
-        Long total = dmpResult.getCount() == null ? null : dmpResult.getCount().longValue();
-        return new AdmCreateResponse(SUCCESS, null, null, admVOs);
+    public static AdmCreateResponse success(String message) {
+        return new AdmCreateResponse(SUCCESS, message, 0L,null, 1, 500, new ArrayList<>(1),null,null,null,null);
+    }
+    public static AdmCreateResponse success(List<?> content) {
+        return new AdmCreateResponse(SUCCESS, "", CollUtil.isEmpty(content) ? 0L :content.size()*1L,null, 1, 50, CollUtil.isEmpty(content) ? new ArrayList(1): content,null,null,content,null);
     }
-}
+}