作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
该项目是前后台的医药管理系统(写在了一个web项目里),
简单明了,界面高端大气,共6张表,适合毕业设计使用,
后台管理系统用于药片的管理,
前台系统是用户购买药片,下订单使用。
主要功能介绍:
药品管理系统-后台:
订单管理
添加、编辑、删除
药品管理
添加、编辑、删除 - 药品名、药品类别、单价
药品类别管理
添加、编辑、删除 - 类别名称、描述
用户管理
添加、编辑、删除 - 用户名、电话、描述
药品商城-前台:
前台页面展示药品类别、药品缩略图、药品详情、可购买、加入购物车、形成订单
配置环境
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版本;
技术栈
1. 后端:Spring SpringMVC MyBatis
2. 前端:html+jQuery+javascript
使用步骤
1 使用IDEA/Eclipse导入MedicinesMS项目
2 使用Navicat或者其它工具,导入并执行sql文件 medicine_ms.sql,在项目的数据库配置文件db.properties中修改数据库相关配置,包括数据库名称、数据库用户名、密码等;
3 使用tomcat启动项目,项目名是/MedicinesMS 注:请固定为此项目名,否则会产生异常
4 访问后台系统http://localhost:8080/MedicinesMS/admin_login.html
进入登录页面,用户名 admin,密码123
5 在后台系统上添加药品信息
6 访问前台页面http://localhost:8080/MedicinesMS/login.html,
使用用户名 admin,密码123登录,购买要求,形成订单。
运行截图
前台界面
后台界面
相关代码
药品控制器
package com.clw.medicine.medi_detail.controller;
import com.clw.medicine.medi_detail.po.Medicine;
import com.clw.medicine.medi_detail.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Description: 药品控制器
* Author: clw
* Date: 2018/4/9
* Version: 1.0
*/
@Controller
@RequestMapping(value = "medicine/medicine", method = {RequestMethod.POST})
public class MedicineController {
@Autowired
MedicineService medicineService;
/**
* 获取指定数量的药品信息
* @param offset 偏移量
* @param limit 返回限制条数
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "getFilteredLimitMedicine")
public @ResponseBody
Map<String, Object> getFilteredLimitMedicine(@RequestParam(value = "medTypeId", defaultValue = "") String medTypeId,
@RequestParam(value = "offset") int offset,
@RequestParam(value = "limit") int limit) throws Exception {
medTypeId = "".equals(medTypeId) ? null : medTypeId;
List<Medicine> medicines = medicineService.getFilteredLimitMedicine(medTypeId, offset, limit);
Map<String, Object> result = new HashMap<String, Object>();
if (medicines.size() > 0) {
result.put("state", "success");
result.put("result", medicines);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
/**
* 获取指定ID的药品信息
* @param medicineIds String[] 药品ID数组
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "getSomeMedicine")
public @ResponseBody
Map<String, Object> getSomeMedicine(@RequestParam(value = "medicineIds[]") String[] medicineIds) throws Exception {
List<Medicine> medicines = medicineService.getSomeMedicine(medicineIds);
Map<String, Object> result = new HashMap<String, Object>();
if (medicines.size() > 0) {
result.put("state", "success");
result.put("result", medicines);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
/**
* 获取药品总量
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "getMedicineCount")
public @ResponseBody
Map<String, Object> getMedicineCount() throws Exception {
int count = medicineService.count();
Map<String, Object> result = new HashMap<String, Object>();
if (count > 0) {
result.put("state", "success");
result.put("result", count);
} else {
result.put("state", "fail");
result.put("reason", 0);
}
return result;
}
/**
* 根据药品ID更新药品信息
* @param medicine 新的药品信息
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "updateMedicineById")
public @ResponseBody
Map<String, Object> updateMedicineById(@RequestBody Medicine medicine) throws Exception {
int updateCount = medicineService.updateById(medicine);
Map<String, Object> result = new HashMap<String, Object>();
if (updateCount > 0) {
result.put("state", "success");
result.put("result", updateCount);
} else {
result.put("state", "fail");
result.put("reason", 0);
}
return result;
}
/**
* 根据药品ID数组删除一些药品信息
* @param medicineIds 药品ID数组
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "deleteSomeMedicine")
public @ResponseBody
Map<String, Object> deleteSomeMedicine(@RequestParam(value = "medicineIds[]") String[] medicineIds) throws Exception {
int deleteNum = medicineService.deleteSomeMedicine(medicineIds);
Map<String, Object> result = new HashMap<String, Object>();
if (deleteNum > 0) {
result.put("state", "success");
result.put("result", deleteNum);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
/**
* 添加药品
* @param medicine 药品信息
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "addMedicine")
public @ResponseBody
Map<String, Object> addMedicine(@RequestBody Medicine medicine) throws Exception {
int addCount = medicineService.addMedicine(medicine);
Map<String, Object> result = new HashMap<String, Object>();
if (addCount > 0) {
result.put("state", "success");
result.put("result", addCount);
} else {
result.put("state", "fail");
result.put("reason", 0);
}
return result;
}
/**
* 药品图片上传
* @param medicinePic 药品图片
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "addMedicinePic")
public @ResponseBody
Map<String, Object> addMedicinePic(HttpServletRequest request,
@RequestParam("medicinePic") MultipartFile medicinePic) throws Exception {
Map<String, Object> result = new HashMap<String, Object>();
String imgPath = medicineService.uploadFile(request, medicinePic);
System.out.println("upload img path: " + imgPath);
if (imgPath != null) {
result.put("state", "success");
result.put("result", imgPath);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
/**
* 根据过滤条件过滤查询药品总数
* @param medicine 药品过滤信息
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "getFilteredMedicineCount")
public @ResponseBody
Map<String, Object> getFilteredMedicineCount(@RequestBody Medicine medicine) throws Exception {
System.out.println("getFilteredMedicineCount --- medicine: " + medicine);
Map<String, Object> result = new HashMap<String, Object>();
int count = medicineService.getFilteredCount(medicine);
if (count > 0) {
result.put("state", "success");
result.put("result", count);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
}
MedicineTypeController
package com.clw.medicine.medi_detail.controller;
import com.clw.medicine.medi_detail.po.MedicineType;
import com.clw.medicine.medi_detail.service.MedicineTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Description:
* Author: clw
* Date: 2018/4/9
* Version: 1.0
*/
@Controller
@RequestMapping(value = "medicine/medicine_type", method = {RequestMethod.POST})
public class MedicineTypeController {
@Autowired
MedicineTypeService medicineTypeService;
/**
* 获取指定ID的药品类型信息
* @param typeIds String[] 药品类型ID数组
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "getSomeMedicineType")
public @ResponseBody
Map<String, Object> getSomeMedicineType(@RequestParam(value = "typeIds[]") String[] typeIds) throws Exception {
List<MedicineType> medicineTypes = medicineTypeService.getSomeMedicineType(typeIds);
Map<String, Object> result = new HashMap<String, Object>();
if (medicineTypes.size() > 0) {
result.put("state", "success");
result.put("result", medicineTypes);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
/**
* 获取药品类型总量
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "getMedicineTypeCount")
public @ResponseBody
Map<String, Object> getMedicineTypeCount() throws Exception {
int count = medicineTypeService.count();
Map<String, Object> result = new HashMap<String, Object>();
if (count > 0) {
result.put("state", "success");
result.put("result", count);
} else {
result.put("state", "fail");
result.put("reason", 0);
}
return result;
}
/**
* 获取指定数量的药品类型信息
* @param offset 偏移量
* @param limit 返回限制条数
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "getLimitMedicineType")
public @ResponseBody
Map<String, Object> getLimitMedicineType(@RequestParam(value = "offset") int offset,
@RequestParam(value = "limit") int limit) throws Exception {
List<MedicineType> medicineTypes = medicineTypeService.getLimitMedicineType(offset, limit);
Map<String, Object> result = new HashMap<String, Object>();
if (medicineTypes.size() > 0) {
result.put("state", "success");
result.put("result", medicineTypes);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
/**
* 根据药品类型ID更新药品类型信息
* @param medicineType 新的药品类型信息
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "updateMedicineTypeById")
public @ResponseBody
Map<String, Object> updateMedicineTypeById(@RequestBody MedicineType medicineType) throws Exception {
int updateCount = medicineTypeService.updateById(medicineType);
Map<String, Object> result = new HashMap<String, Object>();
if (updateCount > 0) {
result.put("state", "success");
result.put("result", updateCount);
} else {
result.put("state", "fail");
result.put("reason", 0);
}
return result;
}
/**
* 根据药品类型ID数组删除一些药品类型信息
* @param medicineTypeIds 药品类型ID数组
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "deleteSomeMedicineType")
public @ResponseBody
Map<String, Object> deleteSomeMedicineType(@RequestParam(value = "medicineTypeIds[]") String[] medicineTypeIds) throws Exception {
int deleteNum = medicineTypeService.deleteSomeMedicineType(medicineTypeIds);
Map<String, Object> result = new HashMap<String, Object>();
if (deleteNum > 0) {
result.put("state", "success");
result.put("result", deleteNum);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
/**
* 添加药品类型
* @param medicineType 药品信息
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "addMedicineType")
public @ResponseBody
Map<String, Object> addMedicineType(@RequestBody MedicineType medicineType) throws Exception {
System.out.println(medicineType);
int addCount = medicineTypeService.addMedicineType(medicineType);
Map<String, Object> result = new HashMap<String, Object>();
if (addCount > 0) {
result.put("state", "success");
result.put("result", addCount);
} else {
result.put("state", "fail");
result.put("reason", 0);
}
return result;
}
/**
* 查询所有药品类型
* @return Map 返回相关状态及信息
* @throws Exception 异常
*/
@RequestMapping(value = "getAllMedicineType")
public @ResponseBody
Map<String, Object> getAllMedicineType() throws Exception {
List<MedicineType> medicineTypes = medicineTypeService.getAllMedicineType();
Map<String, Object> result = new HashMap<String, Object>();
if (medicineTypes.size() > 0) {
result.put("state", "success");
result.put("result", medicineTypes);
} else {
result.put("state", "fail");
result.put("reason", null);
}
return result;
}
}
如果也想学习本系统,下面领取。关注并回复:006ssm