首页>代码>基于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";
    }
}
最近下载更多
dmyafda  LV5 9月9日
wuying8208  LV13 7月1日
张真狗  LV9 6月10日
万紫怡  LV4 5月15日
齐凌霄  LV7 5月13日
sunlzh888888  LV28 4月23日
qwertytao123  LV3 4月21日
youzitao  LV11 4月16日
啦啦啦嘿嘿嘿  LV5 4月12日
最近浏览更多
漫步的海星  LV4 昨天
txf123  LV3 昨天
理想123456  LV1 9月13日
zhouye123  LV1 9月11日
xiao小果  LV11 9月11日
jeffqj 9月9日
暂无贡献等级
dmyafda  LV5 9月7日
WHY-small  LV13 8月28日
www2222  LV2 8月9日
飞呀飞呀飞不放  LV7 7月26日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友