SSM实现校园超市管理系统(源码+SQL)

14 篇文章 1 订阅
订阅专栏
10 篇文章 1 订阅
订阅专栏

SSM实现校园超市管理系统

之前寒假写的一个小项目,idea写的,用了maven工程Spring+SpringMVC+MyBatis框架技术实现校园超市系统。

2019.12.28的重要通知:已完善基本功能    前后端分离    实现了前台页面展示,购物车,订单,收货地址,会员管理,支付宝付款等模块,静态文件例如图片采用ftp服务器上传

已上传到码云​​​​​​​

之前加的人有点多,源码+sql+jar已上传到    SSM实现校园超市管理系统(源码+SQL)_基于ssm的超市管理系统-Java代码类资源-CSDN下载

里边的sql放错了,正确的:链接:https://pan.baidu.com/s/1rhUfNyA4LmHpjTsxzVbvcw ji
提取码:3760 

同时也可以加我的QQ:354124728   互相交流一下升仙经验。。。   

1、数据库表:

item表:商品详情

order:订单

product:商品

product_type:商品类型

role:身份管理

sysuser:系统管理员

user:用户表

2、界面展示:

3、项目目录:

super_parent:父目录

super_common:公共目录(存放工具类、异常、常量等)

super_pojo:实体类

super_dao:数据访问层

super_service:业务层

super_base_web:Web模块——后台管理系统

4、部分实例代码(商品模块):

因为全写篇幅太长,所以挑出一个模块来做实例,其余差不多

4.1、Product

package com.market.pojo;

import java.io.Serializable;

public class Product  implements Serializable{

    private Integer id;
    private String batch;
    private String name;
    private Integer saleNumber;
    private Integer number;
    private Double price;
    private String info;
    private String image;
    private ProductType productType;
    private String pDate;

    public Integer getSaleNumber() {
        return saleNumber;
    }

    public void setSaleNumber(Integer saleNumber) {
        this.saleNumber = saleNumber;
    }

    public String getBatch() {
        return batch;
    }

    public void setBatch(String batch) {
        this.batch = batch;
    }

    public String getpDate() {
        return pDate;
    }

    public void setpDate(String pDate) {
        this.pDate = pDate;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public ProductType getProductType() {
        return productType;
    }

    public void setProductType(ProductType productType) {
        this.productType = productType;
    }
}

4.2、ProductDao

package com.market.dao;

import com.market.pojo.Product;
import org.apache.commons.fileupload.FileUploadException;

import java.util.List;

/**
 * @Auther:jiaxuan
 * @Date: 2019/2/21 0021 13:02
 * @Description:
 */
public interface ProductDao {
    public void insert(Product product);

    //int insert(Product product);

    Product selectByName(String name);

    List<Product> selectAll();

    Product selectById(int id);

    int update(Product product);

    void deleteById(int id);



}

ProductMapper.xml 

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.market.dao.ProductDao">
    <resultMap id="productMap" type="com.market.pojo.Product">
        <id property="id" column="id"/>
        <result property="batch" column="batch"/>
        <result property="name" column="name"/>
        <result property="number" column="number"/>
        <result property="price" column="price"/>
        <result property="info" column="info"/>
        <result property="image" column="image"/>
        <result property="pDate" column="p_date" jdbcType="DATE"/>
        <association property="productType" javaType="ProductType" column="product_type_id">
            <id property="id" column="product_type_id"/>
        </association>
    </resultMap>

    <resultMap id="productMap2" type="Product">
        <id property="id" column="id"/>
        <result property="batch" column="batch"/>
        <result property="name" column="name"/>
        <result property="number" column="number"/>
        <result property="saleNumber" column="sale_number"/>
        <result property="price" column="price"/>
        <result property="info" column="info"/>
        <result property="image" column="image"/>
        <result property="pDate" column="p_date" jdbcType="DATE"/>
        <association property="productType" javaType="ProductType" column="product_type_id">
            <id property="id" column="pt.id"/>
            <result property="name" column="pt.name"/>
            <result property="status" column="status"/>
        </association>
    </resultMap>

    <sql id="productColumn">
        id,
        batch,
        name,
        number,
        price,
        info,
        image,
        product_type_id,
        p_date
    </sql>


