基于javaweb+mysql的springboot医疗挂号管理系统(java+springboot+freemarker+layui+maven+mysql)

基于javaweb+mysql的springboot医疗挂号管理系统(java+springboot+freemarker+layui+maven+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot医疗挂号管理系统(java+springboot+freemarker+layui+maven+mysql)

项目介绍

本系统分为管理员、医生、患者三种角色; 管理员角色包含以下功能: 管理员登录,医生患者管理,患者管理,药品管理,科目管理,疾病管理,预约管理,病史管理,住院信息管理,管理员管理等功能。

医生角色包含以下功能: 医生角色登录,查看预约的病例,开药,查看病史等功能。

患者角色包含以下功能: 患者角色首页,患者登录,查询信息,挂号预约,查看病史,查看住院信息等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:是;

技术栈

  1. 后端:SpringBoot 2. 前端:freemarker+CSS+JavaScript+jquery+layui

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
        response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(filename, "utf-8"));
        OutputStream outputStream = response.getOutputStream();
        workbook.write(outputStream);
        outputStream.flush();
        outputStream.close();
    }
}

@Controller
public class DrugsController {
    @Autowired
    DrugsService drugsService;
    @RequestMapping("admin/drugsManage")
    public String drugsManage(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="type",required = false) Integer type){
        request.setAttribute("name",name);
//        request.setAttribute("type",type);
        Drugs drugs=new Drugs();
        drugs.setName(name);
        drugs.setType(type);
        request.setAttribute("drugs",drugsService.getAllDrugs(drugs));
        return "/admin/drugsManage";
    }
    @RequestMapping(value = "/admin/drug/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delDrug(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",drugsService.delDrug(id));
        return json;
    }
    @RequestMapping(value = "/admin/drug",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject addDrug(@RequestBody Drugs drugs){
        JSONObject json=new JSONObject();
        json.put("message",drugsService.addDrug(drugs));
        return json;
    }
    @RequestMapping("/admin/drugAdd")
    public String drugAddPage(){
        return  "/admin/add/drugadd";
    }
    @RequestMapping(value = "/admin/drug/{id}",method = RequestMethod.GET)
    public String drugInfo(HttpServletRequest request,@PathVariable Integer id) {
        request.setAttribute("drug",drugsService.getDrug(id));
        HSSFCellStyle style = workbook.createCellStyle();
        HSSFFont font = workbook.createFont();
        font.setBold(true);
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setFont(font);

        HSSFCell cell;
        cell = row.createCell(0);
        cell.setCellValue("序号");
        cell.setCellStyle(style);

        cell = row.createCell(1);
        cell.setCellValue("楼层号");
        cell.setCellStyle(style);

        cell = row.createCell(2);
        cell.setCellValue("门牌号");
        cell.setCellStyle(style);

        cell = row.createCell(3);
        cell.setCellValue("床号");
        cell.setCellStyle(style);

        cell = row.createCell(4);
        cell.setCellValue("患者");
        cell.setCellStyle(style);

        cell = row.createCell(5);
        cell.setCellValue("患病");
        cell.setCellStyle(style);

        cell = row.createCell(6);
        cell.setCellValue("住院时间");
        cell.setCellStyle(style);

        cell = row.createCell(7);
        cell.setCellValue("出院时间");
        cell.setCellStyle(style);
    }

    //生成excel文件
    public static void buildExcelFile(String filename,HSSFWorkbook workbook) throws Exception{
        FileOutputStream fos = new FileOutputStream(filename);
        workbook.write(fos);
        fos.flush();

@Controller
public class IllnessController {
    @Autowired
    IllnessService illnessService;
    @RequestMapping("/admin/illnessManage")
    public String illnessManage(HttpServletRequest request){
        request.setAttribute("illnesses",illnessService.getAll());
        return "/admin/illnessManage";
    }
    @RequestMapping(value = "/admin/illness/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delIllness(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",illnessService.deleteIllness(id));
        return json;
    }
    @RequestMapping(value = "/admin/illness",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject addDrug(@RequestBody Illness illness){
        JSONObject json=new JSONObject();
        json.put("message",illnessService.insert(illness));
        return json;
    }
    @RequestMapping("/admin/illnessAdd")
    public String illnessAddPage(){
        return  "/admin/add/illnessadd";
    }
    @RequestMapping(value = "/admin/illness/{id}",method = RequestMethod.GET)
    public String illnessInfo(HttpServletRequest request,@PathVariable Integer id) {
        request.setAttribute("illness",illnessService.getIllness(id));
        return  "/admin/info/illnessinfo";
    }
    @RequestMapping(value = "/admin/illness",method = RequestMethod.PUT)
    @ResponseBody
    public JSONObject updateIllness(@RequestBody Illness illness) {
        JSONObject json=new JSONObject();
        json.put("message",illnessService.updateIllness(illness));
        request.setAttribute("doctorname",doctorname);
        request.setAttribute("patientname",patientname);
        request.setAttribute("medicalhistorys",medicalhistoryService.getAllMedicalhistorys(doctorname,patientname));
        return "admin/medicalhistoryManage";
    }
    @RequestMapping("/admin/medicalhistoryAdd")
    public String medicalhistoryAddPage(HttpServletRequest request){
        request.setAttribute("doctors",doctorService.getAllDoctor());
        request.setAttribute("patients",patientService.getAllPatients());
        return"admin/add/medicalhistoryadd";
    }
    @RequestMapping(value = "/admin/medicalhistory/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delmedicalhistory(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",medicalhistoryService.delMedicalhistory(id));
        return json;
    }
    @RequestMapping(value = "/admin/medicalhistory/{id}",method = RequestMethod.GET)
    public String medicalhistoryInfo(@PathVariable Integer id,HttpServletRequest request){
        request.setAttribute("patients",patientService.getAllPatients());
        request.setAttribute("doctors",doctorService.getAllDoctor());
        request.setAttribute("medicalhistory",medicalhistoryService.getMedicalhistory(id));
        return "admin/info/medicalhistoryInfo";
    }
    @RequestMapping(value = "/admin/medicalhistory",method = RequestMethod.PUT)
    @ResponseBody
    public JSONObject medicalhistoryUpdate(@RequestBody Medicalhistory medicalhistory){
        JSONObject json=new JSONObject();
        json.put("message",medicalhistoryService.UpdateMedicalhistory(medicalhistory));
        return json;
    }
    @RequestMapping(value = "/admin/medicalhistory",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject medicalhistoryAdd(@RequestBody Medicalhistory medicalhistory){
        JSONObject json=new JSONObject();
        json.put("message",medicalhistoryService.addMedicalhistory(medicalhistory));
        return json;
    }
}

        request.setAttribute("intime",intime);
        request.setAttribute("hospitalizations",hospitalizationService.getAllHospitalizations(patientname,intime));
        return "admin/hospitalizationManage";
    }
    @RequestMapping("/admin/hospitalizationAdd")
    public String hospitalizationAddPage(HttpServletRequest request){
        request.setAttribute("patients",patientService.getAllPatients());
        return"admin/add/hospitalizationadd";
    }
    @RequestMapping(value = "/admin/hospitalization",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject hospitalizationAdd(@RequestBody Hospitalization hospitalization){
        JSONObject json=new JSONObject();
        json.put("message",hospitalizationService.AddHospitalization(hospitalization));
        return json;
    }
    @RequestMapping(value = "/admin/hospitalization/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delHospitalization(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",hospitalizationService.deleteHospitalization(id));
        return json;
    }
    @RequestMapping(value = "/admin/hospitalization/{id}",method = RequestMethod.GET)
    public String hospitalizationInfo(HttpServletRequest request,@PathVariable Integer id){
        request.setAttribute("h",hospitalizationService.getHospitalization(id));
        request.setAttribute("patients",patientService.getAllPatients());
        return"admin/info/hospitalizationinfo";
    }
    @RequestMapping(value = "/admin/hospitalization",method = RequestMethod.PUT)
    @ResponseBody
    public JSONObject delHospitalization(@RequestBody Hospitalization hospitalization){
        JSONObject json=new JSONObject();
        json.put("message",hospitalizationService.updateHospitalization(hospitalization));
        return json;
    }
    //生成user表excel
    @GetMapping(value = "/admin/getHospitalization")
    public String getUser(HttpServletResponse response) throws Exception{
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("统计表");
        ExcelUtils.createTitle(workbook,sheet);
        List<Hospitalization> rows = hospitalizationService.getAllHospitalizations();
    }
    @RequestMapping(value = "/admin/admin",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject adminAdd(@RequestBody Login login){
        JSONObject json=new JSONObject();
        json.put("message",loginService.addAmin(login));
        return json;
    }
    @RequestMapping(value = "/admin/admin",method = RequestMethod.PUT)
    @ResponseBody
    public JSONObject upAdmin(@RequestBody Login login){
        JSONObject json=new JSONObject();
        json.put("message",loginService.updateAdmin(login));
        return json;
    }
    @RequestMapping(value = "/admin/admin/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delAdmin(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",loginService.delAdmin(id));
        return json;
    }
    @RequestMapping(value = "/loginout",method = RequestMethod.GET)
    public String loginout(HttpSession session){
        session.removeAttribute("login");
        return "/hospital";
    }
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject login(@RequestBody Login login,HttpSession session){
        JSONObject json=new JSONObject();
        json.put("message",loginService.login(login));
        session.setAttribute("login",login);
        return json;
    }
    @RequestMapping(value = "/regest",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject regest(@RequestBody Login login){
        JSONObject json=new JSONObject();
        json.put("message",loginService.regist(login));
        return json;
    }
    @RequestMapping("/hospital")
    public String hospital(){
        return "index";
    }
    @RequestMapping("/hospital/patient/index")
    public String patientIndex(){
        cell.setCellStyle(style);
    }

    //生成excel文件
    public static void buildExcelFile(String filename,HSSFWorkbook workbook) throws Exception{
        FileOutputStream fos = new FileOutputStream(filename);
        workbook.write(fos);
        fos.flush();
        fos.close();
    }

    //浏览器下载excel
    public static void buildExcelDocument(String filename, HSSFWorkbook workbook, HttpServletResponse response) throws Exception{
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(filename, "utf-8"));
        OutputStream outputStream = response.getOutputStream();
        workbook.write(outputStream);
        outputStream.flush();
        outputStream.close();
    }
}

