admin
2019-06-13 25295657ad6d1675462f0b6814366417bbda6d99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.yeshi.fanli.controller.client.v1;
 
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.help.AppPageNotification;
import com.yeshi.fanli.service.inter.help.AppPageNotificationService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.VersionUtil;
 
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.JsonUtil;
 
@Controller
@RequestMapping("api/v1/help")
public class HelpController {
 
    @Resource
    private AppPageNotificationService appPageNotificationService;
 
    /**
     * 获取app页面的通知
     * 
     * @param acceptData
     * @param type
     * @param out
     */
    @RequestMapping(value = "getAppPageNotification")
    public void getAppPageNotification(AcceptData acceptData, String type, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(type)) {
            out.print(JsonUtil.loadFalseResult(1, "请上传类型"));
            return;
        }
 
        AppPageNotification ap = appPageNotificationService.getAppPageNotificationByTypeCache(type);
        if ("home".equalsIgnoreCase(type)
                && VersionUtil.smallerThan_1_5_1(acceptData.getPlatform(), acceptData.getVersion()) && ap != null) {
            AppPageNotification no = new AppPageNotification();
            no.setContentUrl("");
            no.setMd5("111111111111111111");
            no.setPageName(ap.getPageName());
            no.setShow(true);
            no.setType(ap.getType());
            no.setUpdateTime(ap.getUpdateTime());
            no.setCanClose(false);
            no.setContent("尊敬的用户,为更加准确高效的为你返利、省钱,请升级到返利券最新版本");
            Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
            out.print(JsonUtil.loadTrueResult(gson.toJson(no)));
            return;
        }
 
        // 没有通知
        if (ap == null || !ap.getShow()) {
            out.print(JsonUtil.loadFalseResult(2, "无通知"));
        } else {// 有通知
            Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
            out.print(JsonUtil.loadTrueResult(gson.toJson(ap)));
        }
    }
 
    @RequestMapping(value = "updateApp")
    public void updateApp(AcceptData acceptData, PrintWriter out) {
        Map<String, String> params = new HashMap<>();
        if ("android".equalsIgnoreCase(acceptData.getPlatform())) {// android更新
//            acceptData.setVersion("10");
            params.put("method", "update");
            params.put("Platform", "Android");
            params.put("Version", acceptData.getVersion());
            params.put("device  ", acceptData.getDevice());
            params.put("time", System.currentTimeMillis() + "");
            params.put("Package", acceptData.getPackages());
            params.put("device", acceptData.getDevice());
            params.put("platform", "Android");
            params.put("key", "a3f390d88e4c41f2747bfa2f1b5f87db");
            params.put("versionCode", acceptData.getVersion() + "");
            String url = "http://update.yeshitv.com:8090/update/update";
            String result = HttpUtil.post(url, params, null);
            try {
                out.print(new String(result.getBytes("ISO-8859-1"), "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                out.print(result);
            }
        } else {// IOS更新
            params.put("method", "update");
            params.put("Platform", "IOS");
            params.put("Version", acceptData.getVersion());
            params.put("device  ", acceptData.getDevice());
            params.put("time", System.currentTimeMillis() + "");
            params.put("Package", acceptData.getPackages());
            params.put("device", acceptData.getDevice());
            params.put("platform", "IOS");
            params.put("key", "32bb90e8976aab5298d5da10fe66f21d");
            params.put("versionCode", acceptData.getVersion() + "");
        }
        String url = "http://update.yeshitv.com:8090/update/update";
        String result = HttpUtil.post(url, params, null);
        try {
            out.print(new String(result.getBytes("ISO-8859-1"), "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            out.print(result);
        }
    }
 
}