源码获取:俺的博客首页 "资源" 里下载!
项目介绍
本项目分为药房人员、管理员与医生三种角色;
药房人员角色包含以下功能:
药房人员登录,导诊单管理,采购管理等功能。
管理员角色包含以下功能:
管理员登录,药房人员管理,医生管理,药材信息管理,药方管理等功能。
医生角色包含以下功能:
医生登录,药材信息查询,药方查询,导诊单管理等功能。
环境需要
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/8.0版本均可;
6.是否Maven项目:是;
技术栈
1. 后端:Spring+SpringMVC+Mbytes
2. 前端:JSP+css+javascript+bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入localhost:8080/ssm_yaofangsys/
医生账号/密码: doctor/123456
药房人员账号/密码:yaofang/123456
管理员账号/密码:admin/admin
登录管理控制层:
@Controller
@RequestMapping("/login")
public class LoginController extends BaseController{
@Autowired
private ManageService manageService;
@Autowired
private MedicineUserService medicineUserService;
@Autowired
private DoctorService doctorService;
/**
* 跳转登陆
* @return
*/
@RequestMapping("/login")
public String login(){
return "login/mLogin";
}
@RequestMapping("/index")
public String index(){
return "login/mIndex";
}
@RequestMapping("/uIndex")
public String uIndex(Model model){
return "login/uIndex";
}
@RequestMapping("/welcome")
public String welcome(){
return "login/welcome";
}
@RequestMapping("/mup")
public String mpass(){
return "login/mup";
}
/**
* 管理员登陆
* @param manage
* @param request
* @param response
* @return
*/
@RequestMapping("/toLogin")
public String toLogin(Manage manage,Integer role, HttpServletRequest request, HttpServletResponse response){
if (role == null){
return "redirect:/login/login.action";
}
//超级管理员
if (role== 1){
Manage byEntity = manageService.getByEntity(manage);
if(byEntity != null){
request.getSession().setAttribute("role", role);
request.getSession().setAttribute("name", byEntity.getRealName());
return "redirect:/login/index.action";
}else{
return "redirect:/login/login.action";
}
}
//1 超级管理员2 医生 3 药房人员
if (role== 2){
Doctor d = new Doctor();
d.setPassword(manage.getPassword());
d.setUserName(manage.getUserName());
Doctor byEntity = doctorService.getByEntity(d);
if(byEntity != null){
request.getSession().setAttribute("role", role);
request.getSession().setAttribute("name", byEntity.getRealName());
request.getSession().setAttribute("userId", byEntity.getId());
return "redirect:/login/index.action";
}else{
return "redirect:/login/login.action";
}
}
//药房人员
if (role== 3){
MedicineUser d = new MedicineUser();
d.setPassword(manage.getPassword());
d.setUserName(manage.getUserName());
MedicineUser byEntity = medicineUserService.getByEntity(d);
if(byEntity != null){
request.getSession().setAttribute("role", role);
request.getSession().setAttribute("name", byEntity.getRealName());
request.getSession().setAttribute("userId", byEntity.getId());
return "redirect:/login/index.action";
}else{
return "redirect:/login/login.action";
}
}
return null;
}
/**
* 退出
* @param request
* @param response
* @return
*/
@RequestMapping("/tuichu")
public String tuichu( HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
session.invalidate();
return "redirect:/login/login.action";
}
@RequestMapping("/uTui")
public String uTui( HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
session.invalidate();
return "redirect:/login/uLogin.action";
}
@RequestMapping("/head")
private String head(){
return "inc/head";
}
@RequestMapping("/left")
private String left(){
return "inc/left";
}
}
医生管理控制层:
@Controller
@RequestMapping("/doctor")
public class DoctorController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private DoctorService doctorService;
@RequestMapping(value = "/findBySql")
public String findBySql(Doctor doctor, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
String sql = "SELECT * FROM doctor WHERE 1=1 and isDelete = 0 ";//and isDelete = 0
if(!isEmpty(doctor.getUserName())){
sql += " and userName like '%"+doctor.getUserName()+"%'";
}
if(!isEmpty(doctor.getPassword())){
sql += " and password like '%"+doctor.getPassword()+"%'";
}
if(!isEmpty(doctor.getRealName())){
sql += " and realName like '%"+doctor.getRealName()+"%'";
}
if(!isEmpty(doctor.getIdCard())){
sql += " and idCard like '%"+doctor.getIdCard()+"%'";
}
if(!isEmpty(doctor.getPhone())){
sql += " and phone like '%"+doctor.getPhone()+"%'";
}
if(!isEmpty(doctor.getSex())){
sql += " and sex like '%"+doctor.getSex()+"%'";
}
if(!isEmpty(doctor.getIsDelete())){
sql += " and isDelete like '%"+doctor.getIsDelete()+"%'";
}
sql += " ORDER BY ID DESC ";
Pager<Doctor> pagers = doctorService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", doctor);
return "doctor/doctor";
}
/**
* 跳至添加页面
* @return
*/
@RequestMapping(value = "/add")
public String add() {
return "doctor/add";
}
/**
* 添加执行
* @return
*/
@RequestMapping(value = "/exAdd")
public String exAdd(Doctor doctor, Model model, HttpServletRequest request, HttpServletResponse response) {
doctor.setIsDelete(0);
doctorService.insert(doctor);
return "redirect:/doctor/findBySql";
}
/**
* 跳至修改页面
* @return
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model) {
Doctor obj = doctorService.load(id);
model.addAttribute("obj",obj);
return "doctor/update";
}
/**
* 添加修改
* @return
*/
@RequestMapping(value = "/exUpdate")
public String exUpdate(Doctor doctor, Model model, HttpServletRequest request, HttpServletResponse response) {
//1.通过实体类修改,可以多传修改条件
doctorService.updateById(doctor);
//2.通过主键id修改
//doctorService.updateById(doctor);
return "redirect:/doctor/findBySql";
}
/**
* 删除通过主键
* @return
*/
@RequestMapping(value = "/delete")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
Doctor load = doctorService.load(id);
load.setIsDelete(1);
doctorService.update(load);
doctorService.updateById(load);
return "redirect:/doctor/findBySql";
}
}
药房人员管理控制层:
@Controller
@RequestMapping("/medicineUser")
public class MedicineUserController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private MedicineUserService medicineUserService;
@RequestMapping(value = "/findBySql")
public String findBySql(MedicineUser medicineUser, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
String sql = "SELECT * FROM medicine_user WHERE 1=1 and isDelete = 0 ";//and isDelete = 0
if(!isEmpty(medicineUser.getUserName())){
sql += " and userName like '%"+medicineUser.getUserName()+"%'";
}
if(!isEmpty(medicineUser.getPassword())){
sql += " and password like '%"+medicineUser.getPassword()+"%'";
}
if(!isEmpty(medicineUser.getRealName())){
sql += " and realName like '%"+medicineUser.getRealName()+"%'";
}
if(!isEmpty(medicineUser.getIdCard())){
sql += " and idCard like '%"+medicineUser.getIdCard()+"%'";
}
if(!isEmpty(medicineUser.getPhone())){
sql += " and phone like '%"+medicineUser.getPhone()+"%'";
}
if(!isEmpty(medicineUser.getSex())){
sql += " and sex like '%"+medicineUser.getSex()+"%'";
}
if(!isEmpty(medicineUser.getIsDelete())){
sql += " and isDelete like '%"+medicineUser.getIsDelete()+"%'";
}
sql += " ORDER BY ID DESC ";
Pager<MedicineUser> pagers = medicineUserService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", medicineUser);
return "medicineUser/medicineUser";
}
/**
* 跳至添加页面
* @return
*/
@RequestMapping(value = "/add")
public String add() {
return "medicineUser/add";
}
/**
* 添加执行
* @return
*/
@RequestMapping(value = "/exAdd")
public String exAdd(MedicineUser medicineUser, Model model, HttpServletRequest request, HttpServletResponse response) {
medicineUser.setIsDelete(0);
medicineUserService.insert(medicineUser);
return "redirect:/medicineUser/findBySql";
}
/**
* 跳至修改页面
* @return
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model) {
MedicineUser obj = medicineUserService.load(id);
model.addAttribute("obj",obj);
return "medicineUser/update";
}
/**
* 添加修改
* @return
*/
@RequestMapping(value = "/exUpdate")
public String exUpdate(MedicineUser medicineUser, Model model, HttpServletRequest request, HttpServletResponse response) {
//1.通过实体类修改,可以多传修改条件
medicineUserService.updateById(medicineUser);
//2.通过主键id修改
//medicineUserService.updateById(medicineUser);
return "redirect:/medicineUser/findBySql";
}
/**
* 删除通过主键
* @return
*/
@RequestMapping(value = "/delete")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
MedicineUser load = medicineUserService.load(id);
load.setIsDelete(1);
medicineUserService.updateById(load);
return "redirect:/medicineUser/findBySql";
}
}
源码获取:俺的博客首页 "资源" 里下载!