@Controller
public class DrugsController {
    @Autowired
    DrugsService drugsService;
    @RequestMapping("admin/drugsManage")
    public String drugsManage(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="type",required = false) Integer type){
        request.setAttribute("name",name);
//        request.setAttribute("type",type);
    @RequestMapping("/admin/patientManage")
    public String patientlist(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="certId",required = false) String certId){
        request.setAttribute("name",name);
        request.setAttribute("certId",certId);
        request.setAttribute("patients",patientService.getAllPatients(name,certId));
        return "admin/patientManage";
    }
    @RequestMapping(value = "/admin/patient/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delPatient(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",patientService.delPatient(id));
        return json;
    }
    @RequestMapping(value = "/admin/patient/{id}",method = RequestMethod.GET)
    public String patientInfo(@PathVariable Integer id,HttpServletRequest request){
        request.setAttribute("patient",patientService.getPatient(id));
        request.setAttribute("appointments",appointmentService.getPatientMessage(id));
        request.setAttribute("hospitalizations",hospitalizationService.getPatientMessage(id));
        request.setAttribute("doctors",doctorService.getAllDoctor());
        return "admin/info/patientinfo";
    }
    @RequestMapping(value = "/admin/patientAdd",method = RequestMethod.GET)
    public String patientAddPage(){
        return "admin/add/patientadd";
    }
    @RequestMapping(value = "/admin/patient",method = RequestMethod.PUT)
    @ResponseBody
    public JSONObject patientInfo(@RequestBody Patient patient){
        JSONObject json=new JSONObject();
        json.put("message",patientService.updatePatient(patient));
        return json;
    }
    @RequestMapping(value = "/admin/patient",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject delPatient(@RequestBody Patient patient){
        JSONObject json=new JSONObject();
        json.put("message",patientService.addPatient(patient));
        return json;
    }
    }

}

