基于javaweb+mysql的ssm+maven医药信息管理系统(java+ssm+maven+html+easyui+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven医药信息管理系统(java+ssm+maven+html+easyui+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项目:是;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:HTML+CSS+JavaScript+easyui
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录 管理员账号:admir 密码:1234 用户账号:test 密码:1201
}
//处理登陆逻辑
@RequestMapping("Login")
@Controller
public class LoginController {
@Autowired
private LoginService loginService;
/*
* 用户登陆 判断是否存在用户 存在保存session
*/
@RequestMapping(value = "loginUser", produces = "text/html;charset=UTF-8")
@ResponseBody
public String login(String username, String password, HttpSession session) {
return loginService.login(username, password, session);
}
// 取出seeion的用户名
@RequestMapping("GetLoginName")
@ResponseBody
public Object GetLoginName(HttpSession session) {
Object username = session.getAttribute("user");
return username;
}
// 清除session
@RequestMapping("LogOff")
@ResponseBody
public void logOff(HttpSession session) {
Enumeration em = session.getAttributeNames();
while (em.hasMoreElements()) {
session.removeAttribute(em.nextElement().toString());
//处理登陆逻辑
@RequestMapping("Login")
@Controller
public class LoginController {
@Autowired
private LoginService loginService;
/*
* 用户登陆 判断是否存在用户 存在保存session
*/
@RequestMapping(value = "loginUser", produces = "text/html;charset=UTF-8")
@ResponseBody
public String login(String username, String password, HttpSession session) {
return loginService.login(username, password, session);
}
// 取出seeion的用户名
@RequestMapping("GetLoginName")
@ResponseBody
public Object GetLoginName(HttpSession session) {
Object username = session.getAttribute("user");
return username;
}
// 清除session
@RequestMapping("LogOff")
@ResponseBody
public void logOff(HttpSession session) {
Enumeration em = session.getAttributeNames();
while (em.hasMoreElements()) {
session.removeAttribute(em.nextElement().toString());
}
}
}
@Service
public class LoginService {
// 注入userMapper
return "";
} catch (Exception e) {
// TODO: handle exception
return "操作异常,请刷新后操作";
}
// System.out.println(medicine);
// List<Medicine> medicine1 = (List<Medicine>)
// medicineMapper.queryMultiMedicine(medicine);
// System.out.println(medicine1);
}
public EasyUIResult getMultiMedicine(Integer page, Integer rows, HttpSession session) {
// TODO Auto-generated method stub
PageHelper.startPage(page, rows);
List<Medicine> medicines = (List<Medicine>) session.getAttribute("medicines");
System.out.println(medicines);
PageInfo<Medicine> pageInfo = new PageInfo<Medicine>(medicines);
return new EasyUIResult(pageInfo.getTotal(), medicines);
}
}
@RequestMapping("Medicine")
@Controller
public class MedicineController {
// 药品controller
@Autowired
private MedicineService medicineService;
// 通过mno查询药品信息
@RequestMapping("QueryMedicineByMno")
@ResponseBody
public Medicine queryMedicineByMno(String mno) {
Medicine medicine = medicineService.queryMedicineByMno(mno);
return medicine;
}
/*
* // 多条件药品信息保存session
* // 多条件药品信息保存session
*
* @RequestMapping("QueryMultiMedicine")
*
* @ResponseBody public String queryMultiMedicine(Medicine
* medicine,HttpSession session) { return
* medicineService.queryMultiMedicine(medicine,session);
*
* } // 多条件药品查询url
*
* @RequestMapping("GetMultiMedicine")
*
* @ResponseBody public EasyUIResult getMultiMedicine(@RequestParam(value =
* "page", defaultValue = "1") Integer page,
*
* @RequestParam(value = "rows", defaultValue = "5") Integer rows,
* HttpSession session) { return medicineService.getMultiMedicine(page,
* rows,session);
*
* }
*/
/*
* // 通过mno删除药品信息
*
* @RequestMapping(value = "DeleteMedicine", produces =
* "text/html;charset=UTF-8")
*
* @ResponseBody public String deleteMedicineByMno(String mno) { return
* medicineService.deleteMedicineByMno(mno); }
*/
// 批量删除
@RequestMapping(value = "DeleteRows", produces = "text/html;charset=UTF-8")
@ResponseBody
public String deleteMedicineByRows(@RequestParam(value = "array[]") String[] array) {
try {
return medicineService.deleteMedicineByRows(array);
} catch (Exception e) {
// TODO: handle exception
return "操作异常,可能某些药品被顾客购买过," + "无法删该药品,请重新选择";
}
}
// 保存药品信息
@RequestMapping(value = "SaveMedicine", produces = "text/html;charset=UTF-8")
@ResponseBody
public String saveMedicine(Medicine medicine) {
@Controller
public class MedicineController {
// 药品controller
@Autowired
private MedicineService medicineService;
// 通过mno查询药品信息
@RequestMapping("QueryMedicineByMno")
@ResponseBody
public Medicine queryMedicineByMno(String mno) {
Medicine medicine = medicineService.queryMedicineByMno(mno);
return medicine;
}
/*
* // 多条件药品信息保存session
*
* @RequestMapping("QueryMultiMedicine")
*
* @ResponseBody public String queryMultiMedicine(Medicine
* medicine,HttpSession session) { return
* medicineService.queryMultiMedicine(medicine,session);
*
* } // 多条件药品查询url
*
* @RequestMapping("GetMultiMedicine")
*
* @ResponseBody public EasyUIResult getMultiMedicine(@RequestParam(value =
* "page", defaultValue = "1") Integer page,
*
* @RequestParam(value = "rows", defaultValue = "5") Integer rows,
* HttpSession session) { return medicineService.getMultiMedicine(page,
* rows,session);
*
* }
*/
/*
* // 通过mno删除药品信息
*
* @RequestMapping(value = "DeleteMedicine", produces =
* "text/html;charset=UTF-8")
*
* @ResponseBody public String deleteMedicineByMno(String mno) { return
public Medicine queryMedicineByMno(String mno) {
Medicine medicine = medicineService.queryMedicineByMno(mno);
return medicine;
}
/*
* // 多条件药品信息保存session
*
* @RequestMapping("QueryMultiMedicine")
*
* @ResponseBody public String queryMultiMedicine(Medicine
* medicine,HttpSession session) { return
* medicineService.queryMultiMedicine(medicine,session);
*
* } // 多条件药品查询url
*
* @RequestMapping("GetMultiMedicine")
*
* @ResponseBody public EasyUIResult getMultiMedicine(@RequestParam(value =
* "page", defaultValue = "1") Integer page,
*
* @RequestParam(value = "rows", defaultValue = "5") Integer rows,
* HttpSession session) { return medicineService.getMultiMedicine(page,
* rows,session);
*
* }
*/
/*
* // 通过mno删除药品信息
*
* @RequestMapping(value = "DeleteMedicine", produces =
* "text/html;charset=UTF-8")
*
* @ResponseBody public String deleteMedicineByMno(String mno) { return
* medicineService.deleteMedicineByMno(mno); }
*/
// 批量删除
@RequestMapping(value = "DeleteRows", produces = "text/html;charset=UTF-8")
@ResponseBody
public String deleteMedicineByRows(@RequestParam(value = "array[]") String[] array) {
try {
return medicineService.deleteMedicineByRows(array);
} catch (Exception e) {
// TODO: handle exception
return "操作异常,可能某些药品被顾客购买过," + "无法删该药品,请重新选择";
}
}
// 保存药品信息
@RequestMapping(value = "SaveMedicine", produces = "text/html;charset=UTF-8")
try {
for (String mno : array) {
medicineMapper.deleteMedicineByMno(mno);
}
} catch (Exception e) {
// TODO: handle exception
// 抛出异常让spring捕获,进行事务回滚
throw new RuntimeException();
}
return "删除成功";
}
public String queryMultiMedicine(Medicine medicine, HttpSession session) {
// TODO Auto-generated method stub
try {
List<Medicine> medicines = medicineMapper.queryMultiMedicine(medicine);
session.setAttribute("medicines", medicines);
System.out.println(medicines);
System.out.println("@@@@@");
return "";
} catch (Exception e) {
// TODO: handle exception
return "操作异常,请刷新后操作";
}
// System.out.println(medicine);
// List<Medicine> medicine1 = (List<Medicine>)
// medicineMapper.queryMultiMedicine(medicine);
// System.out.println(medicine1);
}
public EasyUIResult getMultiMedicine(Integer page, Integer rows, HttpSession session) {
// TODO Auto-generated method stub
PageHelper.startPage(page, rows);
List<Medicine> medicines = (List<Medicine>) session.getAttribute("medicines");
System.out.println(medicines);
PageInfo<Medicine> pageInfo = new PageInfo<Medicine>(medicines);
return new EasyUIResult(pageInfo.getTotal(), medicines);
}
}
public class MyHandlerInterceptor implements HandlerInterceptor {
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception {
// TODO Auto-generated method stub
}
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
// TODO Auto-generated method stub
}
/*
* 自定义拦截器 判断session是否存在用户 不存在就拦截返回登陆页面
*/
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
// TODO Auto-generated method stub
HttpSession session = request.getSession();
Object username = session.getAttribute("user");
Object password = session.getAttribute("password");
if (username == null || password == null) {
response.sendRedirect("../login.html");
System.out.println("##");
return false;
}
return true;
}
}
@RequestMapping("Client")
@Controller
public class ClientController {
// 顾客controller
@Autowired
// 注入service
private ClientService clientService;
// 按编号查询
@RequestMapping("GetClient")
@ResponseBody
public Client queryClientBycno(String cno) {
Client client = clientService.queryClientBycno(cno);
return client;
}
// 按编号删除
@RequestMapping("DeleteClient")
@ResponseBody
public void deleteClientBycno(String cno) {
clientService.deleteClientBycno(cno);
}
// 批量删除
@RequestMapping(value = "DeleteRows", produces = "text/html;charset=UTF-8")
@ResponseBody
public String deleteClientByRows(
@RequestParam(value = "array[]") String[] array) {
return clientService.deleteClientByRows(array);
// clientService.deleteClientBycno(cno);
}
// 保存顾客信息
@RequestMapping(value = "SaveClient", produces = "text/html;charset=UTF-8")
@ResponseBody
public String saveClient(Client client) {
return clientService.saveClient(client);
}
//用户
@RequestMapping("User")
@Controller
public class UserController {
@Autowired
private UserServies userServies;
// 添加新用户
@RequestMapping("AddUser")
@ResponseBody
public String addUser(User user) {
userServies.addUser(user);
return "success";
}
// 修改用户信息
@RequestMapping("UpdateUser")
@ResponseBody
public void updateUser(User user) {
userServies.updateUser(user);
}
// 删除用户
@RequestMapping("DeleteUser")
@ResponseStatus(value = HttpStatus.OK)
public void deleteUser(String uUsername) {
userServies.deleteUser(uUsername);
}
// easyui返回全部用户信息
@RequestMapping("queryAllUser")
@ResponseBody
public EasyUIResult queryAllUser(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "rows", defaultValue = "5") Integer rows) {
EasyUIResult queryAllUser = userServies.queryAllUser(page, rows);
return queryAllUser;
}
// 通过uUsername查询用户
@RequestMapping(value = "GetUUsername", produces = "text/html;charset=UTF-8")
@ResponseBody
public String queryUserByName(String uUsername) {
return userServies.queryUserByName(uUsername);
}
// TODO Auto-generated method stub
try {
List<Medicine> medicines = medicineMapper.queryMultiMedicine(medicine);
session.setAttribute("medicines", medicines);
System.out.println(medicines);
System.out.println("@@@@@");
return "";
} catch (Exception e) {
// TODO: handle exception
return "操作异常,请刷新后操作";
}
// System.out.println(medicine);
// List<Medicine> medicine1 = (List<Medicine>)
// medicineMapper.queryMultiMedicine(medicine);
// System.out.println(medicine1);
}
public EasyUIResult getMultiMedicine(Integer page, Integer rows, HttpSession session) {
// TODO Auto-generated method stub
PageHelper.startPage(page, rows);
List<Medicine> medicines = (List<Medicine>) session.getAttribute("medicines");
System.out.println(medicines);
PageInfo<Medicine> pageInfo = new PageInfo<Medicine>(medicines);
return new EasyUIResult(pageInfo.getTotal(), medicines);
}
}
@RequestMapping("Medicine")
@Controller
public class MedicineController {
// 药品controller
@Autowired
private MedicineService medicineService;
// 通过mno查询药品信息
@RequestMapping("QueryMedicineByMno")
@ResponseBody
public Medicine queryMedicineByMno(String mno) {
Medicine medicine = medicineService.queryMedicineByMno(mno);
return medicine;
@Autowired
private LoginService loginService;
/*
* 用户登陆 判断是否存在用户 存在保存session
*/
@RequestMapping(value = "loginUser", produces = "text/html;charset=UTF-8")
@ResponseBody
public String login(String username, String password, HttpSession session) {
return loginService.login(username, password, session);
}
// 取出seeion的用户名
@RequestMapping("GetLoginName")
@ResponseBody
public Object GetLoginName(HttpSession session) {
Object username = session.getAttribute("user");
return username;
}
// 清除session
@RequestMapping("LogOff")
@ResponseBody
public void logOff(HttpSession session) {
Enumeration em = session.getAttributeNames();
while (em.hasMoreElements()) {
session.removeAttribute(em.nextElement().toString());
}
}
}
@Service
public class LoginService {
// 注入userMapper
@Autowired
private UserMapper userMapper;
public String login(String username, String password, HttpSession session) {
// TODO Auto-generated method stub
User user = userMapper.queryUserByName(username);
if (user == null) {
return "没有此用户";
} else if (user.getuPassword().equals(password) == false) {
return "密码错误";
EasyUIResult queryAllUser = userServies.queryAllUser(page, rows);
return queryAllUser;
}
// 通过uUsername查询用户
@RequestMapping(value = "GetUUsername", produces = "text/html;charset=UTF-8")
@ResponseBody
public String queryUserByName(String uUsername) {
return userServies.queryUserByName(uUsername);
}
@RequestMapping(value = "GetUpassword", produces = "text/html;charset=UTF-8")
@ResponseBody
public String queryPasswordByName(String uUsername) {
return userServies.queryPasswordByName(uUsername);
}
}
public class MyHandlerInterceptor implements HandlerInterceptor {
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception {
// TODO Auto-generated method stub
}
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
// TODO Auto-generated method stub
}
/*
* 自定义拦截器 判断session是否存在用户 不存在就拦截返回登陆页面
*/
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
// TODO Auto-generated method stub
HttpSession session = request.getSession();
Object username = session.getAttribute("user");
Object password = session.getAttribute("password");
if (username == null || password == null) {
@ResponseBody
public List<Medicine> getAllMedicine() {
List<Medicine> allMedicine = medicineService.getAllMedicine();
return allMedicine;
}
// 按编号查询
@RequestMapping("GetMedicine")
@ResponseBody
public Medicine GetMedicine(String mno) {
return medicineService.queryMedicineByMno(mno);
}
}
@RequestMapping("Agency")
@Controller
public class AgencyController {
// 经办人controller
@Autowired
private AgencyService agencyService;
// 通过ano查询单个经办人
@RequestMapping("GetAgency")
@ResponseBody
public Agency queryAgencyByAno(String ano) {
Agency agency = agencyService.queryAgencyByAno(ano);
return agency;
}
@RequestMapping(value = "DeleteAgency", produces = "text/html;charset=UTF-8")
@ResponseBody
public void updateUser(User user) {
userServies.updateUser(user);
}
// 删除用户
@RequestMapping("DeleteUser")
@ResponseStatus(value = HttpStatus.OK)
public void deleteUser(String uUsername) {
userServies.deleteUser(uUsername);
}
// easyui返回全部用户信息
@RequestMapping("queryAllUser")
@ResponseBody
public EasyUIResult queryAllUser(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "rows", defaultValue = "5") Integer rows) {
EasyUIResult queryAllUser = userServies.queryAllUser(page, rows);
return queryAllUser;
}
// 通过uUsername查询用户
@RequestMapping(value = "GetUUsername", produces = "text/html;charset=UTF-8")
@ResponseBody
public String queryUserByName(String uUsername) {
return userServies.queryUserByName(uUsername);
}
@RequestMapping(value = "GetUpassword", produces = "text/html;charset=UTF-8")
@ResponseBody
public String queryPasswordByName(String uUsername) {
return userServies.queryPasswordByName(uUsername);
}
}
@RequestMapping("Medicine")
@Controller
public class MedicineController {
// 药品controller
@Autowired
private MedicineService medicineService;
// 通过mno查询药品信息
@RequestMapping("QueryMedicineByMno")
@ResponseBody
public Medicine queryMedicineByMno(String mno) {
Medicine medicine = medicineService.queryMedicineByMno(mno);
return medicine;
}
/*
* // 多条件药品信息保存session
*
* @RequestMapping("QueryMultiMedicine")
*
* @ResponseBody public String queryMultiMedicine(Medicine
* medicine,HttpSession session) { return
* medicineService.queryMultiMedicine(medicine,session);
*
* } // 多条件药品查询url
*
* @RequestMapping("GetMultiMedicine")
*
* @ResponseBody public EasyUIResult getMultiMedicine(@RequestParam(value =
* "page", defaultValue = "1") Integer page,
*
* @RequestParam(value = "rows", defaultValue = "5") Integer rows,
* HttpSession session) { return medicineService.getMultiMedicine(page,
* rows,session);
*
* }
*/
/*
* // 通过mno删除药品信息
*
* @RequestMapping(value = "DeleteMedicine", produces =
* "text/html;charset=UTF-8")
*
* @ResponseBody public String deleteMedicineByMno(String mno) { return
* medicineService.deleteMedicineByMno(mno); }
return queryAllClient;
}
// 修改客户信息
@RequestMapping(value = "ModifyClient", produces = "text/html;charset=UTF-8")
@ResponseBody
public String modifyClient(Client client) {
return clientService.modifyClient(client);
}
}
//用户
@RequestMapping("User")
@Controller
public class UserController {
@Autowired
private UserServies userServies;
// 添加新用户
@RequestMapping("AddUser")
@ResponseBody
public String addUser(User user) {
userServies.addUser(user);
return "success";
}