• 基于javaweb的在线社区药品销售商城(java+ssm+jsp+bootstrap+mysql)


    基于javaweb的在线社区药品销售商城(java+ssm+jsp+bootstrap+mysql)

    运行环境

    Java≥8、MySQL≥5.7、Tomcat≥8

    开发工具

    eclipse/idea/myeclipse/sts等均可配置运行

    适用

    课程设计,大作业,毕业设计,项目练习,学习演示等

    功能说明

    20220819204541

    20220819204542

    20220819204543

    20220819204544

    20220819204545

    20220819204546

    基于javaweb+mysql的在线社区药品销售商城(java+SSM+JSP+Bootstrap+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项目:是;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+jQuery+Bootstrap

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ssm_sqyp_shop/ 登录  注:Tomcat中配置项目路径必须为ssm_sqyp_shop 用户账号/密码: user/123456 管理员账号/密码:admin/admin

    用户管理控制层:

    @Controller

    @RequestMapping(value = “user/user”, method = {RequestMethod.POST})

    public class UserController {

    @Autowired

    UserService userService;

    /**

    • 登录Controller

    • @param request HttpServletRequest 对象

    • @param username 用户名

    • @param password 密码

    • @return Map 返回相关状态

    • @throws Exception 异常

    */

    @RequestMapping(value = “login”)

    public @ResponseBody

    Map login(HttpServletRequest request, @RequestParam(value = “username”, defaultValue = “”) String username,

    @RequestParam(value = “password”, defaultValue = “”) String password) throws Exception {

    System.out.println("username: " + username + ", password: " + password);

    User user = userService.loginCheck(username, password);

    Map resultMap =new HashMap();

    if (user != null) {

    request.getSession().setAttribute(“userid”, user.getUid());

    request.getSession().setAttribute(“username”, user.getUsername());

    request.getSession().setAttribute(“identity”, “user”);

    resultMap.put(“state”, “success”);

    } else {

    resultMap.put(“state”, “fail”);

    resultMap.put(“reason”, ErrorInfoUtil.getErrorInfo(“user.login.check.null”));

    return resultMap;

    /**

    • 获取指定用户ID的用户信息

    • @param userIds 用户ID数组

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “getSomeUser”)

    public @ResponseBody

    Map getSomeUser(@RequestParam(value = “userIds[]”) String[] userIds) throws Exception {

    List users = userService.getSomeUser(userIds);

    Map result = new HashMap();

    if (users.size() > 0) {

    result.put(“state”, “success”);

    result.put(“result”, users);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, null);

    return result;

    /**

    • 获取用户总量

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “getUserCount”)

    public @ResponseBody

    Map getUserCount() throws Exception {

    int count = userService.count();

    Map result = new HashMap();

    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 = “getLimitUser”)

    public @ResponseBody

    Map getLimitUser(@RequestParam(value = “offset”) int offset,

    @RequestParam(value = “limit”) int limit) throws Exception {

    List userList = userService.getLimitUser(offset, limit);

    Map result = new HashMap();

    if (userList.size() > 0) {

    result.put(“state”, “success”);

    result.put(“result”, userList);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, null);

    return result;

    /**

    • 根据用户ID更新用户信息

    • @param user 新的用户信息

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “updateUserById”)

    public @ResponseBody

    Map updateUserById(@RequestBody User user) throws Exception {

    int updateCount = userService.updateById(user);

    Map result = new HashMap();

    if (updateCount > 0) {

    result.put(“state”, “success”);

    result.put(“result”, updateCount);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, 0);

    return result;

    /**

    • 根据用户ID数组删除一些用户信息

    • @param userIds 用户ID数组

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “deleteSomeUser”)

    public @ResponseBody

    Map deleteSomeUser(@RequestParam(value = “userIds[]”) String[] userIds) throws Exception {

    int deleteNum = userService.deleteSomeUser(userIds);

    Map result = new HashMap();

    if (deleteNum > 0) {

    result.put(“state”, “success”);

    result.put(“result”, deleteNum);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, null);

    return result;

    /**

    • 添加用户

    • @param user 用户信息

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = {“addUser”, “registerUser”})

    public @ResponseBody

    Map addUser(@RequestBody User user) throws Exception {

    int addCount = userService.addUser(user);

    Map result = new HashMap();

    if (addCount > 0) {

    result.put(“state”, “success”);

    result.put(“result”, addCount);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, 0);

    return result;

    /**

    • 根据用户ID更新用户密码

    • @param uid 用户ID

    • @param originalPasswd 原密码

    • @param newPasswd 新密码

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “updateUserPasswdById”)

    public @ResponseBody

    Map updateUserPasswdById(@RequestParam(value = “uid”, defaultValue = “”) String uid,

    @RequestParam(value = “originalPasswd”, defaultValue = “”) String originalPasswd,

    @RequestParam(value = “newPasswd”, defaultValue = “”) String newPasswd) throws Exception {

    int updateCount = userService.updatePasswdById(uid, originalPasswd, newPasswd);

    Map result = new HashMap();

    if (updateCount > 0) {

    result.put(“state”, “success”);

    result.put(“result”, updateCount);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, 0);

    return result;

    /**

    • 获取当前登录用户

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “getCurrentUser”)

    public @ResponseBody

    Map getCurrentUser(HttpServletRequest request) throws Exception {

    String userId = (String) request.getSession().getAttribute(“userid”);

    User user = null;

    if (userId != null && !“”.equals(userId)) {

    user = userService.getUserById(userId);

    Map result = new HashMap();

    if (user != null) {

    result.put(“state”, “success”);

    result.put(“result”, user);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, null);

    return result;

    订单管理控制层:

    @Controller

    @RequestMapping(value = “orders/orders”, method = {RequestMethod.POST})

    public class OrdersController {

    @Autowired

    OrdersService ordersService;

    /**

    • 获取指定数量的订单信息

    • @param offset 偏移量

    • @param limit 限制返回条数

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “getLimitOrders”)

    public @ResponseBody

    Map getLimitOrders(@RequestParam(value = “offset”) int offset,

    @RequestParam(value = “limit”) int limit) throws Exception {

    List ordersList = ordersService.getLimitOrders(offset, limit);

    Map result = new HashMap();

    if (ordersList.size() > 0) {

    result.put(“state”, “success”);

    result.put(“result”, ordersList);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, null);

    return result;

    /**

    • 获取订单总量

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “getOrdersCount”)

    public @ResponseBody

    Map getOrdersCount() throws Exception {

    int count = ordersService.count();

    Map result = new HashMap();

    if (count > 0) {

    result.put(“state”, “success”);

    result.put(“result”, count);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, 0);

    return result;

    /**

    • 根据订单ID更新订单信息

    • @param orders 新的订单信息

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “updateOrdersById”)

    public @ResponseBody

    Map updateOrdersById(@RequestBody Orders orders) throws Exception {

    int updateCount = ordersService.updateById(orders);

    Map result = new HashMap();

    if (updateCount > 0) {

    result.put(“state”, “success”);

    result.put(“result”, updateCount);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, 0);

    return result;

    /**

    • 根据订单ID数组删除一些订单信息

    • @param ordersIds 订单ID数组

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “deleteSomeOrders”)

    public @ResponseBody

    Map deleteSomeOrders(@RequestParam(value = “ordersIds[]”) String[] ordersIds) throws Exception {

    int deleteNum = ordersService.deleteSomeOrders(ordersIds);

    Map result = new HashMap();

    if (deleteNum > 0) {

    result.put(“state”, “success”);

    result.put(“result”, deleteNum);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, null);

    return result;

    /**

    • 添加多条订单信息

    • @param ordersList 订单集合

    • @return Map 返回相关状态及信息

    • @throws Exception 异常

    */

    @RequestMapping(value = “addSomeOrders”)

    public @ResponseBody

    Map addSomeOrders(@RequestBody List ordersList) throws Exception {

    int addNum = ordersService.addSomeOrders(ordersList);

    Map result = new HashMap();

    if (addNum > 0) {

    result.put(“state”, “success”);

    result.put(“result”, addNum);

    } else {

    result.put(“state”, “fail”);

    result.put(“reason”, null);

    return result;

    药品管理控制器:

    /**

    • Descriiption: 药品控制器

    */

    @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 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 medicines = medicineService.getFilteredLimitMedicine(medTypeId, offset, limit);

    Map result = new HashMap();

    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 getSomeMedicine(@RequestParam(value = “medicineIds[]”) String[] medicineIds) throws Exception {

    List medicines = medicineService.getSomeMedicine(medicineIds);

    Map result = new HashMap();

    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 getMedicineCount() throws Exception {

    int count = medicineService.count();

    Map result = new HashMap();

    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 updateMedicineById(@RequestBody Medicine medicine) throws Exception {

    int updateCount = medicineService.updateById(medicine);

    Map result = new HashMap();

    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 deleteSomeMedicine(@RequestParam(value = “medicineIds[]”) String[] medicineIds) throws Exception {

    int deleteNum = medicineService.deleteSomeMedicine(medicineIds);

    Map result = new HashMap();

    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 addMedicine(@RequestBody Medicine medicine) throws Exception {

    int addCount = medicineService.addMedicine(medicine);

    Map result = new HashMap();

    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 addMedicinePic(HttpServletRequest request,

    @RequestParam(“medicinePic”) MultipartFile medicinePic) throws Exception {

    Map result = new HashMap();

    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 getFilteredMedicineCount(@RequestBody Medicine medicine) throws Exception {

    System.out.println("getFilteredMedicineCount — medicine: " + medicine);

    Map result = new HashMap();

    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;


  • 相关阅读:
    SSL/TLS工作原理:密钥、证书、SSL握手
    Linux常用命令
    民法通则配套规定(二)
    22 C++设计模式之备忘录(Memento)模式
    城中村智能水电表改造,提升居民生活品质
    第三范式
    内网渗透神器CobaltStrike之配置与基础操作(一)
    STL中map用法详解
    水泥行业工业互联网平台(CCPS)解决方案
    编译器一日一练(DIY系列之词法分析)
  • 原文地址:https://blog.csdn.net/m0_69592937/article/details/127579545