Selaa lähdekoodia

查询账套接口修改

yingp 8 vuotta sitten
vanhempi
commit
f7e1120b6f

+ 23 - 4
src/main/java/com/uas/erp/database/api/v1/MasterController.java

@@ -18,16 +18,35 @@ public class MasterController {
     @Autowired
     private MasterService masterService;
 
+    /**
+     * 查找账套配置信息
+     *
+     * @param cloudEnabled 启用云端服务
+     * @return
+     */
     @GetMapping(path = "/list")
-    public ResponseEntity getAll() {
-        return ResponseWrap.ok(masterService.findAll());
+    public ResponseEntity getAll(Boolean cloudEnabled) {
+        return ResponseWrap.ok(masterService.findAll(null != cloudEnabled &&
+                cloudEnabled.booleanValue()));
     }
 
+    /**
+     * 查找账套
+     *
+     * @param cloudEnabled 启用云端服务
+     * @return
+     */
     @GetMapping(path = "/view")
-    public ResponseEntity getAllView() {
-        return ResponseWrap.ok(masterService.findAllView());
+    public ResponseEntity getAllView(Boolean cloudEnabled) {
+        return ResponseWrap.ok(masterService.findAllView(null != cloudEnabled &&
+                cloudEnabled.booleanValue()));
     }
 
+    /**
+     * 重新扫描
+     *
+     * @return
+     */
     @RequestMapping(path = "/refresh")
     public ResponseEntity refreshAll() {
         masterService.scanAll();

+ 5 - 0
src/main/java/com/uas/erp/database/domain/Master.java

@@ -2,6 +2,7 @@ package com.uas.erp.database.domain;
 
 import com.uas.erp.database.core.Constant;
 import com.uas.erp.database.datasource.Connectable;
+import org.springframework.util.StringUtils;
 
 /**
  * Created by Pro1 on 2017/7/26.
@@ -151,4 +152,8 @@ public class Master implements Connectable, Comparable<Master>{
     public int compareTo(Master master) {
         return Integer.compare(this.ma_id, master.getMa_id());
     }
+
+    public boolean isCloudEnabled() {
+        return 1 == getMa_b2benable() && null != getMa_uu() && !StringUtils.isEmpty(getMa_accesssecret());
+    }
 }

+ 11 - 0
src/main/java/com/uas/erp/database/domain/MasterView.java

@@ -9,11 +9,14 @@ public class MasterView {
     private String name;
     private String title;
     private String env;
+    // 是否启用云端服务(b2b、商城等的数据交互)
+    private boolean cloudEnabled;
 
     public MasterView(Master master) {
         this.name = master.getMa_user().toUpperCase();
         this.title = master.getMa_function();
         this.env = StringUtils.isEmpty(master.getMa_env()) ? "test" : master.getMa_env();
+        this.cloudEnabled = master.isCloudEnabled();
     }
 
     public String getName() {
@@ -39,4 +42,12 @@ public class MasterView {
     public void setEnv(String env) {
         this.env = env;
     }
+
+    public boolean isCloudEnabled() {
+        return cloudEnabled;
+    }
+
+    public void setCloudEnabled(boolean cloudEnabled) {
+        this.cloudEnabled = cloudEnabled;
+    }
 }

+ 14 - 6
src/main/java/com/uas/erp/database/service/MasterService.java

@@ -8,11 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 
 /**
@@ -44,13 +42,23 @@ public class MasterService implements InitializingBean{
         this.scanAll();
     }
 
-    public Set<Master> findAll() {
-        return masters;
+    public Set<Master> findAll(boolean cloudEnabled) {
+        if (!cloudEnabled) {
+            return masters;
+        }
+        Set<Master> cloudMasters = new LinkedHashSet<>();
+        for (Master master : masters) {
+            if (master.isCloudEnabled()) {
+                cloudMasters.add(master);
+            }
+        }
+        return cloudMasters;
     }
 
-    public Set<MasterView> findAllView() {
+    public Set<MasterView> findAllView(boolean cloudEnabled) {
         Set<MasterView> views = new LinkedHashSet<>();
-        for (Master master : masters) {
+        Set<Master> thisMasters = findAll(cloudEnabled);
+        for (Master master : thisMasters) {
             views.add(new MasterView(master));
         }
         return views;