@Controller
public class HospitalizationController {
    @Autowired
    HospitalizationService hospitalizationService;
    @Autowired
    PatientService patientService;
    @RequestMapping("/admin/hospitalizationManage")
    public String hospitalizationManage(HttpServletRequest request,@RequestParam(value = "patientname",required = false)String patientname,@RequestParam(value = "intime",required = false)String intime){
        request.setAttribute("patientname",patientname);
        request.setAttribute("intime",intime);
        request.setAttribute("hospitalizations",hospitalizationService.getAllHospitalizations(patientname,intime));
        return "admin/hospitalizationManage";
    }
    @RequestMapping("/admin/hospitalizationAdd")
    public String hospitalizationAddPage(HttpServletRequest request){
        request.setAttribute("patients",patientService.getAllPatients());
        return"admin/add/hospitalizationadd";
    }
    @RequestMapping(value = "/admin/hospitalization",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject hospitalizationAdd(@RequestBody Hospitalization hospitalization){
        JSONObject json=new JSONObject();
        json.put("message",hospitalizationService.AddHospitalization(hospitalization));
        return json;
        return "download excel";
    }
}

@Controller
public class LoginController {
    @Autowired
    LoginService loginService;
    @RequestMapping(value = "/hospital/login")
    public String loginAndregist(){
        return "login&regist";
    }
    @RequestMapping("/admin/adminManage")
    public String adminManage(HttpServletRequest request,@RequestParam(value = "username",required = false)String username){
        request.setAttribute("username",username);
        request.setAttribute("admins",loginService.findAllAdmin(username));
        return "/admin/adminManage";
    }
    @RequestMapping("/admin/admin/{id}")
    public String adminInfo(HttpServletRequest request,@PathVariable Integer id){
        request.setAttribute("admin",loginService.getAdmin(id));
        return "/admin/info/admininfo";
    }
    @RequestMapping("/admin/adminAdd")
    public String adminAddPage(){
        return"admin/add/adminadd";
    }
    @RequestMapping(value = "/admin/admin",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject adminAdd(@RequestBody Login login){
        JSONObject json=new JSONObject();
        return json;
    }
    @RequestMapping(value = "/admin/medicalhistory",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject medicalhistoryAdd(@RequestBody Medicalhistory medicalhistory){
        JSONObject json=new JSONObject();
        json.put("message",medicalhistoryService.addMedicalhistory(medicalhistory));
        return json;
    }
}

@Controller
public class AppointmentController {
    @Autowired
    AppointmentService appointmentService;
    @Autowired
    DoctorService doctorService;
    @Autowired
    PatientService patientService;
    @RequestMapping("/admin/appointmentManage")
    public String appointmentManage(HttpServletRequest request,@RequestParam(value = "doctorname",required = false)String doctorname,@RequestParam(value = "patientname",required = false)String patientname){
        request.setAttribute("doctorname",doctorname);
        request.setAttribute("patientname",patientname);
        List<Appointment> appointmentList=appointmentService.getAllAppointments(doctorname,patientname);
        request.setAttribute("appointments" ,appointmentList);
        return"admin/appointmentManage";
    }
    @RequestMapping("/admin/appointmentAdd")
    public String appointmentAddPage(HttpServletRequest request){
        request.setAttribute("patients",patientService.getAllPatients());
        //request.setAttribute("doctors",doctorService.getAllDoctor());

@Controller
public class DoctorController {
    @Autowired
    DoctorService doctorService;
    @Autowired
    AppointmentService appointmentService;
    @Autowired
    PatientService patientService;
    @Autowired
    DrugsService drugsService;
    @Autowired
    HospitalizationService hospitalizationService;
    @Autowired
    MedicalhistoryService medicalhistoryService;
    @Autowired
    OptionService optionService;
    @Autowired
    SeekService seekService;
    @Value("${filepath.seekpdfpath}")
    private String path;
    @RequestMapping("/admin/doctorManage")
    public String doctorManage(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="certId",required = false) String certId){
        request.setAttribute("name",name);
        request.setAttribute("certId",certId);
        request.setAttribute("doctors",doctorService.getAllDoctor(name,certId));
        return "admin/doctorManage";
    }
    @RequestMapping(value = "/admin/doctor/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delDoctor(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",doctorService.delDoctor(id));
        return json;
    }
    @RequestMapping(value = "/admin/doctor/{id}",method = RequestMethod.GET)
        JSONObject json=new JSONObject();
        json.put("message",hospitalizationService.AddHospitalization(hospitalization));
        return json;
    }
    @RequestMapping(value = "/doctor/medicalhistory/{id}")
    public String medicalhistory(@PathVariable Integer id,HttpServletRequest request){
        request.setAttribute("medicalhistorys",medicalhistoryService.getMedicalhistoryByPatientId(id));
        return "doctor/medicalhistory";
    }

    @RequestMapping( value = "/doctor/{department}",method = RequestMethod.GET)
    @ResponseBody
    public JSONObject getDoctorByDepartment(@PathVariable String department) throws UnsupportedEncodingException{
        JSONObject json=new JSONObject();
        department = URLDecoder.decode(department,"UTF-8");
        json.put("doctors",doctorService.getDoctorByDepartment(department));
        return json;
    }
    @RequestMapping( value = "/doctor/seekinfo",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject seekinfo(@RequestBody Map map){
        JSONObject json=new JSONObject();
        String message=doctorService.seekInfo(map);
        json.put("message",message);
        return json;
    }
    @RequestMapping( value = "/doctor/printseek/{id}",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject printseek(@PathVariable Integer id,HttpSession session){
        Login login=(Login)session.getAttribute("login");
        Doctor doctor=doctorService.getDoctorByLoginId(login.getId());
        JSONObject json=new JSONObject();
        Seek seek=seekService.getSeekByPatientId(id);
        seek.setPatientname(patientService.getPatient(id).getName());
        seek.setDoctorname(doctor.getName());
        //createSeekInfo,第三个参数填空字符串就是生成在项目根目录里面,要是想生成在别的路径,例:D:\\ 就是生成在D盘根目录
        path = Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(0,Thread.currentThread().getContextClassLoader().getResource("").getPath().length()-16)+"/";
        String message= PDFUtils.createSeekInfo(seek,optionService,path);
        json.put("message",message);
        return json;
    }

}

        //设置列宽,setColumnWidth的第二个参数要乘以256,这个参数的单位是1/256个字符宽度
        sheet.setColumnWidth(1,12*256);
        sheet.setColumnWidth(3,17*256);

        //设置为居中加粗
        HSSFCellStyle style = workbook.createCellStyle();
        HSSFFont font = workbook.createFont();
        font.setBold(true);
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setFont(font);

        HSSFCell cell;
        cell = row.createCell(0);
        cell.setCellValue("序号");
        cell.setCellStyle(style);

        cell = row.createCell(1);
        cell.setCellValue("楼层号");
        cell.setCellStyle(style);

        cell = row.createCell(2);
        cell.setCellValue("门牌号");
        cell.setCellStyle(style);

        cell = row.createCell(3);
        cell.setCellValue("床号");
        cell.setCellStyle(style);

        cell = row.createCell(4);
        cell.setCellValue("患者");
        cell.setCellStyle(style);

        cell = row.createCell(5);
        cell.setCellValue("患病");
        cell.setCellStyle(style);

        cell = row.createCell(6);
        cell.setCellValue("住院时间");
        cell.setCellStyle(style);

        cell = row.createCell(7);
        cell.setCellValue("出院时间");
        cell.setCellStyle(style);
    }

//        request.setAttribute("type",type);
        Drugs drugs=new Drugs();
        drugs.setName(name);
        drugs.setType(type);
        request.setAttribute("drugs",drugsService.getAllDrugs(drugs));
        return "/admin/drugsManage";
    }
    @RequestMapping(value = "/admin/drug/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delDrug(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",drugsService.delDrug(id));
        return json;
    }
    @RequestMapping(value = "/admin/drug",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject addDrug(@RequestBody Drugs drugs){
        JSONObject json=new JSONObject();
        json.put("message",drugsService.addDrug(drugs));
        return json;
    }
    @RequestMapping("/admin/drugAdd")
    public String drugAddPage(){
        return  "/admin/add/drugadd";
    }
    @RequestMapping(value = "/admin/drug/{id}",method = RequestMethod.GET)
    public String drugInfo(HttpServletRequest request,@PathVariable Integer id) {
        request.setAttribute("drug",drugsService.getDrug(id));
        return  "/admin/info/drugsinfo";
    }
    @RequestMapping(value = "/admin/drug",method = RequestMethod.PUT)
    @ResponseBody
    public JSONObject updateDrug(@RequestBody Drugs drugs) {
        JSONObject json=new JSONObject();
        json.put("message",drugsService.updateDrug(drugs));
        return  json;
    }
}

 
 
@Component
            //这个方法返回false表示忽略当前请求,如果一个用户调用了需要登陆才能使用的接口,如果他没有登陆这里会直接忽略掉
            //当然你可以利用response给用户返回一些提示信息,告诉他没登陆
            response.sendRedirect("/hospital/login");
            return false;
        }else {
            return true;    //如果session里有login,表示该用户已经登陆,放行,用户即可继续调用自己需要的接口
        }
    }
 
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
    }
 
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
    }
}

