基于javaweb+mysql的springboot医院管理系统(java+springboot+layui+freemaker+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot医院管理系统(java+springboot+layui+freemaker+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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
技术栈
-
后端:SpringBoot
-
前端:Layui+Freemaker
使用说明
-
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
-
使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令
- 将项目中application.yml配置文件中的数据库配置改为自己的配置,配置tomcat,然后运行; 4. 运行项目,输入http://localhost:8088 登录
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){
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";
}
@Controller
public class MedicalhistoryController {
@Autowired
PatientService patientService;
@Autowired
MedicalhistoryService medicalhistoryService;
@RequestMapping("/admin/medicalhistoryManage")
public String medicalhistoryManage(HttpServletRequest request,@RequestParam(value = "doctorname",required = false)String doctorname,@RequestParam(value = "patientname",required = false)String patientname){
request.setAttribute("medicalhistorys",medicalhistoryService.getAllMedicalhistorys(doctorname,patientname));
return "admin/medicalhistoryManage";
}
@RequestMapping("/admin/medicalhistoryAdd")
public String medicalhistoryAddPage(HttpServletRequest request){
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";
}
/**
*
*
*
*/
@Configuration
public class ShiroConfiguration {
private static final Logger S_LOGGER = LoggerFactory.getLogger(ShiroConfiguration.class);
/**
* Shiro的Web过滤器Factory 命名:shiroFilter<br />
*
* @param securityManager
* @return
*/
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
S_LOGGER.info("注入Shiro的Web过滤器-->shiroFilter", ShiroFilterFactoryBean.class);
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
//Shiro的核心安全接口,这个属性是必须的
shiroFilterFactoryBean.setSecurityManager(securityManager);
//要求登录时的链接(可根据项目的URL进行替换),非必须的属性,默认会自动寻找Web工程根目录下的"/login.jsp"页面
shiroFilterFactoryBean.setLoginUrl("/hospital/login");
//登录成功后要跳转的连接,逻辑也可以自定义,例如返回上次请求的页面
shiroFilterFactoryBean.setSuccessUrl("/hospital/admin/index");
//用户访问未对其授权的资源时,所显示的连接
shiroFilterFactoryBean.setUnauthorizedUrl("/404.html");
/*定义shiro过滤器,例如实现自定义的FormAuthenticationFilter,需要继承FormAuthenticationFilter
**本例中暂不自定义实现,在下一节实现验证码的例子中体现
*/
}
@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);
@Controller
public class LoginController {
@Autowired
LoginService loginService;
@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;
}
}
/**
* 不指定名字的话,自动创建一个方法名第一个字母小写的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;
}
/**
* Shiro Realm 继承自AuthorizingRealm的自定义Realm,即指定Shiro验证用户登录的类为自定义的
*
* @param
* @return
*/
@Bean
public MyShiroRealm userRealm() {
MyShiroRealm userRealm = new MyShiroRealm();
//告诉realm,使用credentialsMatcher加密算法类来验证密文
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;
}
}
/**
*/
public class ShiroLoginFilter extends FormAuthenticationFilter {
/**
* 在访问controller前判断是否登录,返回json,不进行重定向。
* @param request
* @param response
return "admin/info/appointmentInfo";
}
@RequestMapping(value = "/admin/appointment",method = RequestMethod.PUT)
@ResponseBody
public JSONObject AppointmentUpdate(@RequestBody Appointment appointment){
JSONObject json=new JSONObject();
json.put("message",appointmentService.UpdateAppointment(appointment));
return json;
}
@RequestMapping(value = "/admin/appointment",method = RequestMethod.POST)
@ResponseBody
public JSONObject AppointmentAdd(@RequestBody Appointment appointment){
System.out.println(appointment);
JSONObject json=new JSONObject();
json.put("message",appointmentService.addAppointment(appointment));
return json;
}
}
@Controller
public class MedicalhistoryController {
@Autowired
PatientService patientService;
@Autowired
MedicalhistoryService medicalhistoryService;
@RequestMapping("/admin/medicalhistoryManage")
public String medicalhistoryManage(HttpServletRequest request,@RequestParam(value = "doctorname",required = false)String doctorname,@RequestParam(value = "patientname",required = false)String patientname){
request.setAttribute("medicalhistorys",medicalhistoryService.getAllMedicalhistorys(doctorname,patientname));
return "admin/medicalhistoryManage";
}
@RequestMapping("/admin/medicalhistoryAdd")
public String medicalhistoryAddPage(HttpServletRequest request){
request.setAttribute("patients",patientService.getAllPatients());
return"admin/add/medicalhistoryadd";
}
@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)
@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(){
@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";
}
@RequestMapping("/admin/appointmentAdd")
public String appointmentAddPage(HttpServletRequest request){
request.setAttribute("patients",patientService.getAllPatients());
//request.setAttribute("doctors",doctorService.getAllDoctor());
return"admin/add/appointmentadd";
}
@RequestMapping(value = "/admin/appointment/{id}",method = RequestMethod.DELETE)
@ResponseBody
public JSONObject delAppointment(@PathVariable Integer id){
@Controller
public class LoginController {
@Autowired
LoginService loginService;
@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";
}
* @throws Exception
*/
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws IOException {
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
if (isAjax(request)) {
HashMap<String,Object> result = new HashMap<>();
httpServletResponse.setCharacterEncoding("UTF-8");
httpServletResponse.setContentType("application/json");
result.put("msg","未登录");
result.put("status",-1);
httpServletResponse.getWriter().write(JSONObject.toJSON(result).toString());
}/* else {
*//**
* @Mark 非ajax请求重定向为登录页面
*//*
httpServletResponse.sendRedirect("/gbq_blog/login/noLogin");
}*/
return false;
}
private boolean isAjax(ServletRequest request) {
String header = ((HttpServletRequest) request).getHeader("X-Requested-With");
return "XMLHttpRequest".equalsIgnoreCase(header);
}
}
/**
*/
public class MyShiroRealm extends AuthorizingRealm{
@Autowired
private LoginMapper loginMapper;
@Autowired
private HttpServletRequest request;
@Override
@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";
}
@RequestMapping("/admin/appointmentAdd")
public String appointmentAddPage(HttpServletRequest request){
request.setAttribute("patients",patientService.getAllPatients());
//request.setAttribute("doctors",doctorService.getAllDoctor());
return"admin/add/appointmentadd";
}
@RequestMapping(value = "/admin/appointment/{id}",method = RequestMethod.DELETE)
@ResponseBody
public JSONObject delAppointment(@PathVariable Integer id){
JSONObject json=new JSONObject();
json.put("message",appointmentService.delAppointment(id));
return json;
}
@RequestMapping(value = "/admin/appointment/{id}",method = RequestMethod.GET)
public String AppointmentInfo(@PathVariable Integer id,HttpServletRequest request){
request.setAttribute("patients",patientService.getAllPatients());
request.setAttribute("doctors",doctorService.getAllDoctor());
request.setAttribute("appointment",appointmentService.getAppointment(id));
return "admin/info/appointmentInfo";
}
@RequestMapping(value = "/admin/appointment",method = RequestMethod.PUT)
@ResponseBody
}
/**
* 凭证匹配器
* (由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了
* 所以我们需要修改下doGetAuthenticationInfo中的代码;
* )
* 可以扩展凭证匹配器,实现 输入密码错误次数后锁定等功能,下一次
* @return
*/
@Bean(name="credentialsMatcher")
public HashedCredentialsMatcher hashedCredentialsMatcher(){
HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher();
hashedCredentialsMatcher.setHashAlgorithmName("md5");//散列算法:这里使用MD5算法;
hashedCredentialsMatcher.setHashIterations(2);//散列的次数,比如散列两次,相当于 md5(md5(""));
//storedCredentialsHexEncoded默认是true,此时用的是密码加密用的是Hex编码;false时用Base64编码
hashedCredentialsMatcher.setStoredCredentialsHexEncoded(true);
return hashedCredentialsMatcher;
}
/**
* 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;
}
}
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)
@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";
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){
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();
@Autowired
HospitalizationService hospitalizationService;
@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));