//
// Decompiled by Procyon v0.5.29
//
package com.action;
import com.entity.Topic;
import com.entity.Orders;
import com.entity.Details;
import com.entity.City;
import com.entity.Cart;
import com.util.VeDate;
import com.entity.Users;
import com.entity.Article;
import java.util.Iterator;
import java.util.ArrayList;
import com.entity.Jiancai;
import com.entity.Cate;
import java.util.List;
import java.util.Collections;
import com.service.TopicService;
import com.service.DetailsService;
import com.service.OrdersService;
import com.service.CartService;
import com.service.JiancaiService;
import com.service.PeihuoService;
import com.service.CityService;
import com.service.CateService;
import com.service.ArticleService;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import com.service.UsersService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
@Controller
@RequestMapping({ "/index" })
public class IndexAction extends BaseAction
{
@Autowired
@Resource
private UsersService usersService;
@Autowired
@Resource
private ArticleService articleService;
@Autowired
@Resource
private CateService cateService;
@Autowired
@Resource
private CityService cityService;
@Autowired
@Resource
private PeihuoService peihuoService;
@Autowired
@Resource
private JiancaiService jiancaiService;
@Autowired
@Resource
private CartService cartService;
@Autowired
@Resource
private OrdersService ordersService;
@Autowired
@Resource
private DetailsService detailsService;
@Autowired
@Resource
private TopicService topicService;
private void front() {
this.getRequest().setAttribute("title", (Object)"\u9f99\u57ce\u5efa\u6750\u7f51-\u529b\u4f5c\u4e2d\u56fd\u6700\u5927\u7684\u5efa\u6750\u7f51\u7ad9");
final List<Cate> cateList = this.cateService.getAllCate();
this.getRequest().setAttribute("cateList", (Object)cateList);
final List<Jiancai> hotList = this.jiancaiService.getJiancaiByHot();
Collections.shuffle(hotList);
this.getRequest().setAttribute("hotList", (Object)hotList);
}
@RequestMapping({ "index.action" })
public String index() {
this.front();
final List<Cate> cateList = this.cateService.getCateFront();
final List<Cate> frontList = new ArrayList<Cate>();
for (final Cate cate : cateList) {
final List<Jiancai> flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
cate.setFlimList(flimList);
frontList.add(cate);
}
this.getRequest().setAttribute("frontList", (Object)frontList);
return "users/index";
}
@RequestMapping({ "network.action" })
public String network() {
this.front();
final List<Cate> cateList = this.cateService.getCateFront();
final List<Cate> frontList = new ArrayList<Cate>();
for (final Cate cate : cateList) {
final List<Jiancai> flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
cate.setFlimList(flimList);
frontList.add(cate);
}
this.getRequest().setAttribute("frontList", (Object)frontList);
return "users/network";
}
@RequestMapping({ "article.action" })
public String article(String number) {
this.front();
final List<Article> articleList = new ArrayList<Article>();
final List<Article> tempList = this.articleService.getAllArticle();
int maxPage;
final int pageNumber = maxPage = tempList.size();
if (maxPage % 12 == 0) {
maxPage /= 12;
}
else {
maxPage = maxPage / 12 + 1;
}
if (number == null) {
number = "0";
}
final int start = Integer.parseInt(number) * 12;
int over = (Integer.parseInt(number) + 1) * 12;
final int count = pageNumber - over;
if (count <= 0) {
over = pageNumber;
}
for (int i = start; i < over; ++i) {
final Article x = tempList.get(i);
articleList.add(x);
}
String html = "";
final StringBuffer buffer = new StringBuffer();
buffer.append(" \u5171\u4e3a");
buffer.append(maxPage);
buffer.append("\u9875 \u5171\u6709");
buffer.append(pageNumber);
buffer.append("\u6761 \u5f53\u524d\u4e3a\u7b2c");
buffer.append(Integer.parseInt(number) + 1);
buffer.append("\u9875 ");
if (Integer.parseInt(number) + 1 == 1) {
buffer.append("\u9996\u9875");
}
else {
buffer.append("<a href=\"index/article.action?number=0\">\u9996\u9875</a>");
}
buffer.append(" ");
if (Integer.parseInt(number) + 1 == 1) {
buffer.append("\u4e0a\u4e00\u9875");
}
else {
buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) - 1) + "\">\u4e0a\u4e00\u9875</a>");
}
buffer.append(" ");
if (maxPage <= Integer.parseInt(number) + 1) {
buffer.append("\u4e0b\u4e00\u9875");
}
else {
buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) + 1) + "\">\u4e0b\u4e00\u9875</a>");
}
buffer.append(" ");
if (maxPage <= Integer.parseInt(number) + 1) {
buffer.append("\u5c3e\u9875");
}
else {
buffer.append("<a href=\"index/article.action?number=" + (maxPage - 1) + "\">\u5c3e\u9875</a>");
}
html = buffer.toString();
this.getRequest().setAttribute("html", (Object)html);
this.getRequest().setAttribute("articleList", (Object)articleList);
return "users/article";
}
@RequestMapping({ "read.action" })
public String read(final String id) {
this.front();
final Article article = this.articleService.getArticleById(id);
article.setHits(new StringBuilder().append(Integer.parseInt(article.getHits()) + 1).toString());
this.articleService.updateArticle(article);
this.getRequest().setAttribute("article", (Object)article);
return "users/read";
}
@RequestMapping({ "preLogin.action" })
public String prelogin() {
this.front();
return "users/login";
}
@RequestMapping({ "login.action" })
public String login() {
this.front();
final String username = this.getRequest().getParameter("username");
final String password = this.getRequest().getParameter("password");
final Users u = new Users();
u.setUsername(username);
final List<Users> usersList = this.usersService.getUsersByCond(u);
if (usersList.size() == 0) {
this.getSession().setAttribute("message", (Object)"\u7528\u6237\u540d\u4e0d\u5b58\u5728");
return "redirect:/index/preLogin.action";
}
final Users users = usersList.get(0);
if (password.equals(users.getPassword())) {
this.getSession().setAttribute("userid", (Object)users.getUsersid());
this.getSession().setAttribute("username", (Object)users.getUsername());
this.getSession().setAttribute("users", (Object)users);
return "redirect:/index/index.action";
}
this.getSession().setAttribute("message", (Object)"\u5bc6\u7801\u9519\u8bef");
return "redirect:/index/preLogin.action";
}
@RequestMapping({ "preReg.action" })
public String pre