@Controller
public class IllnessController {
    @Autowired
    IllnessService illnessService;
    @RequestMapping("/admin/illnessManage")
    public String illnessManage(HttpServletRequest request){
        request.setAttribute("illnesses",illnessService.getAll());
        return "/admin/illnessManage";
    }
    @RequestMapping(value = "/admin/illness/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delIllness(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",illnessService.deleteIllness(id));
        return json;
    }
    @RequestMapping(value = "/admin/illness",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject addDrug(@RequestBody Illness illness){
        JSONObject json=new JSONObject();
        json.put("message",illnessService.insert(illness));
        return json;
    OptionService optionService;
    @Autowired
    SeekService seekService;
    @Value("${filepath.seekpdfpath}")
    private String path;
    @RequestMapping("/admin/doctorManage")
    public String doctorManage(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="certId",required = false) String certId){
        request.setAttribute("name",name);
        request.setAttribute("certId",certId);
        request.setAttribute("doctors",doctorService.getAllDoctor(name,certId));
        return "admin/doctorManage";
    }
    @RequestMapping(value = "/admin/doctor/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public JSONObject delDoctor(@PathVariable Integer id){
        JSONObject json=new JSONObject();
        json.put("message",doctorService.delDoctor(id));
        return json;
    }
    @RequestMapping(value = "/admin/doctor/{id}",method = RequestMethod.GET)
    public String doctorInfo(@PathVariable Integer id,HttpServletRequest request){
        request.setAttribute("doctor",doctorService.getDoctor(id));
        return "admin/info/doctorinfo";
    }
    @RequestMapping(value = "/admin/doctor",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject AddDoctor(@RequestBody Doctor doctor){
        JSONObject json=new JSONObject();
        json.put("message",doctorService.addDoctor(doctor));
        return json;
    }
    @RequestMapping(value = "/admin/doctor",method = RequestMethod.PUT)
    @ResponseBody
    public JSONObject updateDoctor(@RequestBody Doctor doctor){
        JSONObject json=new JSONObject();
        json.put("message",doctorService.upDoctor(doctor));
        return json;
    }
    @RequestMapping("/admin/doctorAdd")
    public String doctorAddPage(){
        return "admin/add/doctoradd";
    }

    @RequestMapping("/doctor/seekMedicalAdvice")
    public String seekMedicalAdvice(HttpServletRequest request, HttpSession session,@RequestParam(value = "patientname",required = false)String patientname,@RequestParam(value = "time",required = false)String time){
        Login login=(Login)session.getAttribute("login");
        Doctor doctor=doctorService.getDoctorByLoginId(login.getId());
        request.setAttribute("appointments" ,appointmentService.selectByDoctorId(doctor.getId(),patientname,time));
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setFont(font);

        HSSFCell cell;
        cell = row.createCell(0);
        cell.setCellValue("序号");
        cell.setCellStyle(style);

        cell = row.createCell(1);
        cell.setCellValue("楼层号");
        cell.setCellStyle(style);

        cell = row.createCell(2);
        cell.setCellValue("门牌号");
        cell.setCellStyle(style);

        cell = row.createCell(3);
        cell.setCellValue("床号");
        cell.setCellStyle(style);

        cell = row.createCell(4);
        cell.setCellValue("患者");
        cell.setCellStyle(style);

        cell = row.createCell(5);
        cell.setCellValue("患病");
        cell.setCellStyle(style);

        cell = row.createCell(6);
        cell.setCellValue("住院时间");
        cell.setCellStyle(style);

        cell = row.createCell(7);
        cell.setCellValue("出院时间");
        cell.setCellStyle(style);
    }

    //生成excel文件
    public static void buildExcelFile(String filename,HSSFWorkbook workbook) throws Exception{
        FileOutputStream fos = new FileOutputStream(filename);
        workbook.write(fos);
        fos.flush();
        fos.close();
    }

    //浏览器下载excel
    public static void buildExcelDocument(String filename, HSSFWorkbook workbook, HttpServletResponse response) throws Exception{
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(filename, "utf-8"));
        OutputStream outputStream = response.getOutputStream();
        workbook.write(outputStream);
        outputStream.flush();
        outputStream.close();

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值