• Java项目:ssm药品管理系统


    作者主页:源码空间站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登录,购买要求,形成订单。

    运行截图

    前台界面

    后台界面

    相关代码 

    药品控制器

    1. package com.clw.medicine.medi_detail.controller;
    2. import com.clw.medicine.medi_detail.po.Medicine;
    3. import com.clw.medicine.medi_detail.service.MedicineService;
    4. import org.springframework.beans.factory.annotation.Autowired;
    5. import org.springframework.stereotype.Controller;
    6. import org.springframework.web.bind.annotation.*;
    7. import org.springframework.web.multipart.MultipartFile;
    8. import javax.servlet.http.HttpServletRequest;
    9. import java.util.HashMap;
    10. import java.util.List;
    11. import java.util.Map;
    12. /**
    13. * Description: 药品控制器
    14. * Author: clw
    15. * Date: 2018/4/9
    16. * Version: 1.0
    17. */
    18. @Controller
    19. @RequestMapping(value = "medicine/medicine", method = {RequestMethod.POST})
    20. public class MedicineController {
    21. @Autowired
    22. MedicineService medicineService;
    23. /**
    24. * 获取指定数量的药品信息
    25. * @param offset 偏移量
    26. * @param limit 返回限制条数
    27. * @return Map 返回相关状态及信息
    28. * @throws Exception 异常
    29. */
    30. @RequestMapping(value = "getFilteredLimitMedicine")
    31. public @ResponseBody
    32. Map getFilteredLimitMedicine(@RequestParam(value = "medTypeId", defaultValue = "") String medTypeId,
    33. @RequestParam(value = "offset") int offset,
    34. @RequestParam(value = "limit") int limit) throws Exception {
    35. medTypeId = "".equals(medTypeId) ? null : medTypeId;
    36. List medicines = medicineService.getFilteredLimitMedicine(medTypeId, offset, limit);
    37. Map result = new HashMap();
    38. if (medicines.size() > 0) {
    39. result.put("state", "success");
    40. result.put("result", medicines);
    41. } else {
    42. result.put("state", "fail");
    43. result.put("reason", null);
    44. }
    45. return result;
    46. }
    47. /**
    48. * 获取指定ID的药品信息
    49. * @param medicineIds String[] 药品ID数组
    50. * @return Map 返回相关状态及信息
    51. * @throws Exception 异常
    52. */
    53. @RequestMapping(value = "getSomeMedicine")
    54. public @ResponseBody
    55. Map getSomeMedicine(@RequestParam(value = "medicineIds[]") String[] medicineIds) throws Exception {
    56. List medicines = medicineService.getSomeMedicine(medicineIds);
    57. Map result = new HashMap();
    58. if (medicines.size() > 0) {
    59. result.put("state", "success");
    60. result.put("result", medicines);
    61. } else {
    62. result.put("state", "fail");
    63. result.put("reason", null);
    64. }
    65. return result;
    66. }
    67. /**
    68. * 获取药品总量
    69. * @return Map 返回相关状态及信息
    70. * @throws Exception 异常
    71. */
    72. @RequestMapping(value = "getMedicineCount")
    73. public @ResponseBody
    74. Map getMedicineCount() throws Exception {
    75. int count = medicineService.count();
    76. Map result = new HashMap();
    77. if (count > 0) {
    78. result.put("state", "success");
    79. result.put("result", count);
    80. } else {
    81. result.put("state", "fail");
    82. result.put("reason", 0);
    83. }
    84. return result;
    85. }
    86. /**
    87. * 根据药品ID更新药品信息
    88. * @param medicine 新的药品信息
    89. * @return Map 返回相关状态及信息
    90. * @throws Exception 异常
    91. */
    92. @RequestMapping(value = "updateMedicineById")
    93. public @ResponseBody
    94. Map updateMedicineById(@RequestBody Medicine medicine) throws Exception {
    95. int updateCount = medicineService.updateById(medicine);
    96. Map result = new HashMap();
    97. if (updateCount > 0) {
    98. result.put("state", "success");
    99. result.put("result", updateCount);
    100. } else {
    101. result.put("state", "fail");
    102. result.put("reason", 0);
    103. }
    104. return result;
    105. }
    106. /**
    107. * 根据药品ID数组删除一些药品信息
    108. * @param medicineIds 药品ID数组
    109. * @return Map 返回相关状态及信息
    110. * @throws Exception 异常
    111. */
    112. @RequestMapping(value = "deleteSomeMedicine")
    113. public @ResponseBody
    114. Map deleteSomeMedicine(@RequestParam(value = "medicineIds[]") String[] medicineIds) throws Exception {
    115. int deleteNum = medicineService.deleteSomeMedicine(medicineIds);
    116. Map result = new HashMap();
    117. if (deleteNum > 0) {
    118. result.put("state", "success");
    119. result.put("result", deleteNum);
    120. } else {
    121. result.put("state", "fail");
    122. result.put("reason", null);
    123. }
    124. return result;
    125. }
    126. /**
    127. * 添加药品
    128. * @param medicine 药品信息
    129. * @return Map 返回相关状态及信息
    130. * @throws Exception 异常
    131. */
    132. @RequestMapping(value = "addMedicine")
    133. public @ResponseBody
    134. Map addMedicine(@RequestBody Medicine medicine) throws Exception {
    135. int addCount = medicineService.addMedicine(medicine);
    136. Map result = new HashMap();
    137. if (addCount > 0) {
    138. result.put("state", "success");
    139. result.put("result", addCount);
    140. } else {
    141. result.put("state", "fail");
    142. result.put("reason", 0);
    143. }
    144. return result;
    145. }
    146. /**
    147. * 药品图片上传
    148. * @param medicinePic 药品图片
    149. * @return Map 返回相关状态及信息
    150. * @throws Exception 异常
    151. */
    152. @RequestMapping(value = "addMedicinePic")
    153. public @ResponseBody
    154. Map addMedicinePic(HttpServletRequest request,
    155. @RequestParam("medicinePic") MultipartFile medicinePic) throws Exception {
    156. Map result = new HashMap();
    157. String imgPath = medicineService.uploadFile(request, medicinePic);
    158. System.out.println("upload img path: " + imgPath);
    159. if (imgPath != null) {
    160. result.put("state", "success");
    161. result.put("result", imgPath);
    162. } else {
    163. result.put("state", "fail");
    164. result.put("reason", null);
    165. }
    166. return result;
    167. }
    168. /**
    169. * 根据过滤条件过滤查询药品总数
    170. * @param medicine 药品过滤信息
    171. * @return Map 返回相关状态及信息
    172. * @throws Exception 异常
    173. */
    174. @RequestMapping(value = "getFilteredMedicineCount")
    175. public @ResponseBody
    176. Map getFilteredMedicineCount(@RequestBody Medicine medicine) throws Exception {
    177. System.out.println("getFilteredMedicineCount --- medicine: " + medicine);
    178. Map result = new HashMap();
    179. int count = medicineService.getFilteredCount(medicine);
    180. if (count > 0) {
    181. result.put("state", "success");
    182. result.put("result", count);
    183. } else {
    184. result.put("state", "fail");
    185. result.put("reason", null);
    186. }
    187. return result;
    188. }
    189. }

    MedicineTypeController

    1. package com.clw.medicine.medi_detail.controller;
    2. import com.clw.medicine.medi_detail.po.MedicineType;
    3. import com.clw.medicine.medi_detail.service.MedicineTypeService;
    4. import org.springframework.beans.factory.annotation.Autowired;
    5. import org.springframework.stereotype.Controller;
    6. import org.springframework.web.bind.annotation.*;
    7. import java.util.HashMap;
    8. import java.util.List;
    9. import java.util.Map;
    10. /**
    11. * Description:
    12. * Author: clw
    13. * Date: 2018/4/9
    14. * Version: 1.0
    15. */
    16. @Controller
    17. @RequestMapping(value = "medicine/medicine_type", method = {RequestMethod.POST})
    18. public class MedicineTypeController {
    19. @Autowired
    20. MedicineTypeService medicineTypeService;
    21. /**
    22. * 获取指定ID的药品类型信息
    23. * @param typeIds String[] 药品类型ID数组
    24. * @return Map 返回相关状态及信息
    25. * @throws Exception 异常
    26. */
    27. @RequestMapping(value = "getSomeMedicineType")
    28. public @ResponseBody
    29. Map getSomeMedicineType(@RequestParam(value = "typeIds[]") String[] typeIds) throws Exception {
    30. List medicineTypes = medicineTypeService.getSomeMedicineType(typeIds);
    31. Map result = new HashMap();
    32. if (medicineTypes.size() > 0) {
    33. result.put("state", "success");
    34. result.put("result", medicineTypes);
    35. } else {
    36. result.put("state", "fail");
    37. result.put("reason", null);
    38. }
    39. return result;
    40. }
    41. /**
    42. * 获取药品类型总量
    43. * @return Map 返回相关状态及信息
    44. * @throws Exception 异常
    45. */
    46. @RequestMapping(value = "getMedicineTypeCount")
    47. public @ResponseBody
    48. Map getMedicineTypeCount() throws Exception {
    49. int count = medicineTypeService.count();
    50. Map result = new HashMap();
    51. if (count > 0) {
    52. result.put("state", "success");
    53. result.put("result", count);
    54. } else {
    55. result.put("state", "fail");
    56. result.put("reason", 0);
    57. }
    58. return result;
    59. }
    60. /**
    61. * 获取指定数量的药品类型信息
    62. * @param offset 偏移量
    63. * @param limit 返回限制条数
    64. * @return Map 返回相关状态及信息
    65. * @throws Exception 异常
    66. */
    67. @RequestMapping(value = "getLimitMedicineType")
    68. public @ResponseBody
    69. Map getLimitMedicineType(@RequestParam(value = "offset") int offset,
    70. @RequestParam(value = "limit") int limit) throws Exception {
    71. List medicineTypes = medicineTypeService.getLimitMedicineType(offset, limit);
    72. Map result = new HashMap();
    73. if (medicineTypes.size() > 0) {
    74. result.put("state", "success");
    75. result.put("result", medicineTypes);
    76. } else {
    77. result.put("state", "fail");
    78. result.put("reason", null);
    79. }
    80. return result;
    81. }
    82. /**
    83. * 根据药品类型ID更新药品类型信息
    84. * @param medicineType 新的药品类型信息
    85. * @return Map 返回相关状态及信息
    86. * @throws Exception 异常
    87. */
    88. @RequestMapping(value = "updateMedicineTypeById")
    89. public @ResponseBody
    90. Map updateMedicineTypeById(@RequestBody MedicineType medicineType) throws Exception {
    91. int updateCount = medicineTypeService.updateById(medicineType);
    92. Map result = new HashMap();
    93. if (updateCount > 0) {
    94. result.put("state", "success");
    95. result.put("result", updateCount);
    96. } else {
    97. result.put("state", "fail");
    98. result.put("reason", 0);
    99. }
    100. return result;
    101. }
    102. /**
    103. * 根据药品类型ID数组删除一些药品类型信息
    104. * @param medicineTypeIds 药品类型ID数组
    105. * @return Map 返回相关状态及信息
    106. * @throws Exception 异常
    107. */
    108. @RequestMapping(value = "deleteSomeMedicineType")
    109. public @ResponseBody
    110. Map deleteSomeMedicineType(@RequestParam(value = "medicineTypeIds[]") String[] medicineTypeIds) throws Exception {
    111. int deleteNum = medicineTypeService.deleteSomeMedicineType(medicineTypeIds);
    112. Map result = new HashMap();
    113. if (deleteNum > 0) {
    114. result.put("state", "success");
    115. result.put("result", deleteNum);
    116. } else {
    117. result.put("state", "fail");
    118. result.put("reason", null);
    119. }
    120. return result;
    121. }
    122. /**
    123. * 添加药品类型
    124. * @param medicineType 药品信息
    125. * @return Map 返回相关状态及信息
    126. * @throws Exception 异常
    127. */
    128. @RequestMapping(value = "addMedicineType")
    129. public @ResponseBody
    130. Map addMedicineType(@RequestBody MedicineType medicineType) throws Exception {
    131. System.out.println(medicineType);
    132. int addCount = medicineTypeService.addMedicineType(medicineType);
    133. Map result = new HashMap();
    134. if (addCount > 0) {
    135. result.put("state", "success");
    136. result.put("result", addCount);
    137. } else {
    138. result.put("state", "fail");
    139. result.put("reason", 0);
    140. }
    141. return result;
    142. }
    143. /**
    144. * 查询所有药品类型
    145. * @return Map 返回相关状态及信息
    146. * @throws Exception 异常
    147. */
    148. @RequestMapping(value = "getAllMedicineType")
    149. public @ResponseBody
    150. Map getAllMedicineType() throws Exception {
    151. List medicineTypes = medicineTypeService.getAllMedicineType();
    152. Map result = new HashMap();
    153. if (medicineTypes.size() > 0) {
    154. result.put("state", "success");
    155. result.put("result", medicineTypes);
    156. } else {
    157. result.put("state", "fail");
    158. result.put("reason", null);
    159. }
    160. return result;
    161. }
    162. }

    如果也想学习本系统,下面领取。关注并回复:006ssm 

     

  • 相关阅读:
    [答疑]系统首先维护的是本质而不是现象
    受众分析与卸载分析全面升级,HMS Core分析服务6.6.0版本上新
    为什么说企业内部管理需要ERP系统
    嵌入式led灯效驱动(easy_led)
    Windows 同时安装 MySQL5 和 MySQL8 版本
    怎么保护公司文件安全
    18uec++多人游戏【服务器为两个角色发枪,并能在线开枪】
    Java毕设项目——大学生社团管理系统(java+SSM+Maven+Mysql+Jsp)
    c++函数模板,类模板以使用
    华为云云耀云服务器L实例评测|企业项目最佳实践之docker部署及应用(七)
  • 原文地址:https://blog.csdn.net/m0_74967853/article/details/128073866