HomeAction.java
4.51 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package com.cjs.site.action.pub;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.cjs.site.dao.entrust.EntrustDataDao;
import com.cjs.site.dao.entrust.OtcCodeDao;
import com.cjs.site.dao.info.ArticleCategoryDao;
import com.cjs.site.dao.info.ArticleDao;
import com.cjs.site.dao.pub.BannerDao;
import com.cjs.site.model.article.ArticleCategoryInfo;
import com.cjs.site.model.article.ArticleInfo;
import com.cjs.site.model.entrust.EntrustDataInfo;
import com.cjs.site.util.web.PageUtils;
/**
* 首页
*
* @author tongyufu
*
*/
@Controller
public class HomeAction {
Logger log = LogManager.getLogger();
@Autowired
private ArticleDao articleDao;
@Autowired
private EntrustDataDao entrustDao;
@Autowired
private BannerDao bannerDao;
@Autowired
private ArticleCategoryDao articleCategoryDao;
@Autowired
private OtcCodeDao otcCodeDao;
@RequestMapping("/")
public String home(Model model, HttpServletRequest request, HttpServletResponse response) {
this.handlerRequest(request, response);
Map<String, Object> params = new HashMap<String, Object>();
params.put("_limit", 5);
params = PageUtils.processPage(params);
// 托管公告、公告通知
params.put("cids", Arrays.asList(13, 24));
List<ArticleInfo> list = articleDao.search(params);
model.addAttribute("gonggao",list );
params.remove("cids");
if(list.size()>0){
model.addAttribute("showggBox",articleDao.queryById(list.get(0).getId()));
}
/** 新闻动态 */
params.put("cid", 25);
model.addAttribute("news", articleDao.search(params));
model.addAttribute("newCategoryId", 25);
/** 托管数据 */
//model.addAttribute("entrusts", entrustDao.getEntrustList());
model.addAttribute("entrusts", this.queryMinSellPrice());
/** 首页广告图片 */
Map<String, Object> map = new HashMap<String, Object>();
map.put("type", 0);
map.put("bannerLocation", 0);
model.addAttribute("banners", bannerDao.getBannerList(map));
/**首页行情banner*/
map.put("type", 0);
map.put("bannerLocation", 1);
model.addAttribute("hangqingB", bannerDao.getBannerList(map));
model.addAttribute("bannerBottom", bannerDao.queryBannerById(71));
model.addAttribute("bannerRight", bannerDao.queryBannerById(72));
/**友情链接*/
ArticleCategoryInfo categoryInfo = articleCategoryDao.queryByName("友情链接");
Map<String, Object> articleParams = new HashMap<String, Object>();
articleParams.put("_limit", 1000);
articleParams = PageUtils.processPage(articleParams);
articleParams.put("categoryId", categoryInfo.getId());
List<ArticleInfo> youqingArticles = articleDao.queryByCategoryId(articleParams);
model.addAttribute("youqingArticles", youqingArticles);
//return "index.jsp";
return "redirect:/user/balance";
}
/**
* 301跳转
*
* @param request
* @param response
*/
private void handlerRequest(HttpServletRequest request, HttpServletResponse response) {
String url = request.getRequestURL().toString();
if (url.contains("cangjs")) {
log.info("old url:" + url);
response.setStatus(301);
response.setHeader("Location", "http://www.zhao.com/");
response.setHeader("Connection", "close");
}
}
private List<Map<String, Object>> queryMinSellPrice() {
List<Map<String, Object>> otcs = otcCodeDao.queryLastPrice();
List<EntrustDataInfo> datas = entrustDao.getEntrustList();
for (Map<String, Object> otc : otcs) {
for (EntrustDataInfo data : datas) {
if (StringUtils.equals(otc.get("SDC_CODE").toString(), data.getEntrustId())) {
otc.put("IMAGE", data.getEntrustImage());
break;
}
}
}
return otcs;
}
}