首页>代码>基于springboot的员工宿舍管理系统>/src/main/java/com/lian/demo/controller/mainController.java
package com.lian.demo.controller;

import com.lian.demo.pojo.staff;
import com.lian.demo.pojo.user;
import com.lian.demo.service.StaffService;
import org.mybatis.spring.annotation.MapperScan;
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 org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class mainController {
    @Autowired
    private StaffService staffService;
    @RequestMapping(value = "/logout")
    public String logout(HttpSession session){
    session.invalidate();
    return "login";
    }

    @RequestMapping(value = "/tozhuce")
    public String tozhuce(){
    return "sign-up";
    }
    @RequestMapping(value ="/toDoctor-Patient" )
    public String toDoctorPatient(){
        return "toDoctor-patient";
    }
    @RequestMapping(value = "/toAdd")
    public String toAdd(){
        return "add-doctor";
    }
    @RequestMapping(value = "/baoxiu")
    public String baoxiu(){
        return "add-baoxiu";
    }
    @RequestMapping("/queryStaff")
    public ModelAndView queryStaff(){
        List<staff> patientList= staffService.AlistPatient();
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("patient",patientList);
        modelAndView.setViewName("patientsList");
        return modelAndView;
    }
    @RequestMapping(value = "/userLogin")
    public String userLogin(String username, String password, Model model, HttpSession session){
        user user=  staffService.login(username,password);
        String role = user.getRole();
        if (user!=null&&role.equals("用户")){
            session.setAttribute("user",user);
            return "index1";
        }if (user!=null&&role.equals("管理员")){
            session.setAttribute("user",user);
            return "index";
        }
        else{
            model.addAttribute("msg","用户名或密码错误");
            return "login";
        }

    }
    //注册
    @RequestMapping(value = "/sign")
    public String sign(user user){
        staffService.save(user);
        return "login";
    }
    @RequestMapping("/showlogin")
    public String showlogin(){
        return "login";
    }
    @RequestMapping(value = "/index")
    public String index(){
        return "index";
    }
}
最近下载更多
15953970869  LV6 2024年11月10日
微信网友_6786215447367680  LV5 2024年10月11日
xinxin23383  LV7 2024年9月13日
微信网友_6767218254057472  LV3 2024年7月3日
计科一班  LV7 2024年6月18日
wanglinddad  LV55 2024年5月11日
Luck_ZDM  LV12 2024年4月12日
together love  LV2 2024年3月26日
wsl566666  LV2 2024年2月20日
3311545828  LV3 2024年1月19日
最近浏览更多
SX520886  LV6 4月24日
暂无贡献等级
jiaoyuhang  LV1 3月28日
xiaohuaidan455  LV2 2月23日
54ty1212 1月6日
暂无贡献等级
zq1685  LV4 2024年12月20日
xp95323  LV15 2024年12月6日
15578157792  LV7 2024年11月28日
zolscy  LV24 2024年11月26日
krispeng  LV14 2024年11月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友