Browse Source

@自优化@laijj@RN获取信息处理逻辑优化

赖骏劼 3 years ago
parent
commit
d980f2555d
1 changed files with 1 additions and 73 deletions
  1. 1 73
      show-server/src/main/java/com/ai/ipu/show/bean/BundleBean.java

+ 1 - 73
show-server/src/main/java/com/ai/ipu/show/bean/BundleBean.java

@ -28,67 +28,7 @@ public class BundleBean extends IpuAppBean{
28 28
29 29
30 30
31
    /**
32
     * 根据服务端的信息表与传入app参数对比,计算返回的更新信息
33
     * @param {"appV":"1","bundleV":"1.1","platform":"Android"}
34
     * @return  {"status":"0","latestBundleV":"2.3","latestAppMinV":"2","canUpdate":"true","canUpdateBundle":"1.3","canUpdateAppMinV":"1","patchUrl":"http://www.xxx.xxx/xxx","des":"一些备注","platForm":"Android"}
35
     */
36
    private IData calUpdate(IData params){
37
        IData results = new DataMap();
38
        String appV = params.getString("appV");
39
        String appBundleV = params.getString("bundleV");
40
        String platForm = params.getString("platform");
41
        //获取后台信息进行匹配
42
        String des = null;
43
        //1.appV判断是否可以更新
44
        List<String> appVs = getAppVs(platForm);
45
        List<Integer> appVIns = new ArrayList<Integer>();
46
        for(String s:appVs){
47
            appVIns.add(Integer.parseInt(s));
48
        }
49
        if(appVIns.size() <= 0){
50
            results.put("status","-1");
51
            results.put("des","没有获取到任何App版本信息");
52
            return results;
53
        }
54
        int minApp = Collections.min(appVIns);
55
        int maxApp = Collections.max(appVIns);
56
        boolean noLowThanMinApp = Integer.parseInt(appV) >= minApp;//不低于最低app版本
57
        boolean isAppUpdate = false;
58
        boolean canUpdate = false;
59
        //2.bundleV判断提供哪个patches版本或bundle,或者不用更新
60
        if(noLowThanMinApp){
61
            String lastestBundleV = queryLastestBundleV(appV,platForm);//获取此app版本下最新bundle版本
62
            results.put("lastestBundleV",lastestBundleV);
63
            if(Float.parseFloat(appBundleV) < Float.parseFloat(lastestBundleV)){
64
                String patchUrl = queryUpdatePatch(appBundleV,lastestBundleV,platForm);
65
                des =  "可以更新," + "当前App版本"+ appV + "支持最新Bundle版本" + lastestBundleV;
66
                results.put("patchUrl",patchUrl);
67
                canUpdate = true;
68
            }else{
69
                canUpdate = false;
70
                des = "不能更新," + "已经是当前App版本"+ appV + "的最新Bundle版本";
71
            }
72
            if(Integer.parseInt(appV) < maxApp){//appV低于最高版本appV
73
                des = des + ";最新的App版本为" + maxApp;
74
                String appUrl = queryLastestAppUrl();
75
                results.put("appUrl",appUrl);
76
                isAppUpdate = true;
77
            }
78
        }else {
79
                canUpdate = false;
80
                des = "不能更新,低于最低App版本" + minApp +  ";可更新到最新的App版本" + maxApp;
81
                String appUrl = queryLastestAppUrl();
82
                results.put("appUrl",appUrl);
83
                isAppUpdate = true;
84
        }
85
        //3.拼接结果
86
        results.put("status","0");
87
        results.put("canUpdate",canUpdate);
88
        results.put("isAppUpdate",isAppUpdate);
89
        results.put("des",des);
90
        return results;
91
    }
31
92 32
93 33
94 34
    /**
@ -150,18 +90,6 @@ public class BundleBean extends IpuAppBean{
150 90
        return result;
151 91
    }
152 92
153
154
    /**
155
     * 返回对应App能拿到的更新信息
156
     * @param {"appV":"1","bundleV":"1.1","platform":"Android"}
157
     * @return {"status":"0","latestBundleV":"2.3","latestAppMinV":"2","canUpdate":"true","canUpdateBundle":"1.3","canUpdateAppMinV":"1","patchUrl":"http://www.xxx.xxx/xxx","des":"一些备注","platForm":"Android"}
158
     */
159
    public IData getPatchInfo(IData params){
160
        IData results = null;
161
        results = calUpdate(params);
162
        return results;
163
    }
164
165 93
    /**
166 94
     * 读取获取对应的更新包
167 95
     * @param appBunleV