yujian
2019-05-29 0588d6be74335f41c79a8d8e32dbd1c3d3e47fa3
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
package com.yeshi.fanli.controller.client.v1;
 
import java.io.PrintWriter;
 
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.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) {
            ap.setCanClose(false);
            ap.setContent("尊敬的用户,为更加准确高效的为你返利、省钱,请升级到返利券最新版本");
            Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
            out.print(JsonUtil.loadTrueResult(gson.toJson(ap)));
            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)));
        }
    }
 
}