基于javaweb+mysql的springboot医院管理系统(java+springboot+layui+freemaker+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot医院管理系统(java+springboot+layui+freemaker+maven+mysql)
项目介绍
医院管理系统,分为管理员、医生、病人三种角色;
管理员主要功能包括: 首页、系统管理:医生管理、患者管理、药品管理;预约管理;病史管理;住院信息管理;管理员用户管理; 医生主要功能包括:首页、就医/查看病史;
病人主要功能包括:首页、病史、住院信息、挂号;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7版本;
技术栈
- 后端:SpringBoot
- 前端:Layui+Freemaker
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
- 使用IDEA/Eclipse/MyEclipse导入项目
- 将项目中application.yml配置文件中的数据库配置改为自己的配置然后运行;
- 运行项目,输入http://localhost:8088 登录
@Autowired
MedicalhistoryService medicalhistoryService;
@RequestMapping("/admin/doctorManage")
public String doctorManage(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="certId",required = false) String 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));
return "doctor/seekMedicalAdvice";
}
@RequestMapping("/doctor/seek/{id}")@RequestMapping(value = "/login",method = RequestMethod.POST)
@ResponseBody
public JSONObject login(@RequestBody Login login,HttpSession session){
// 生成登录验证用到的token对象
UsernamePasswordToken token = new UsernamePasswordToken(login.getUsername(), login.getPassword());
Subject subject = SecurityUtils.getSubject();
//登录验证
subject.login(token);
String login1 = loginService.login(login);
JSONObject json=new JSONObject();
json.put("message",login1);
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/patient/index")
public String patientIndex(){
return "/patient/index";
}
@RequestMapping("/hospital/doctor/index")
public String doctorIndex(){
return "/doctor/index";
}
@RequestMapping("/hospital/admin/index")
public String adminIndex(){
return "/admin/index";
}
}/*定义shiro过滤链 Map结构
* Map中key(xml中是指value值)的第一个'/'代表的路径是相对于HttpServletRequest.getContextPath()的值来的
* anon:它对应的过滤器里面是空的,什么都没做,这里.do和.jsp后面的*表示参数,比方说login.jsp?main这种
* authc:该过滤器下的页面必须验证后才能访问,它是Shiro内置的一个拦截器org.apache.shiro.web.filter.authc.FormAuthenticationFilter
*/
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
// 配置退出过滤器,其中的具体的退出代码Shiro已经替我们实现了
filterChainDefinitionMap.put("/resources/**", "anon");
filterChainDefinitionMap.put("/static/**", "anon");
filterChainDefinitionMap.put("/logout", "logout");
// filterChainDefinitionMap.put("/", "anon");
// <!-- 过滤链定义,从上向下顺序执行,一般将 /**放在最为下边 -->:这是一个坑呢,一不小心代码就不好使了;
// <!-- authc:所有url都必须认证通过才可以访问; anon:所有url都都可以匿名访问-->
filterChainDefinitionMap.put("/hospital/**", "anon");
// filterChainDefinitionMap.put("/upload/upload", "anon");
filterChainDefinitionMap.put("/login/**", "anon");
// filterChainDefinitionMap.put("/manager/getCurrentManager", "anon");
//其余全部认证
filterChainDefinitionMap.put("/**", "authc");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
/**
* 不指定名字的话,自动创建一个方法名第一个字母小写的bean
* @Bean(name = "securityManager")
* @return
*/
@Bean
public SecurityManager securityManager() {
S_LOGGER.info("注入Shiro的Web过滤器-->securityManager", ShiroFilterFactoryBean.class);
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//securityManager.setRealm(userRealm());
securityManager.setSessionManager(sessionManager());
return securityManager;
}
/**
* 定义session管理
*/
@Bean
public SessionManager sessionManager() {
// Shiro 提供了三个默认实现 基于默认 基于Servlet环境 基于自身
MySessionManager sessionManager = new MySessionManager();
// 这里可以不设置。Shiro有默认的session管理。如果缓存为Redis则需改用Redis的管理
sessionManager.setSessionDAO(new MemorySessionDAO());
// 开启定期清除session
sessionManager.setGlobalSessionTimeout(3 * 60 * 60 * 1000);
// sessionManager.setGlobalSessionTimeout(10000);
sessionManager.setSessionValidationSchedulerEnabled(true);
return sessionManager;* @return
*/
@Bean
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor(){
return new LifecycleBeanPostProcessor();
}
/**
* 开启Shiro的注解(如@RequiresRoles,@RequiresPermissions),需借助SpringAOP扫描使用Shiro注解的类,并在必要时进行安全逻辑验证
* 配置以下两个bean(DefaultAdvisorAutoProxyCreator(可选)和AuthorizationAttributeSourceAdvisor)即可实现此功能
* @return
*/
@Bean
@DependsOn({"lifecycleBeanPostProcessor"})
public DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator(){
DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
advisorAutoProxyCreator.setProxyTargetClass(true);
return advisorAutoProxyCreator;
}
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(){
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager());
return authorizationAttributeSourceAdvisor;
}
}
@Controller
public class PatientController {
@Autowired
PatientService patientService;
@Autowired
DoctorService doctorService;
@Autowired
AppointmentService appointmentService;
@Autowired
HospitalizationService hospitalizationService;
@Autowiredjson.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));
return "doctor/seekMedicalAdvice";
}
@RequestMapping("/doctor/seek/{id}")
public String seek(@PathVariable Integer id,HttpServletRequest request){
request.setAttribute("patient",patientService.getPatient(id));
request.setAttribute("drugs",drugsService.getAllDrugs());
return "doctor/seek";
}
@RequestMapping(value = "/doctor/drug",method = RequestMethod.PUT)
@ResponseBody
public JSONObject drug(@RequestBody Map map){
JSONObject json=new JSONObject();
Patient patient=new Patient();
System.out.println(map);/**
* 开启Shiro的注解(如@RequiresRoles,@RequiresPermissions),需借助SpringAOP扫描使用Shiro注解的类,并在必要时进行安全逻辑验证
* 配置以下两个bean(DefaultAdvisorAutoProxyCreator(可选)和AuthorizationAttributeSourceAdvisor)即可实现此功能
* @return
*/
@Bean
@DependsOn({"lifecycleBeanPostProcessor"})
public DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator(){
DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
advisorAutoProxyCreator.setProxyTargetClass(true);
return advisorAutoProxyCreator;
}
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(){
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager());
return authorizationAttributeSourceAdvisor;
}
}
@Controller
public class PatientController {
@Autowired
PatientService patientService;
@Autowired
DoctorService doctorService;
@Autowired
AppointmentService appointmentService;
@Autowired
HospitalizationService hospitalizationService;json.put("message",loginService.regist(login));
return json;
}
@RequestMapping("/hospital/patient/index")
public String patientIndex(){
return "/patient/index";
}
@RequestMapping("/hospital/doctor/index")
public String doctorIndex(){
return "/doctor/index";
}
@RequestMapping("/hospital/admin/index")
public String adminIndex(){
return "/admin/index";
}
}
@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){
List<Appointment> appointmentList=appointmentService.getAllAppointments(doctorname,patientname);
request.setAttribute("appointments" ,appointmentList);
return"admin/appointmentManage";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("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){
System.out.println(medicalhistory);
JSONObject json=new JSONObject();
json.put("message",medicalhistoryService.addMedicalhistory(medicalhistory));
return json;
}
}
public class ExcelUtils {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();
}
}
@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){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();
}
}
@Controller
public class DrugsController {@RequestMapping(value = "/hospital/login")
public String loginAndregist(){
return "login®ist";
}
@RequestMapping("/admin/adminManage")
public String adminManage(HttpServletRequest request,@RequestParam(value = "username",required = false)String 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();
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 "login®ist";
}
@RequestMapping(value = "/login",method = RequestMethod.POST)}
@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/patient/index")
public String patientIndex(){
return "/patient/index";
}
@RequestMapping("/hospital/doctor/index")
public String doctorIndex(){
return "/doctor/index";
}
@RequestMapping("/hospital/admin/index")
public String adminIndex(){
return "/admin/index";
}
}
@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){
List<Appointment> appointmentList=appointmentService.getAllAppointments(doctorname,patientname);
request.setAttribute("appointments" ,appointmentList);
return"admin/appointmentManage";/**
* Shiro生命周期处理器
* @return
*/
@Bean
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor(){
return new LifecycleBeanPostProcessor();
}
/**
* 开启Shiro的注解(如@RequiresRoles,@RequiresPermissions),需借助SpringAOP扫描使用Shiro注解的类,并在必要时进行安全逻辑验证
* 配置以下两个bean(DefaultAdvisorAutoProxyCreator(可选)和AuthorizationAttributeSourceAdvisor)即可实现此功能
* @return
*/
@Bean
@DependsOn({"lifecycleBeanPostProcessor"})
public DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator(){
DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
advisorAutoProxyCreator.setProxyTargetClass(true);
return advisorAutoProxyCreator;
}
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(){
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager());
return authorizationAttributeSourceAdvisor;
}
}
@Controller
public class PatientController {
@Autowired@Controller
public class PatientController {
@Autowired
PatientService patientService;
@Autowired
DoctorService doctorService;
@Autowired
AppointmentService appointmentService;
@Autowired
HospitalizationService hospitalizationService;
@Autowired
MedicalhistoryService medicalhistoryService;
@RequestMapping("/admin/patientManage")
public String patientlist(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="certId",required = false) String 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());@Autowired
MedicalhistoryService medicalhistoryService;
@RequestMapping("/admin/patientManage")
public String patientlist(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="certId",required = false) String 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;
}
@RequestMapping(value = "/patient/medicalhistory")
public String medicalhistory(HttpSession session,HttpServletRequest request){authorizationAttributeSourceAdvisor.setSecurityManager(securityManager());
return authorizationAttributeSourceAdvisor;
}
}
@Controller
public class PatientController {
@Autowired
PatientService patientService;
@Autowired
DoctorService doctorService;
@Autowired
AppointmentService appointmentService;
@Autowired
HospitalizationService hospitalizationService;
@Autowired
MedicalhistoryService medicalhistoryService;
@RequestMapping("/admin/patientManage")
public String patientlist(HttpServletRequest request,@RequestParam(value="name",required = false) String name,@RequestParam(value="certId",required = false) String 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;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;
}
@RequestMapping(value = "/patient/medicalhistory")
public String medicalhistory(HttpSession session,HttpServletRequest request){
Login login=(Login)session.getAttribute("login");
Patient patient=patientService.findPatientByLoginId(login.getId());
request.setAttribute("medicalhistorys",medicalhistoryService.getMedicalhistoryByPatientId(patient.getId()));
return "patient/medicalhistory";
}
@RequestMapping(value = "/patient/hospitalization")
public String hospitalization(HttpSession session,HttpServletRequest request){
Login login=(Login)session.getAttribute("login");
Patient patient=patientService.findPatientByLoginId(login.getId());
request.setAttribute("theLast",hospitalizationService.findTheLastHospitalization(patient.getHospitalizationid()));
Hospitalization hospitalization=new Hospitalization();
hospitalization.setPatientid(patient.getId());
hospitalization.setId(patient.getHospitalizationid());
request.setAttribute("others",hospitalizationService.findOtherHospitalization(hospitalization));
return "patient/hospitalization";
}
@RequestMapping(value = "/patient/appointment")
public String appointmentInfo(HttpServletRequest request,HttpSession session){
Login login=(Login)session.getAttribute("login");
Patient patient=patientService.findPatientByLoginId(login.getId());
request.setAttribute("patientid",patient.getId());
request.setAttribute("doctors",doctorService.getAllDoctor());
return "patient/appointment";
}
@RequestMapping(value = "/patient/appointment",method = RequestMethod.POST)
@ResponseBody
public JSONObject appointment(@RequestBody Appointment appointment){
JSONObject json=new JSONObject();
Patient patient=new Patient();
String message=appointmentService.addAppointment(appointment);
patient.setAppointmentid(appointmentService.selectTheLastAppointment(appointment.getPatientid()));
patient.setId(appointment.getPatientid());@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("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){
System.out.println(medicalhistory);
JSONObject json=new JSONObject();
json.put("message",medicalhistoryService.addMedicalhistory(medicalhistory));
return json;
}
}
public class ExcelUtils {
public static void createTitle(HSSFWorkbook workbook, HSSFSheet sheet){
HSSFRow row = sheet.createRow(0);
//设置列宽,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;






















