yujian
2019-11-26 2d3afb55aed07f9780ab46aefbdc7d520cdff576
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
package com.yeshi.fanli.controller.admin;
 
import java.io.PrintWriter;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.JsonUtil;
 
import com.google.gson.Gson;
import com.yeshi.fanli.dto.msg.MsgCommonDTO;
import com.yeshi.fanli.exception.config.ConfigException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.msg.MsgConfigService;
 
@Controller
@RequestMapping("admin/new/api/v1/message")
public class MessageController {
 
    @Resource
    private ConfigService configService;
 
    @Resource
    private MsgConfigService msgConfigService;
 
    @RequestMapping(value = "getZhuShou")
    public void getZhuShou(String callback, PrintWriter out) {
        // 板栗快省小助手
        MsgCommonDTO zhuShouMsg = msgConfigService.getZhuShouMsg();
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(new Gson().toJson(zhuShouMsg)));
    }
 
    @RequestMapping(value = "saveZhuShou", method = RequestMethod.POST)
    public void saveZhouShou(String callback, MsgCommonDTO dto, PrintWriter out) {
        if (dto.getJumpDetail() == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请指定跳转方式"));
            return;
        }
        try {
            msgConfigService.addZhuShouMsg(dto);
        } catch (ConfigException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
            return;
        }
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
    }
 
    @RequestMapping(value = "getGuanXuan", method = RequestMethod.POST)
    public void getGuanXuan(String callback, PrintWriter out) {
        MsgCommonDTO guanXuan = msgConfigService.getGuanXuanMsg();
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(new Gson().toJson(guanXuan)));
    }
 
    @RequestMapping(value = "saveGuanXuan", method = RequestMethod.POST)
    public void saveGuanXuan(String callback, MsgCommonDTO dto, PrintWriter out) {
        if (dto.getJumpDetail() == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请指定跳转方式"));
            return;
        }
        try {
            msgConfigService.addGuanXuanMsg(dto);
        } catch (ConfigException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
            return;
        }
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
    }
 
}