    <insert id="insert" parameterType="com.market.pojo.Product">
        insert into t_product
          (id,batch,name,number , price,info, image, product_type_id,p_date)
        values
          (#{id},#{batch},#{name},#{number},#{price},#{info},#{image},#{productType.id},#{pDate})
    </insert>


    <select id="selectByName" resultMap="productMap">
        select <include refid="productColumn"/>
        from t_product
        where name=#{name}
    </select>

    <select id="selectAll" resultMap="productMap2">
        select p.id,p.batch,p.name,p.number,p.sale_number,p.price,p.info,p.image,p.product_type_id,pt.id 'pt.id',pt.name 'pt.name',pt.status,p.p_date
        from t_product p
          left join t_product_type pt
          on p.product_type_id=pt.id
    </select>

    <select id="selectById" resultMap="productMap">
        select <include refid="productColumn"/>
        from t_product
        where id=#{id}
    </select>

    <update id="update" parameterType="Product">
        update t_product
        <set>
            <if test="batch!=null and batch!=''">
                batch=#{batch},
            </if>
            <if test="name!=null and name!=''">
                name=#{name},
            </if>
            <if test="sale_number!=null">
                sale_number=#{sale_number},
            </if>
            <if test="number!=null">
                number=#{number},
            </if>
            <if test="price!=null and price!=''">
                price=#{price},
            </if>
            <if test="info!=null and info!=''">
                info=#{info},
            </if>
            <if test="image!=null and image!=''">
                image=#{image},
            </if>
            <if test="product_type_id!=null and product_type_id!=''">
                product_type_id=#{product_type_id},
            </if>
        </set>
        where id=#{id}
    </update>

    <delete id="deleteById">
        delete from t_product
        where id=#{id}
    </delete>



</mapper>

4.3、ProductService

ProductService接口:

package com.market.service;

import com.market.dto.ProductDto;
import com.market.pojo.Product;
import org.apache.commons.fileupload.FileUploadException;

import java.io.OutputStream;
import java.util.List;

/**
 * @Auther:jiaxuan
 * @Date: 2019/2/20 0020 16:21
 * @Description:
 */
public interface ProductService {

    //public int add(Product product);

    public void add(ProductDto productDto) throws FileUploadException;

    boolean checkName(String name);

    List<Product> findAll();

    Product findById(int id);

    void modify(ProductDto productDto) throws FileUploadException;

    void getImage(String path, OutputStream outputStream);


    public void updateNum(Product product);

    void removeById(int id);
}

实现类:

package com.market.service.Impl;

import com.market.common.util.StringUtils;
import com.market.dao.ProductDao;
import com.market.dto.ProductDto;
import com.market.pojo.Product;
import com.market.pojo.ProductType;
import com.market.service.ProductService;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.fileupload.FileUploadException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StreamUtils;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;

/**
 * @Auther:jiaxuan
 * @Date: 2019/2/20 0020 16:35
 * @Description:
 */
@Service
/**
 * 声明式事务
 * 1.如果存在一个事务,则支持当前事务。如果没有事务则开启
 * 2.事物在遇到非运行时异常时也回滚
 */
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductDao productDao;


    @Override
    public void add(ProductDto productDto) throws FileUploadException {
        //1.文件上传
        String fileName = StringUtils.renameFileName(productDto.getFileName());
        String filePath = productDto.getUploadPath()+"/"+fileName;

        try {
            StreamUtils.copy(productDto.getInputStream(),new FileOutputStream(filePath));
        } catch (IOException e) {
            //e.printStackTrace();
            throw new FileUploadException("文件上传失败"+e.getMessage());
        }
        //2.保存到数据库,将DTO转换为PO
        Product product = new Product();
        try {
            PropertyUtils.copyProperties(product,productDto);
            product.setImage(filePath);

            ProductType productType = new ProductType();
            productType.setId(productDto.getProductTypeId());

            product.setProductType(productType);

            productDao.insert(product);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


//    @Override
//    public int add(Product product) {
//        return productDao.insert(product);
//    }

    @Override
    public boolean checkName(String name) {
        Product product = productDao.selectByName(name);
        if (product!=null){
            return false;
        }
        return true;
    }

    @Override
    public List<Product> findAll() {
        return productDao.selectAll();
    }

    @Override
    public Product findById(int id) {
        return productDao.selectById(id);
    }

    @Override
    public void modify(ProductDto productDto) throws FileUploadException {
        // 1.文件上传
        String fileName = StringUtils.renameFileName(productDto.getFileName());
        String filePath=productDto.getUploadPath()+"/"+fileName;
        try {
            StreamUtils.copy(productDto.getInputStream(),new FileOutputStream(filePath));
        } catch (IOException e) {
            throw new FileUploadException("文件上传失败"+e.getMessage());
        }
        // 2.保存到数据库,将DTO转换为PO
        Product product = new Product();
        try {
            PropertyUtils.copyProperties(product,productDto);
            product.setImage(filePath);

            ProductType productType = new ProductType();
            productType.setId(productDto.getProductTypeId());

            product.setProductType(productType);
            productDao.update(product);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 获取图片,写到输出流中
     * @param path
     * @param outputStream
     */
    @Override
    public void getImage(String path, OutputStream outputStream) {
        try {
            StreamUtils.copy(new FileInputStream(path),outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void updateNum(Product product) {
         productDao.update(product);
    }

    @Override
    public void removeById(int id) {
        productDao.deleteById(id);
    }
}

4.4、ProductBase

ProductController

package com.market.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.market.common.constant.PageConstant;
import com.market.common.constant.ResponseStatusConstant;
import com.market.common.exception.ProductTypeExistsException;
import com.market.common.util.DateUtil;
import com.market.common.util.ResponsResult;
import com.market.dto.ProductDto;
import com.market.pojo.Product;
import com.market.pojo.ProductType;
import com.market.service.ProductService;
import com.market.service.ProductTypeService;
import com.market.vo.ProductVo;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.fileupload.FileUploadException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther:jiaxuan
 * @Date: 2019/2/20 0020 14:44
 * @Description:
 */
@Controller
@RequestMapping("/base/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @Autowired
    private ProductTypeService productTypeService;

    @ModelAttribute("productTypes")
    public List<ProductType> loadProductTypes() {
        List<ProductType> productTypes = productTypeService.findEnable();
        return productTypes;
    }


    @RequestMapping("/findAll")
    public String findAll(Integer pageNum, Model model){
        if (pageNum==null) {
            pageNum = PageConstant.PAGE_NUM;
        }

        PageHelper.startPage(pageNum,PageConstant.PAGE_SIZE);
        List<Product> products = productService.findAll();
        PageInfo<Product> pageInfo = new PageInfo<Product>(products);
        model.addAttribute("pageInfo", pageInfo);

        return "productManager";
    }

    @RequestMapping("/findInfo")
    public String findInfo(Integer pageNum, Model model){
        if (pageNum==null) {
            pageNum = PageConstant.PAGE_NUM;
        }

        PageHelper.startPage(pageNum,PageConstant.PAGE_SIZE_FRONT);
        List<Product> products = productService.findAll();
        PageInfo<Product> pageInfo = new PageInfo<Product>(products);
        model.addAttribute("pageInfo", pageInfo);

        return "productInfo";
    }

    @RequestMapping("/findSale")
    public String findSale(Integer pageNum, Model model){
        if (pageNum==null) {
            pageNum = PageConstant.PAGE_NUM;
        }

        PageHelper.startPage(pageNum,PageConstant.PAGE_SIZE_FRONT);
        List<Product> products = productService.findAll();
        PageInfo<Product> pageInfo = new PageInfo<Product>(products);
        model.addAttribute("pageInfo", pageInfo);

        return "productSale";
    }


//    @RequestMapping("/add")
//    @ResponseBody
//    public String add(HttpServletRequest request, @RequestParam("file") MultipartFile file,String fileName,
//                      Product product,Model model) throws Exception{
//        Date day = new Date();
//        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
//        String batch = df.format(day).toString()+String.valueOf((int)(Math.random()*9000+1000));
//        ProductType productType = new ProductType();
//
//        product.setProductType(productType);
//        product.setpDate(DateUtil.getCurrentDateStr());
//        product.setImage(fileName);
//        product.setBatch(batch);
//        productService.add(product);
//        //如果文件不为空,写入上传路径
//        if(!file.isEmpty()) {
//            //上传文件路径
//            String path = request.getSession().getServletContext().getRealPath("/WEB-INF/upload");
//            //上传文件名
//            String filename = fileName;
//            File filepath = new File(path,filename);
//            //判断路径是否存在,如果不存在就创建一个
//            if (!filepath.getParentFile().exists()) {
//                filepath.getParentFile().mkdirs();
//            }
//            //将上传文件保存到一个目标文件当中
//            file.transferTo(new File(path + File.separator + filename));
//            return "forward:findAll";
//        } else {
//            return "forward:findAll";
//        }
//    }

    //C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\ROOT\WEB-INF\images
      @RequestMapping("/add")
      public String add(ProductVo productVo, HttpSession session,Integer pageNum,Model model){
        String uploadPath = session.getServletContext().getRealPath("/WEB-INF/images");
                System.out.println(uploadPath);
          try {
              ProductDto productDto = new ProductDto();
              Date day = new Date();
              SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
              String batch = df.format(day).toString()+String.valueOf((int)(Math.random()*9000+1000));
              //对象属性间的拷贝
              PropertyUtils.copyProperties(productDto,productVo);
              productDto.setBatch(batch);
              productDto.setpDate(DateUtil.getCurrentDateStr());
              productDto.setInputStream(productVo.getFile().getInputStream());
              productDto.setFileName(productVo.getFile().getOriginalFilename());
              productDto.setUploadPath(uploadPath);

              productService.add(productDto);
              model.addAttribute("successMsg","添加成功");
          } catch (Exception e) {
              model.addAttribute("errorMsg",e.getMessage());
          }
          return "forward:findAll";

      }


    /**
     * 检测名称是否已经存在
     */
    @RequestMapping("/checkName")
    @ResponseBody
    public Map<String, Object> checkName(String name) {
        Map<String, Object> map = new HashMap<>();
        if (productService.checkName(name)) { //不存在,可用
            map.put("valid", true);
        } else {
            map.put("valid", false);
            map.put("message", "商品(" + name + ")已存在");
        }
        return map;
    }

    @RequestMapping("/findById")
    @ResponseBody
    public ResponsResult findById(int id){
        Product product = productService.findById(id);
        return ResponsResult.success(product);
    }

    @RequestMapping("/getImage")
    public void getImage(String path, OutputStream outputStream) {
        productService.getImage(path, outputStream);
    }

    @ResponseBody
    @RequestMapping("/updateNumber")
    public Map<String,Object> updateNumber(Product product){
        Map<String, Object> result = new HashMap<>();
        Product productNumber = productService.findById(product.getId());
        product.setSaleNumber(product.getNumber());
        Integer number = productNumber.getNumber() - product.getNumber();
        if (number>0){
            product.setNumber(number);
        }else {
            result.put("success",false);
            result.put("errorInfo","商品数量不足");
            return result;
        }
        productService.updateNum(product);
        result.put("success", true);
        return result;
    }

    @RequestMapping("/removeById")
    @ResponseBody
    public ResponsResult removeById(int id){
        productService.removeById(id);
        return ResponsResult.success();
    }
}

4.5、Spring-dao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:property-placeholder location="classpath:*.properties"/>

    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="initialSize" value="${jdbc.initialSize}"/>
    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mapperLocations" value="classpath:com/market/mapper/*.xml"/>
        <property name="typeAliasesPackage" value="com.market.pojo"/>
        <!-- 分页插件pagehelper -->
        <property name="plugins">
            <list>
                <!--拦截器-->
                <bean class="com.github.pagehelper.PageInterceptor">
                    <property name="properties">
                        <!--指定数据库-->
                        <props>
                            <prop key="helperDialect">mysql</prop>
                        </props>
                    </property>
                </bean>
            </list>
        </property>
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
        <property name="basePackage" value="com.market.dao"/>
    </bean>

</beans>

4.6、Spring-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!--注解驱动 配置Fastjson 响应json数据-->
    <mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
                <property name="supportedMediaTypes" value="application/json;charset=utf-8"/>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>

    <!--扫描包-->
    <context:component-scan base-package="com.market.controller"/>
    <!--视图解析器-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <mvc:view-controller path="/showLogin" view-name="login"/>

    <!--映射路径 静态资源-->
    <mvc:resources mapping="/css/**" location="/WEB-INF/css/"/>
    <mvc:resources mapping="/js/**" location="/WEB-INF/js/"/>
    <mvc:resources mapping="/images/**" location="/WEB-INF/images/"/>
    <mvc:resources mapping="/fonts/**" location="/WEB-INF/fonts/"/>
    <mvc:resources mapping="/iconfont/**" location="/WEB-INF/iconfont/"/>
    <mvc:resources mapping="/layer/**" location="/WEB-INF/layer/"/>

    <!--文件上传-->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- 上传文件大小上限,单位为字节(10MB) -->
        <property name="maxUploadSize">
            <value>10485760</value>
        </property>
        <!-- 请求的编码格式,必须和jSP的pageEncoding属性一致,以便正确读取表单的内容,默认为ISO-8859-1 -->
        <property name="defaultEncoding">
            <value>UTF-8</value>
        </property>
    </bean>

</beans>

4.7、Spring-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

       <context:component-scan base-package="com.market.service.Impl"/>

       <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
              <property name="dataSource" ref="dataSource"/>
       </bean>

       <!--支持事务注解-->
       <tx:annotation-driven transaction-manager="transactionManager"/>

</beans>

4.8、dataSource.properties

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/supermarket?useUnicde=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=你密码
jdbc.initialSize=5

4.9、Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <!--springMVC的核心控制器-->
  <servlet>
    <servlet-name>springMVC</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring*.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>springMVC</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <!--字符编码过滤器-->
  <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>utf-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

</web-app>

4.10、ProductMananger

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>base</title>
    <link rel="stylesheet"  href="${pageContext.request.contextPath}/css/bootstrap.css" />
    <link rel="stylesheet"  href="${pageContext.request.contextPath}/css/index.css" />
    <link rel="stylesheet"  href="${pageContext.request.contextPath}/css/file.css" />
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
    <script src="${pageContext.request.contextPath}/js/userSetting.js"></script>
    <script src="${pageContext.request.contextPath}/layer/layer.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap-paginator.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrapValidator.min.js"></script>
    <link rel="stylesheet"  href="${pageContext.request.contextPath}/css/zshop.css" />
    <link rel="stylesheet"  href="${pageContext.request.contextPath}/css/bootstrapValidator.min.css" />
    <script>
        $(function(){

            $('#pagination').bootstrapPaginator({
                bootstrapMajorVersion:3,
                currentPage:${pageInfo.pageNum},
                totalPages:${pageInfo.pages},
                pageUrl:function(type,page, current){
                    return '${pageContext.request.contextPath}/base/product/findAll?pageNum='+page;
                },
                itemTexts: function (type, page, current) {
                    switch (type) {
                        case "first":
                            return "首页";
                        case "prev":
                            return "上一页";
                        case "next":
                            return "下一页";
                        case "last":
                            return "末页";
                        case "page":
                            return page;
                    }
                }
            });


            //上传图像预览
            $('#file').on('change',function() {
                $('#img').attr('src', window.URL.createObjectURL(this.files[0]));
            });
            $('#file').on('change',function() {
                $('#img2').attr('src', window.URL.createObjectURL(this.files[0]));
            });
        });

        //服务端提示消息
        var successMsg='${successMsg}';
        var errorMsg='${errorMsg}';
        if(successMsg!=''){
            layer.msg(successMsg,{
                time:2000,
                skin:'successMsg'
            })
        }
        if(errorMsg!=''){
            layer.msg(errorMsg,{
                time:2000,
                skin:'errorMsg'
            })
        }
        //显示商品信息
        function showProduct(id) {
            $.post(
                '${pageContext.request.contextPath}/base/product/findById',
                {'id':id},
                function (result) {
                    if (result.status==1){
                        $('#pro-number').val(result.data.number);
                        $('#pro-name').val(result.data.name);
                        $('#pro-num').val(result.data.id);
                        $('#pro-price').val(result.data.price);
                        $('#pro-TypeId').val(result.data.productType.id);
                        $('#img2').attr('src','${pageContext.request.contextPath}/base/product/getImage?path='+result.data.image);
                    }
                }
            )
        }
        //显示删除模态框
        function showDeleteModal(id){
            $('#deleteProductId').val(id);
            $('#deleteProductModal').modal('show');
        }
        //显示卖出模态框
        function showSaleProduct(id){
            $('#saleProductId').val(id);
            $('#saleProductModal').modal('show');
        }

        function saleProduct() {
            var id =$("#ids").val();
            var number =$("#numbers").val();
            $.post(
                '${pageContext.request.contextPath}/base/product/updateNumber',
                {'id':id,number:number},
                function (result) {
                    if (result.success){
                        layer.closeAll();
                        layer.msg('销售成功');
                    }else {
                        layer.msg('失败')
                    }
                }
            )
        }

        //删除商品
        function deleteProduct(){
            $.post(
                '${pageContext.request.contextPath}/base/product/removeById',
                {'id':$('#deleteProductId').val()},
                function(result){
                    if(result.status==1){
                        layer.msg('删除成功',{
                            time:2000,
                            skin:'successMsg'
                        })
                    }
                }
            )
        }


    </script>
</head>

<body>
<div class="panel panel-default" id="userPic">
    <div class="panel-heading">
        <h3 class="panel-title">商品管理</h3>
    </div>
    <div class="panel-body">
        <input type="button" value="添加商品" class="btn btn-primary" id="doAddPro">
        <br>
        <br>
        <div class="show-list text-center" >
            <table class="table table-bordered table-hover" style='text-align: center;'>
                <thead>
                <tr class="text-danger">
                    <th class="text-center">图片</th>
                    <th class="text-center">编号</th>
                    <th class="text-center">商品批次号</th>
                    <th class="text-center">商品</th>
                    <th class="text-center">数量</th>
                    <th class="text-center">价格</th>
                    <th class="text-center">商品详情</th>
                    <th class="text-center">产品类型</th>
                    <th class="text-center">状态</th>
                    <th class="text-center">生产日期</th>
                    <th class="text-center">操作</th>
                </tr>
                </thead>
                <tbody id="tb">
                <c:forEach items="${pageInfo.list}" var="product">
                <tr>
                    <td>
                    <img src="${product.image}" class="img-responsive">
                    </td>
                    <td>${product.id}</td>
                    <td>${product.batch}</td>
                    <td>${product.name}</td>
                    <td>${product.number}</td>
                    <td>${product.price}</td>
                    <td>${product.info}</td>
                    <td>${product.productType.name}</td>
                    <td>
                        <c:if test="${product.productType.status==1}">有效商品</c:if>
                        <c:if test="${product.productType.status==0}">无效商品</c:if>
                    </td>
                    <td>${product.pDate}</td>
                    <td class="text-center">
                        <input type="button" class="btn btn-info btn-sm saleProduct" value="卖出" onclick="showSaleProduct(${product.id})">
                        <input type="button" class="btn btn-primary btn-sm doProModify" value="修改" onclick="showProduct(${product.id})">
                        <input type="button" class="btn btn-warning btn-sm doProDelete" value="删除" onclick="showDeleteModal(${product.id})">
                    </td>
                </tr>
                </c:forEach>
                </tbody>
            </table>
            <!-- 使用bootstrap-paginator实现分页 -->
            <ul id="pagination"></ul>
        </div>
    </div>
</div>

<!-- 添加商品 start -->
<div class="modal fade" tabindex="-1" id="Product">
    <div class="modal-dialog modal-lg">
        <!-- 内容声明 -->
        <form action="${pageContext.request.contextPath}/base/product/add" class="form-horizontal" method="post" enctype="multipart/form-data" id="frmAddProduct">
            <div class="modal-content">
                <!-- 头部、主体、脚注 -->
                <div class="modal-header">
                    <button class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">添加商品</h4>
                </div>
                <div class="modal-body text-center row">
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label for="product-name" class="col-sm-4 control-label">商品名称:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="product-name" name="name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="product-price" class="col-sm-4 control-label">商品价格:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="product-price" name="price">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="product-number" class="col-sm-4 control-label">商品数量:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="product-number" name="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="product-info" class="col-sm-4 control-label">商品描述:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="product-info" name="info">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="file" class="col-sm-4 control-label">商品图片:</label>
                            <div class="col-sm-8">
                                <a href="javascript:;" class="file">选择文件
                                    <input type="file" name="file" id="file">
                                </a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="product-type" class="col-sm-4 control-label">商品类型:</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="productTypeId" id="product-type">
                                    <option value="">--请选择--</option>
                                    <c:forEach items="${productTypes}" var="productType">
                                        <option value="${productType.id}">${productType.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <!-- 显示图像预览 -->
                        <img style="width: 160px;height: 180px;" id="img">
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary" type="submit">添加</button>
                    <button class="btn btn-primary cancel" data-dismiss="modal">取消</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 添加商品 end -->

<!-- 修改商品 start -->
<div class="modal fade" tabindex="-1" id="myProduct">
    <!-- 窗口声明 -->
    <div class="modal-dialog modal-lg">
        <!-- 内容声明 -->
        <form action="" class="form-horizontal">
            <div class="modal-content">
                <!-- 头部、主体、脚注 -->
                <div class="modal-header">
                    <button class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">修改商品</h4>
                </div>
                <div class="modal-body text-center row">
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label for="pro-num" class="col-sm-4 control-label">商品编号:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="pro-num" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pro-name" class="col-sm-4 control-label">商品名称:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="pro-name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pro-number" class="col-sm-4 control-label">商品数量:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="pro-number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pro-price" class="col-sm-4 control-label">商品价格:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="pro-price">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pro-image" class="col-sm-4 control-label">商品图片:</label>
                            <div class="col-sm-8">
                                <a class="file">
                                    选择文件 <input type="file" name="file" id="pro-image">
                                </a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="product-type" class="col-sm-4 control-label">商品类型:</label>
                            <div class="col-sm-8">
                                <select class="form-control">
                                    <option value="">--请选择--</option>
                                    <c:forEach items="${productTypes}" var="productType">
                                        <option value="${productType.id}">${productType.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <!-- 显示图像预览 -->
                        <img style="width: 160px;height: 180px;" id="img2">
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary updatePro">修改</button>
                    <button class="btn btn-primary cancel" data-dismiss="modal">取消</button>
                </div>
            </div>
        </form>
    </div>
    <!-- 修改商品 end -->
</div>

<!-- 出库 start -->
<div class="modal fade" tabindex="-1" id="saleProductModal">
    <!-- 窗口声明 -->
    <div class="modal-dialog modal-lg">
        <!-- 内容声明 -->
        <form>
            <div class="modal-content">
                <!-- 头部、主体、脚注 -->
                <div class="modal-header">
                    <button class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">出售商品</h4>
                </div>
                <div class="modal-body text-center row">
                    <div class="col-sm-8">
                        <input type="hidden" name="pageNum" value="${pageInfo.pageNum}">
                        <div class="form-group">
                            <label for="numbers" class="col-sm-4 control-label">商品数量:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="numbers" name="numbers">
                            </div>
                        </div>

                    </div>
                </div>
                <div class="modal-footer" id="saleProductId">
                    <button class="btn btn-primary salePro" onclick="saleProduct()" data-dimiss="modal">卖出</button>
                    <button class="btn btn-primary cancel" data-dismiss="modal">取消</button>
                </div>
            </div>
        </form>
    </div>
    <!-- 修改商品 end -->
</div>

<!-- 确认删除 start -->
<div class="modal fade" tabindex="-1" id="deleteProductModal">
    <!-- 窗口声明 -->
    <div class="modal-dialog">
        <!-- 内容声明 -->
        <div class="modal-content">
            <!-- 头部、主体、脚注 -->
            <div class="modal-header">
                <button class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">提示消息</h4>
            </div>
            <div class="modal-body text-center row">
                <h4>确认要删除该商品吗</h4>
            </div>
            <div class="modal-footer">
                <input type="hidden" id="deleteProductId">
                <button class="btn btn-primary updatePro" onclick="deleteProduct()" data-dimiss="modal">确认</button>
                <button class="btn btn-primary cancel" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!-- 确认删除 end -->

</body>

</html>

ssm商品超市管理系统
07-20
基于ssm+mysql搭建的一套商品超市管理系统,内置功能比较全,可用于毕业设计,项目导入即可实用配置简单。
SSM(spring+springMvc+mybatis)超市订单管理系统
qq_41557396的博客
09-17 9540
SSM(spring+springMvc+mybatis)超市订单管理系统 登录地址:http://localhost:8080/项目名 账号:admin 密码:1111111 开发环境 myeclipse 2014+Mysql+Tomcat7.0+JDK1.7 注: 数据库名:smbms 在/项目名/resources/database.properties修改自己的数据库名和密码 项...
校园超市管理系统
最新发布
laojin1234的博客
08-01 305
2.1毕业设计是最能体现出我们所学知识的应用情况,是对我们大学期间所学知识的应用巩固和提高的时刻。通过这次的毕业设计让我对软件的开发有了很深的认识了解,我的编程能力也得到了很大的提升。
Java基于ssm开发的校园超市系统超市商城源码超市网站
飞一样的编程
01-10 304
java使用ssm开发的校园超市系统,为方便学生不受时间限制,可以随时购物,不用到超市也能找到自己需要的日用品,开发了这个校园超市系统。学生用户可以注册浏览商品,加入购物车或者直接下单购买,在个人中心管理收货地址和订单,管理员也就是商家登录后台可以发布商品,上下架商品,处理待发货订单等
SSM框架开发的超市订单管理系统
01-04
SSM框架开发的超市订单管理系统,java web开发简单的超市后台管理系统要求: 1,SSM框架开发超市管理系统 2,SSM框架的搭建 3,实现超市管理系统的登录和注销 4,实现超市的订单管理 5,实现超市的供应商管理 6,实现超市的用户管理
学生作业 SSM实现校园超市管理系统(源码+SQL).zip
03-08
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,...
课程设计-基于SSM实现校园宽带后台业务系统源码+sql数据库+设计报告(可办理和注销宽带).zip
07-26
课程设计-基于SSM实现校园宽带后台业务系统源码+sql数据库+设计报告(可办理和注销宽带).zip 课程:系统设计与开发项目实践(J2EE 框架) 题目: 客户关系管理系统 硬件准备: 1.安装有Microsoft window7 64操作系统...
基于SSM+Vue的智慧校园信息管理分析系统设计与实现+源码+SQL
06-28
基于SSM+Vue的智慧校园信息管理分析系统设计与实现+源码+SQL,参考bilibili上尚硅谷的spring实战视频进行编码,前后端分离。 前端:HTML+CSS+VUE,后端:SpringBoot+MybatisPlus框架
课设毕设基于SSM校园外卖管理系统LW+源码可运行.zip
05-19
标题中的“课设毕设基于SSM校园外卖管理系统LW+源码可运行.zip”表明这是一个用于课程设计或毕业设计的项目,采用的是SSM技术栈,即Spring、SpringMVC和MyBatis框架,主要功能是实现校园外卖管理。这个系统提供了...
SSM框架开发超市管理系统
11-29
资源里含SQL语句。利用ssm框架开发超市管理系统。包括管理系统的登录,注销功能,实现超市的订单管理,实现超市的供应商管理,实现超市的用户管理。
SQL超市管理系统
01-03
超市管理系统,结合VB,并附有课设报告。登陆界面,仓库界面,收银界面
ssm 超市订单管理系统
05-09
ssm spring mvc spring mybatis 超市订单管理系统 ssm spring mvc spring mybatis 超市订单管理系统
基于SSM的简单超市管理系统
11-23
基于spring springMVC mybaitis三种框架技术,较为简单,易于修改
sql数据库的超市管理系统
06-11
超市管理系统。主要涉及到的就是对于超市系统的后台数据的管理。 本系统采用基于Windows的图形用户界面,而该系统是大家熟悉的操作系统,对于那些有一般的计算机知识的人员就可以轻松上手。而整个超市管理系统采用最友好的交互界面,简介明了,不需要对数据库进行深入的了解。 在本系统里面有3种身份:售货员、经理、系统管理员。每个人相互联系又各自独立。其中,经理和系统管理员有售货员的所有权限。
SQl超市管理系统
12-28
非常适合大学生结课设计学习的资源。完整详细,解压后就可以使用。
基于SSM超市管理系统
wangbuerCoder的博客
08-21 1447
基于SSM超市管理系统拥有两种角色 管理员:用户管理、商品管理、分类管理、咨询列表管理、权限管理、支付管理、留言管理、角色管理、管理员管理、订单管理、采购管理等 用户:商品查看、购买、购物车、商品下单、设置收货地址、登录注册等
基于ssm超市管理系统
微小白
01-31 839
基于ssm超市管理系统,主要功能包括商品结算、商品库存、商品分类、供应商管理、销售统计、用户管理等。
Java项目:ssm校内超市管理系统
08-18 2056
系统分为管理员与普通用户两种角色。采用后端SSM框架,前端BootStrap(前后端不分离)的系统架构模式,实现了基本的超市管理功能;本系统实现超市管理的基本功能,包括商品库存模块,商品分类模块,供应商管理模块,销售统计模块以及用户管理模块。...
写文章

分类专栏

  • Java Web 10篇
  • 面试题库 4篇
  • 云计算 1篇
  • 机器学习 1篇
  • 分布式架构 5篇
  • 数据结构与算法 8篇
  • 快捷键 1篇
  • c语言经典100题 22篇
  • Spring Web 14篇
  • 排序 2篇
  • 算法 2篇
  • linux 15篇
  • 设计模式 3篇
  • python 7篇

最新评论

  • XDF赵海英老师C语言课程——考研考级专用(推荐)

    A重阳D: 可以给我一份吗

  • XDF赵海英老师C语言课程——考研考级专用(推荐)

    m0_62241485: 你好,请问可以再发一遍吗?

  • XDF赵海英老师C语言课程——考研考级专用(推荐)

    m0_72573020: 失效了,可以再发一遍不

  • XDF赵海英老师C语言课程——考研考级专用(推荐)

    m0_52464930: 还能补发吗

  • XDF赵海英老师C语言课程——考研考级专用(推荐)

    m0_73769852: 可以重发吗,求补

大家在看

  • SSM出租车管理系统6v0lz 处罚奖赏 投诉等模块全方位服务
  • 如何使用InDraw画绚丽多彩的结构式
  • 国内自闭症学校大揭秘!了解治疗自闭症的最佳选择 159
  • 高手代做抖音图文发灰色词排名优势
  • 前端开发者必学:mo.js动画库 496

最新文章

  • 编程题目1
  • 云原生基础(一)
  • JVM底层知识
2021年8篇
2020年35篇
2019年35篇
2018年29篇

目录

目录

评论 37
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值

天下网标王网站排名提升优化网站优化干什么好新手网站如何优化山西临汾网站优化排名网站运营和优化论文网站标题seo优化新乡网站优化代理网站优化外包优选云速捷怀宁网站优化收费情况深圳国内网站优化公司学院网站SEO优化的建议温州泰顺网站优化福田怎么样进行网站优化方式网站如何提高seo优化东湖独立网站优化网站搜索优化先询火25星神农架seo网站优化合作网站优化推广方法上饶网络推广网站优化徐汇区专业网站优化价格服装网站优化关键词沙井网站关键词优化价格成都网站制作优化服务中山外贸网站优化流程网站结构的优化指标郑州怎么seo优化网站网站网络营销的优化服务崇州网站优化定做常州网站优化快速排名宁夏银川市网站优化哪家不错香港通过《维护国家安全条例》两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”19岁小伙救下5人后溺亡 多方发声卫健委通报少年有偿捐血浆16次猝死汪小菲曝离婚始末何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言男子被猫抓伤后确诊“猫抓病”周杰伦一审败诉网易中国拥有亿元资产的家庭达13.3万户315晚会后胖东来又人满为患了高校汽车撞人致3死16伤 司机系学生张家界的山上“长”满了韩国人?张立群任西安交通大学校长手机成瘾是影响睡眠质量重要因素网友洛杉矶偶遇贾玲“重生之我在北大当嫡校长”单亲妈妈陷入热恋 14岁儿子报警倪萍分享减重40斤方法杨倩无缘巴黎奥运考生莫言也上北大硕士复试名单了许家印被限制高消费奥巴马现身唐宁街 黑色着装引猜测专访95后高颜值猪保姆男孩8年未见母亲被告知被遗忘七年后宇文玥被薅头发捞上岸郑州一火锅店爆改成麻辣烫店西双版纳热带植物园回应蜉蝣大爆发沉迷短剧的人就像掉进了杀猪盘当地回应沈阳致3死车祸车主疑毒驾开除党籍5年后 原水城县长再被查凯特王妃现身!外出购物视频曝光初中生遭15人围殴自卫刺伤3人判无罪事业单位女子向同事水杯投不明物质男子被流浪猫绊倒 投喂者赔24万外国人感慨凌晨的中国很安全路边卖淀粉肠阿姨主动出示声明书胖东来员工每周单休无小长假王树国卸任西安交大校长 师生送别小米汽车超级工厂正式揭幕黑马情侣提车了妈妈回应孩子在校撞护栏坠楼校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变老人退休金被冒领16年 金额超20万西藏招商引资投资者子女可当地高考特朗普无法缴纳4.54亿美元罚金浙江一高校内汽车冲撞行人 多人受伤

天下网标王 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化