InfoAction.java
4.15 KB
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.cjs.site.action.info;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.cjs.site.model.user.account.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mobile.device.Device;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cjs.site.dao.info.ArticleDao;
import com.cjs.site.dao.pub.BannerDao;
import com.cjs.site.util.lang.JsonUtil;
import com.cjs.site.util.web.PageUtils;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 资讯
*
* @author tongyufu
*
*/
@Controller
@RequestMapping("/info")
public class InfoAction {
@Autowired
private ArticleDao articleDao;
@Autowired
private BannerDao bannerDao;
@RequestMapping("/gonggao")
public String gonggao(@RequestParam Map<String, Object> params, Model model, Device device) {
if (device.isMobile()) {
model.addAttribute("pageRouter", "infolist");
return "/mobile/index.jsp";
}
params.put("type",0);
params = PageUtils.processPage(params);
// 托管公告、公告通知
params.put("cids", Arrays.asList(13, 24));
params.put("_total", articleDao.searchTotal(params));
model.addAttribute("gonggao", articleDao.search(params));
model.addAttribute("cid", 24);
model.addAttribute("params", params);
return "info/gonggao.jsp";
}
@RequestMapping("/gonggao2")
public String gonggao2(@RequestParam Map<String, Object> params, Model model, Device device, HttpServletRequest request, HttpServletResponse response) {
Object obj = request.getSession().getAttribute(UserInfo.USER);
if(obj == null) {
try {
request.getRequestDispatcher("/login").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
if (device.isMobile()) {
model.addAttribute("pageRouter", "infolist");
return "/mobile/index.jsp";
}
params.put("type",1);
params = PageUtils.processPage(params);
// 托管公告、公告通知
params.put("cids", Arrays.asList(13, 24));
params.put("_total", articleDao.searchTotal(params));
model.addAttribute("gonggao", articleDao.search(params));
model.addAttribute("cid", 24);
model.addAttribute("params", params);
return "info/gonggao2.jsp";
}
@RequestMapping("/news")
public String news(@RequestParam Map<String, Object> params, Model model) {
params = PageUtils.processPage(params);
params.put("cid", 25);
params.put("_total", articleDao.searchTotal(params));
model.addAttribute("news", articleDao.search(params));
model.addAttribute("params", params);
return "info/news.jsp";
}
/** 手机客户端公告列表 */
@RequestMapping("/moblieGongGao")
public @ResponseBody String moblieGongGao(@RequestParam Map<String, Object> params,
Model model) {
params.put("limit", Integer.parseInt(params.get("limit").toString()));
params.put("start", Integer.parseInt(params.get("start").toString()));
params.put("cids", Arrays.asList(13, 24, 25));
Map<String, Object> map = new HashMap<String, Object>();
map.put("gonggao", articleDao.search(params));
map.put("gonggao_total", articleDao.searchTotal(params));
map.put("params", params);
map.put("news", articleDao.searchOneNew());
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("type", 1);
map2.put("bannerLocation", 0);
map.put("banner", bannerDao.getBannerList(map2));
return JsonUtil.toJson(map);
}
}