首页>代码>基于Spring+Spring MVC+Mybatis开发的社区论坛系统>/Genesis-master/src/main/java/com/withstars/controller/MainController.java
package com.withstars.controller;

import com.withstars.domain.Tab;
import com.withstars.service.impl.ReplyServiceImpl;
import com.withstars.service.impl.TabServiceImpl;
import com.withstars.service.impl.TopicServiceImpl;
import com.withstars.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.jws.WebParam;
import java.util.List;

/**
 * 主控制类
 */
@Controller
public class MainController {

    @Autowired
    public TopicServiceImpl topicService;
    @Autowired
    public ReplyServiceImpl replyService;
    @Autowired
    public UserServiceImpl userService;
    @Autowired
    public TabServiceImpl tabService;

    /**
     * 进入登录页面.
     */
    @RequestMapping(value = {"/signin"})
    public ModelAndView signin(){
        ModelAndView signinPage=new ModelAndView("signin");

        //获取统计信息
        int topicsNum=topicService.getTopicsNum();
        int usersNum=userService.getUserCount();

        signinPage.addObject("topicsNum",topicsNum);
        signinPage.addObject("usersNum",usersNum);
        return  signinPage;
    }

    /**
     * 进入注册页面.
     */
    @RequestMapping("/signup")
    public ModelAndView signup(){
        ModelAndView signupPage=new ModelAndView("signup");

        //获取统计信息
        int topicsNum=topicService.getTopicsNum();
        int usersNum=userService.getUserCount();

        signupPage.addObject("topicsNum",topicsNum);
        signupPage.addObject("usersNum",usersNum);
        return  signupPage;
    }

    /**
     * 进入新建主题页面
     */
    @RequestMapping(value = {"/new"})
    public ModelAndView newTopic(){
        ModelAndView newTopicPage=new ModelAndView("new");
        List<Tab> tabs=tabService.getAllTabs();

        //获取统计信息
        int topicsNum=topicService.getTopicsNum();
        int usersNum=userService.getUserCount();

        newTopicPage.addObject("tabs",tabs);
        newTopicPage.addObject("topicsNum",topicsNum);
        newTopicPage.addObject("usersNum",usersNum);
        return  newTopicPage;
    }

    /**
     * 配置404页面
     */
    @RequestMapping("*")
    public String notFind(){
        return "404";
    }
}
最近下载更多
段池卿  LV4 5月23日
玖零定制问题修复  LV34 2024年3月3日
ewan007  LV30 2024年2月25日
2897744513  LV2 2023年12月31日
lilong007  LV23 2023年12月30日
wang123999  LV19 2023年12月5日
liuyuheng  LV17 2023年11月15日
全栈小白  LV35 2023年11月6日
Seaskye  LV14 2023年11月4日
Dramaaaa  LV3 2023年11月4日
最近浏览更多
潜心小白来到  LV3 6月10日
段池卿  LV4 5月23日
月牙君  LV1 4月25日
PLVAE_514  LV2 3月7日
ChanLain  LV2 3月3日
andy_伟  LV6 2月25日
asdfg01234  LV10 1月10日
meng123wei 1月6日
暂无贡献等级
weishenme1993  LV9 1月1日
srmess  LV4 2024年12月30日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友