Educoder/头歌JAVA——Java Web:基于JSP的网上商城

目录

一、商品列表

本关任务

具体要求

结果输出

实现代码

二、商品详情

本关任务

JDBC查询方法封装

商品相关信息介绍

具体要求

结果输出

实现代码

三、商品搜索

编程要求

测试说明

实现代码

四、购物车列表

本关任务

JDBC查询方法封装

购物车相关信息介绍

编程要求

测试说明

实现代码

五、购物车操作

本关任务

JDBC查询方法封装

购物车相关信息介绍

编程要求

实现代码

六、下单

本关任务

编程要求

实现代码

七、订单查询

本关任务

编程要求

测试说明

实现代码


一、商品列表

本关任务

一个商场不能缺少商品,本关需要借助JDBC,从 t_goods表中获取销量前四的商品信息,并展示到页面。

JDBC信息;

MYSQL用户名MYSQL密码驱动URL
root123123com.mysql.jdbc.Driverjdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true

com.educoder.entity.Goods字段及方法;

字段描述类型get方法set方法
goodsId商品IdStringgetGoodsId()setGoodsId(String goodsId)
goodsName商品名StringgetGoodsName()setGoodsName(String goodsName)
goodsImg展示于主页的图StringgetGoodsImg() setGoodsImg(String goodsImg)
goodsPrice价格BigDecimalgetGoodsPrice()setGoodsPrice(BigDecimal goodsPrice)
goodsNum库存数量IntegergetGoodsNum()setGoodsNum(Integer goodsNum)
salesNum销售数量IntegergetSalesNum()setSalesNum(Integer salesNum)
goodsSize商品规格StringgetGoodsSize()setGoodsSize(String goodsSize)
goodsFrom商品产地StringgetGoodsFrom()setGoodsFrom(String goodsFrom)
goodsTime保质期StringgetGoodsTime()setGoodsTime(String goodsTime)
goodsSaveCondition存储条件StringgetGoodsSaveCondition()setGoodsSaveCondition(String goodsSaveCondition)
goodsDescribe商品描述介绍StringgetGoodsDescribe()setGoodsDescribe(String goodsDescribe)
goodsExplain对商品简短说明StringgetGoodsExplain()setGoodsExplain(String goodsExplain)
goodsClass所属类别StringgetGoodsClass()setGoodsClass(String goodsClass)
goodsDiscount折扣BigDecimalgetGoodsDiscount()setGoodsDiscount(BigDecimal goodsDiscount)
discountStartTime优惠起始时间DategetDiscountStartTime()setDiscountStartTime(Date discountStartTime)
discountEndTime优惠截止时间DategetDiscountEndTime()setDiscountEndTime(Date discountEndTime)

表和类对应表;

库名表名类名
online_shopt_goodsGoods
  1. 注意:类字段和对应的表字段名称一致,这里不再重复列出了。

页面初始效果图:

最终页面效果图:

具体要求

  • 补全 getGoodsList()方法,返回List<Goods>(商品列表)。

结果输出

[{"goodsClass":"甜品","goodsDescribe":"口感绵密,精致细腻\r\n这份雪白让你有如获至宝的幸福感","goodsExplain":"手工打发而成的进口鲜奶油","goodsFrom":"上海","goodsId":"list1","goodsImg":"list_1-1.jpg","goodsName":"雪域牛乳芝士","goodsNum":996,"goodsPrice":98.00,"goodsSaveCondition":"冷藏0~4摄氏度","goodsSize":"约450g","goodsTime":"3天","salesNum":44},{"goodsClass":"甜品","goodsDescribe":"酸甜清爽\r\n回味无穷","goodsExplain":"卡福洛芒果泥","goodsFrom":"上海","goodsId":"list3","goodsImg":"list_3-1.jpg","goodsName":"芒果熔岩星球蛋糕 Mango Planet","goodsNum":1994,"goodsPrice":118.00,"goodsSaveCondition":"冷藏0~4摄氏度","goodsSize":"约680g","goodsTime":"2天","salesNum":42},{"goodsClass":"甜品","goodsDescribe":"通过精致的工艺\r\n将巧克力的香醇甜蜜发挥到极致\r\n每一口都倍感甜蜜","goodsExplain":"进口的黑巧克力","goodsFrom":"上海","goodsId":"list2","goodsImg":"list_2-1.jpg","goodsName":"哈!蜜瓜蛋糕 Hey Melon","goodsNum":1496,"goodsPrice":99.00,"goodsSaveCondition":"冷藏0~4摄氏度","goodsSize":"约500g","goodsTime":"3天","salesNum":39},{"goodsClass":"甜品","goodsDescribe":"在金色芒果淋面的外衣下\r\n是芒果慕斯的柔情\r\n是芒果啫喱的牵挂\r\n还有丝丝香草戚风蛋糕的香气","goodsExplain":"手工打发而成的进口鲜奶油","goodsFrom":"上海","goodsId":"list5","goodsImg":"list_5-1.jpg","goodsName":"蟹蟹你偷吃 Yum Yum Cake","goodsNum":6999,"goodsPrice":88.00,"goodsSaveCondition":"冷藏0~4摄氏度","goodsSize":"约480g","goodsTime":"3天","salesNum":5}]

实现代码

package com.educoder.service.impl;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    import com.educoder.entity.Goods;
    import com.educoder.service.GoodsService;
    import com.educoder.dao.impl.BaseDao;
    public class GoodsServiceImpl implements GoodsService {
        /**
         * 商品详情接口
         */
        public Goods getGoodsByGoodsId(String goodsId) {
            /********* Begin *********/
             String sql = "select * from t_goods where goodsId = ?";
            List<Object> parameters = new ArrayList<Object>();
            parameters.add(goodsId);
            List<Goods> goodsList = null;
            try {
                goodsList = BaseDao.operQuery(sql, parameters, Goods.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return goodsList.size() == 0 ? null : goodsList.get(0);
            /********* End *********/
        }
        /**
         * 商品搜索接口
         */
        public List<Goods> searchGoods(String condition) {
             /********* Begin *********/
            String sql = "select * from t_goods where goodsName like ? or goodsClass like ? order by salesNum desc";
            List<Goods> goodsList = null;
            condition = "%" + condition + "%";
            List<Object> paramenter = new ArrayList<Object>();
            paramenter.add(condition);
            paramenter.add(condition);
            try {
                goodsList = BaseDao.operQuery(sql, paramenter, Goods.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return goodsList;
            /********* End *********/
        }
        /**
         * 商品列表接口
         */
        public List<Goods> getGoodsList() {
            /********* Begin *********/
            String USERNAME = "root";
            String PASSWORD = "123123";
            String URL = "jdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true";
            Connection conn = null;
            PreparedStatement pste = null;
            ResultSet executeQuery = null;
            List<Goods> list = new ArrayList<Goods>();
            String sql = "select * from t_goods order by salesNum desc limit 4";
            try {
                conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
                pste = conn.prepareStatement(sql);
                executeQuery = pste.executeQuery();
                while (executeQuery.next()) {
                    Goods goods = new Goods();
                    goods.setGoodsId(executeQuery.getString("goodsId"));
                    goods.setGoodsName(executeQuery.getString("goodsName"));
                    goods.setGoodsImg(executeQuery.getString("goodsImg"));
                    goods.setGoodsPrice(executeQuery.getBigDecimal("goodsPrice"));
                    goods.setGoodsNum(executeQuery.getInt("goodsNum"));
                    goods.setSalesNum(executeQuery.getInt("salesNum"));
                    goods.setGoodsSize(executeQuery.getString("goodsSize"));
                    goods.setGoodsFrom(executeQuery.getString("goodsFrom"));
                    goods.setGoodsTime(executeQuery.getString("goodsTime"));
                    goods.setGoodsSaveCondition(executeQuery.getString("goodsSaveCondition"));
                    goods.setGoodsDescribe(executeQuery.getString("goodsDescribe"));
                    goods.setGoodsExplain(executeQuery.getString("goodsExplain"));
                    goods.setGoodsClass(executeQuery.getString("goodsClass"));
                    goods.setGoodsDiscount(executeQuery.getBigDecimal("goodsDiscount"));
                    goods.setDiscountStartTime(executeQuery.getDate("discountStartTime"));
                    goods.setDiscountEndTime(executeQuery.getDate("discountEndTime"));
                    list.add(goods);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                try {
                    if (executeQuery != null)
                        executeQuery.close();
                    if (pste != null)
                        pste.close();
                    if (conn != null)
                        conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            return list;
            /********* End *********/
        }
    }

二、商品详情

本关任务

有了商品还需要看商品的详细信息,本关需要借助JDBC,通过参数商品Id从数据库中获取商品详情,展示到页面。为了完成本关任务,需要了解:

  • JDBC 查询方法封装;
  • 商品相关信息介绍

JDBC查询方法封装

为了方便JDBC操作,平台对JDBC查询方法进行了封装,封装类com.educoder.dao.impl.BaseDao

public static <T> List<T> operQuery(String sql, List<Object> p, Class<T> cls)
            throws Exception {
        Connection conn = null;
        PreparedStatement pste = null;
        ResultSet rs = null;
        List<T> list = new ArrayList<T>();
        conn = getConn();
        try {
            pste = conn.prepareStatement(sql);
            if (p != null) {
                for (int i = 0; i < p.size(); i++) {
                    pste.setObject(i + 1, p.get(i));
                }
            }
            
            rs = pste.executeQuery();
            ResultSetMetaData rsmd = rs.getMetaData();
            while (rs.next()) {
                T entity = cls.newInstance();
                for (int j = 0; j < rsmd.getColumnCount(); j++) {
                    String col_name = rsmd.getColumnName(j + 1);
                    Object value = rs.getObject(col_name);
                    Field field = cls.getDeclaredField(col_name);
                    field.setAccessible(true);
                    field.set(entity, value);
                }
                list.add(entity);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            releaseAll(rs, pste, conn);
        }
        return list;
    }

例如,第一关可以使用如下方法,获取商品列表:

String sql = "select * from t_goods order by salesNum desc limit 4";
        List<Goods> goodsList = null;
        try {
            goodsList = BaseDao.operQuery(sql, null, Goods.class);
        } catch (Exception e) {
            e.printStackTrace();
        }

商品相关信息介绍

MYSQL用户名MYSQL密码驱动URL
root123123com.mysql.jdbc.Driverjdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true

com.educoder.entity.Goods字段及方法;

字段描述类型get方法set方法
goodsId商品IdStringgetGoodsId()setGoodsId(String goodsId)
goodsName商品名StringgetGoodsName()setGoodsName(String goodsName)
goodsImg展示于主页的图StringgetGoodsImg() setGoodsImg(String goodsImg)
goodsPrice价格BigDecimalgetGoodsPrice()setGoodsPrice(BigDecimal goodsPrice)
goodsNum库存数量IntegergetGoodsNum()setGoodsNum(Integer goodsNum)
salesNum销售数量IntegergetSalesNum()setSalesNum(Integer salesNum)
goodsSize商品规格StringgetGoodsSize()setGoodsSize(String goodsSize)
goodsFrom商品产地StringgetGoodsFrom()setGoodsFrom(String goodsFrom)
goodsTime保质期StringgetGoodsTime()setGoodsTime(String goodsTime)
goodsSaveCondition存储条件StringgetGoodsSaveCondition()setGoodsSaveCondition(String goodsSaveCondition)
goodsDescribe商品描述介绍StringgetGoodsDescribe()setGoodsDescribe(String goodsDescribe)
goodsExplain对商品简短说明StringgetGoodsExplain()setGoodsExplain(String goodsExplain)
goodsClass所属类别StringgetGoodsClass()setGoodsClass(String goodsClass)
goodsDiscount折扣BigDecimalgetGoodsDiscount()setGoodsDiscount(BigDecimal goodsDiscount)
discountStartTime优惠起始时间DategetDiscountStartTime()setDiscountStartTime(Date discountStartTime)
discountEndTime优惠截止时间DategetDiscountEndTime()setDiscountEndTime(Date discountEndTime)

表和类对应表;

库名表名类名
online_shopt_goodsGoods
  1. 注意:类字段和对应的表字段名称一致,这里不再重复列出了。

页面初始效果图:

最终页面效果图:

具体要求

  • 补全getGoodsByGoodsId()方法,完成查询商品详情的任务,最后返回Goods(商品)。

结果输出

{"goodsClass":"甜品","goodsDescribe":"口感绵密,精致细腻\r\n这份雪白让你有如获至宝的幸福感","goodsExplain":"手工打发而成的进口鲜奶油","goodsFrom":"上海","goodsId":"list1","goodsImg":"list_1-1.jpg","goodsName":"雪域牛乳芝士","goodsNum":996,"goodsPrice":98.00,"goodsSaveCondition":"冷藏0~4摄氏度","goodsSize":"约450g","goodsTime":"3天","salesNum":44}

实现代码

package com.educoder.service.impl;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    import com.educoder.entity.Goods;
    import com.educoder.service.GoodsService;
    import com.educoder.dao.impl.BaseDao;
    public class GoodsServiceImpl implements GoodsService {
        /**
         * 商品详情接口
         */
        public Goods getGoodsByGoodsId(String goodsId) {
            /********* Begin *********/
             String sql = "select * from t_goods where goodsId = ?";
            List<Object> parameters = new ArrayList<Object>();
            parameters.add(goodsId);
            List<Goods> goodsList = null;
            try {
                goodsList = BaseDao.operQuery(sql, parameters, Goods.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return goodsList.size() == 0 ? null : goodsList.get(0);
            /********* End *********/
        }
        /**
         * 商品搜索接口
         */
        public List<Goods> searchGoods(String condition) {
             /********* Begin *********/
            String sql = "select * from t_goods where goodsName like ? or goodsClass like ? order by salesNum desc";
            List<Goods> goodsList = null;
            condition = "%" + condition + "%";
            List<Object> paramenter = new ArrayList<Object>();
            paramenter.add(condition);
            paramenter.add(condition);
            try {
                goodsList = BaseDao.operQuery(sql, paramenter, Goods.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return goodsList;
            /********* End *********/
        }
        /**
         * 商品列表接口
         */
        public List<Goods> getGoodsList() {
            /********* Begin *********/
            String USERNAME = "root";
            String PASSWORD = "123123";
            String URL = "jdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true";
            Connection conn = null;
            PreparedStatement pste = null;
            ResultSet executeQuery = null;
            List<Goods> list = new ArrayList<Goods>();
            String sql = "select * from t_goods order by salesNum desc limit 4";
            try {
                conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
                pste = conn.prepareStatement(sql);
                executeQuery = pste.executeQuery();
                while (executeQuery.next()) {
                    Goods goods = new Goods();
                    goods.setGoodsId(executeQuery.getString("goodsId"));
                    goods.setGoodsName(executeQuery.getString("goodsName"));
                    goods.setGoodsImg(executeQuery.getString("goodsImg"));
                    goods.setGoodsPrice(executeQuery.getBigDecimal("goodsPrice"));
                    goods.setGoodsNum(executeQuery.getInt("goodsNum"));
                    goods.setSalesNum(executeQuery.getInt("salesNum"));
                    goods.setGoodsSize(executeQuery.getString("goodsSize"));
                    goods.setGoodsFrom(executeQuery.getString("goodsFrom"));
                    goods.setGoodsTime(executeQuery.getString("goodsTime"));
                    goods.setGoodsSaveCondition(executeQuery.getString("goodsSaveCondition"));
                    goods.setGoodsDescribe(executeQuery.getString("goodsDescribe"));
                    goods.setGoodsExplain(executeQuery.getString("goodsExplain"));
                    goods.setGoodsClass(executeQuery.getString("goodsClass"));
                    goods.setGoodsDiscount(executeQuery.getBigDecimal("goodsDiscount"));
                    goods.setDiscountStartTime(executeQuery.getDate("discountStartTime"));
                    goods.setDiscountEndTime(executeQuery.getDate("discountEndTime"));
                    list.add(goods);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                try {
                    if (executeQuery != null)
                        executeQuery.close();
                    if (pste != null)
                        pste.close();
                    if (conn != null)
                        conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            return list;
            /********* End *********/
        }
    }

三、商品搜索

编程要求

请仔细阅读右侧代码,在Begin-End区域内进行代码补充,实现商品搜索的功能,具体需求如下:

  • 补全searchGoods()方法,完成商品搜索的功能,最后返回List<Goods>(商品列表)。

测试说明

平台会对你编写的代码进行测试:

测试输入:雪域牛

预期输出:

[{"goodsClass":"甜品","goodsDescribe":"口感绵密,精致细腻\r\n这份雪白让你有如获至宝的幸福感","goodsExplain":"手工打发而成的进口鲜奶油","goodsFrom":"上海","goodsId":"list1","goodsImg":"list_1-1.jpg","goodsName":"雪域牛乳芝士","goodsNum":996,"goodsPrice":98.00,"goodsSaveCondition":"冷藏0~4摄氏度","goodsSize":"约450g","goodsTime":"3天","salesNum":44}]

实现代码

package com.educoder.service.impl;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    import com.educoder.entity.Goods;
    import com.educoder.service.GoodsService;
    import com.educoder.dao.impl.BaseDao;
    public class GoodsServiceImpl implements GoodsService {
        /**
         * 商品详情接口
         */
        public Goods getGoodsByGoodsId(String goodsId) {
            /********* Begin *********/
             String sql = "select * from t_goods where goodsId = ?";
            List<Object> parameters = new ArrayList<Object>();
            parameters.add(goodsId);
            List<Goods> goodsList = null;
            try {
                goodsList = BaseDao.operQuery(sql, parameters, Goods.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return goodsList.size() == 0 ? null : goodsList.get(0);
            /********* End *********/
        }
        /**
         * 商品搜索接口
         */
        public List<Goods> searchGoods(String condition) {
             /********* Begin *********/
            String sql = "select * from t_goods where goodsName like ? or goodsClass like ? order by salesNum desc";
            List<Goods> goodsList = null;
            condition = "%" + condition + "%";
            List<Object> paramenter = new ArrayList<Object>();
            paramenter.add(condition);
            paramenter.add(condition);
            try {
                goodsList = BaseDao.operQuery(sql, paramenter, Goods.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return goodsList;
            /********* End *********/
        }
        /**
         * 商品列表接口
         */
        public List<Goods> getGoodsList() {
            /********* Begin *********/
            String USERNAME = "root";
            String PASSWORD = "123123";
            String URL = "jdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true";
            Connection conn = null;
            PreparedStatement pste = null;
            ResultSet executeQuery = null;
            List<Goods> list = new ArrayList<Goods>();
            String sql = "select * from t_goods order by salesNum desc limit 4";
            try {
                conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
                pste = conn.prepareStatement(sql);
                executeQuery = pste.executeQuery();
                while (executeQuery.next()) {
                    Goods goods = new Goods();
                    goods.setGoodsId(executeQuery.getString("goodsId"));
                    goods.setGoodsName(executeQuery.getString("goodsName"));
                    goods.setGoodsImg(executeQuery.getString("goodsImg"));
                    goods.setGoodsPrice(executeQuery.getBigDecimal("goodsPrice"));
                    goods.setGoodsNum(executeQuery.getInt("goodsNum"));
                    goods.setSalesNum(executeQuery.getInt("salesNum"));
                    goods.setGoodsSize(executeQuery.getString("goodsSize"));
                    goods.setGoodsFrom(executeQuery.getString("goodsFrom"));
                    goods.setGoodsTime(executeQuery.getString("goodsTime"));
                    goods.setGoodsSaveCondition(executeQuery.getString("goodsSaveCondition"));
                    goods.setGoodsDescribe(executeQuery.getString("goodsDescribe"));
                    goods.setGoodsExplain(executeQuery.getString("goodsExplain"));
                    goods.setGoodsClass(executeQuery.getString("goodsClass"));
                    goods.setGoodsDiscount(executeQuery.getBigDecimal("goodsDiscount"));
                    goods.setDiscountStartTime(executeQuery.getDate("discountStartTime"));
                    goods.setDiscountEndTime(executeQuery.getDate("discountEndTime"));
                    list.add(goods);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                try {
                    if (executeQuery != null)
                        executeQuery.close();
                    if (pste != null)
                        pste.close();
                    if (conn != null)
                        conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            return list;
            /********* End *********/
        }
    }

四、购物车列表

本关任务

网上看中的商品,暂时不买,还需要保存起来,这个需要通过购物车来实现。本关需要从session里获取属性名为userUser对象,并借助JDBC,通过表t_cartt_goods获取用户购物车的商品内容,并展示到页面。

为了完成本关任务,需要了解:

  • JDBC查询方法封装;

  • 购物车相关信息介绍。

JDBC查询方法封装

为了方便JDBC操作,平台对JDBC查询方法进行了封装,封装类com.educoder.dao.impl.BaseDao

public static <T> List<T> operQuery(String sql, List<Object> p, Class<T> cls)
            throws Exception {
        Connection conn = null;
        PreparedStatement pste = null;
        ResultSet rs = null;
        List<T> list = new ArrayList<T>();
        conn = getConn();
        try {
            pste = conn.prepareStatement(sql);
            if (p != null) {
                for (int i = 0; i < p.size(); i++) {
                    pste.setObject(i + 1, p.get(i));
                }
            }
            
            rs = pste.executeQuery();
            ResultSetMetaData rsmd = rs.getMetaData();
            while (rs.next()) {
                T entity = cls.newInstance();
                for (int j = 0; j < rsmd.getColumnCount(); j++) {
                    String col_name = rsmd.getColumnName(j + 1);
                    Object value = rs.getObject(col_name);
                    Field field = cls.getDeclaredField(col_name);
                    field.setAccessible(true);
                    field.set(entity, value);
                }
                list.add(entity);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            releaseAll(rs, pste, conn);
        }
        return list;
    }

例如,第一关可以使用如下方法,获取商品列表:

  1. String sql = "select * from t_goods order by salesNum desc limit 4";
  2. List<Goods> goodsList = null;
  3. try {
  4. goodsList = BaseDao.operQuery(sql, null, Goods.class);
  5. } catch (Exception e) {
  6. e.printStackTrace();
  7. }

购物车相关信息介绍

MYSQL用户名MYSQL密码驱动URL
root123123com.mysql.jdbc.Driverjdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true

com.educoder.entity.Goods字段及方法;

字段描述类型get方法set方法
goodsId商品IdStringgetGoodsId()setGoodsId(String goodsId)
goodsName商品名StringgetGoodsName()setGoodsName(String goodsName)
goodsImg展示于主页的图StringgetGoodsImg() setGoodsImg(String goodsImg)
goodsPrice价格BigDecimalgetGoodsPrice()setGoodsPrice(BigDecimal goodsPrice)
goodsNum库存数量IntegergetGoodsNum()setGoodsNum(Integer goodsNum)
salesNum销售数量IntegergetSalesNum()setSalesNum(Integer salesNum)
goodsSize商品规格StringgetGoodsSize()setGoodsSize(String goodsSize)
goodsFrom商品产地StringgetGoodsFrom()setGoodsFrom(String goodsFrom)
goodsTime保质期StringgetGoodsTime()setGoodsTime(String goodsTime)
goodsSaveCondition存储条件StringgetGoodsSaveCondition()setGoodsSaveCondition(String goodsSaveCondition)
goodsDescribe商品描述介绍StringgetGoodsDescribe()setGoodsDescribe(String goodsDescribe)
goodsExplain对商品简短说明StringgetGoodsExplain()setGoodsExplain(String goodsExplain)
goodsClass所属类别StringgetGoodsClass()setGoodsClass(String goodsClass)
goodsDiscount折扣BigDecimalgetGoodsDiscount()setGoodsDiscount(BigDecimal goodsDiscount)
discountStartTime优惠起始时间DategetDiscountStartTime()setDiscountStartTime(Date discountStartTime)
discountEndTime优惠截止时间DategetDiscountEndTime()setDiscountEndTime(Date discountEndTime)

注意:Cart类冗余信息是通过和t_goods表关联查询出来的,不是存在下面的t_cart表里。

表和类对应表;

库名表名类名
online_shopt_cartCart

注意:类字段和对应的表字段名称一致,这里不再重复列出了。

页面初始效果图:

最终页面效果图:

编程要求

根据提示,在右侧编辑器补充getGoodsByUserId方法代码,并返回Cart列表。

注意:后续关卡都是需要从request获取用户信息,从而获得userId。在本关卡获取成功后,后续关卡默认已经获取到userId,并当成接口参数传入,不再需要重复获取。

测试说明

平台会对你编写的代码进行测试:

预期输出:

[{"addTime":1543505629000,"buyNum":1,"cartId":101,"goodsClass":"甜品","goodsDescribe":"酸甜清爽\r\n回味无穷","goodsExplain":"卡福洛芒果泥","goodsFrom":"上海","goodsId":"list3","goodsImg":"list_3-1.jpg","goodsName":"芒果熔岩星球蛋糕 Mango Planet","goodsNum":1994,"goodsPrice":118.00,"goodsSaveCondition":"冷藏0~4摄氏度","goodsSize":"约680g","goodsTime":"2天","salesNum":42,"userId":"123456"},{"addTime":1543505631000,"buyNum":1,"cartId":102,"discountEndTime":1499184679000,"discountStartTime":1498923465000,"goodsClass":"甜品","goodsDescribe":"芝士与香草戚风被雪域奶油的浪漫笼罩\r\n每一口都充满快乐的滋味","goodsDiscount":0.75,"goodsExplain":"选用进口白巧克力","goodsFrom":"上海","goodsId":"list6","goodsImg":"list_6-1.jpg","goodsName":"美刀刀蛋糕 Ms. Golden","goodsNum":3000,"goodsPrice":99.00,"goodsSaveCondition":"冷藏0~4摄氏度","goodsSize":"约700g","goodsTime":"3天","salesNum":5,"userId":"123456"}]

实现代码

package com.educoder.service.impl;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import javax.servlet.http.HttpServletRequest;
    import com.educoder.dao.impl.BaseDao;
    import com.educoder.entity.Cart;
    import com.educoder.entity.User;
    import com.educoder.service.CartService;
    public class CartServiceImpl implements CartService {
        // 查询购物车列表
        public List<Cart> getGoodsByUserId(HttpServletRequest request) {
            /********* Begin *********/
            User user = (User)request.getSession().getAttribute("user");
            String userId = user.getUserId();
            String sql = "select * from t_cart as a, t_goods as b where a.goodsId = b.goodsId and a.userId = ?";
            List<Cart> cartList = null;
            List<Object> parameters = new ArrayList<Object>();
            parameters.add(userId);
            try {
                cartList = BaseDao.operQuery(sql, parameters, Cart.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return cartList;
            /********* End *********/
        }
        // 购物车操作接口
        @Override
        public void doCartHandle(String userId, String goodsId, String buyNum, String oper) {
            /********* Begin *********/
            String deletesql = "delete from t_cart where userId=? and goodsId=?";
            String querysql = "select * from t_cart where userId = ? and goodsId = ?";
            String updatesql = "update t_cart set buyNum=? where userId=? and goodsId=?";
            String addsql = "insert into t_cart(userId, goodsId, buyNum, addTime) values(?, ?, ?, ?)";
            List<Object> parameters = new ArrayList<Object>();
            //删除
            if(buyNum == null) {
                parameters.add(userId);
                parameters.add(goodsId);
                BaseDao.operUpdate(deletesql, parameters);
            }
            else{
                //进行修改和添加
                List<Cart> goodsList = null;
                parameters.add(userId);
                parameters.add(goodsId);
                try {
                    goodsList = BaseDao.operQuery(querysql, parameters, Cart.class);
                    parameters.clear();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //进行添加
                if(goodsList.isEmpty()) {
                    parameters.add(userId);
                    parameters.add(goodsId);
                    parameters.add(buyNum);
                    parameters.add(new Date());
                    BaseDao.operUpdate(addsql, parameters);
                }
                else {
                    //进行修改
                    if(oper != null) {
                        buyNum += goodsList.get(0).getBuyNum();
                        parameters.add(buyNum);
                        parameters.add(userId);
                        parameters.add(goodsId);
                        BaseDao.operUpdate(updatesql, parameters);
                    }
                }
            }
            /********* End *********/
        }
    }

五、购物车操作

本关任务

为了能进行购物车的修改、添加、删除操作,本关需要借助JDBC,对数据库表t_cartt_goods表进行操作。

为了完成本关任务,需要了解:

  • JDBC更新方法封装;

  • 购物车相关信息介绍。

JDBC查询方法封装

为了方便JDBC操作,平台进行的JDBC更新方法进行了封装,封装类com.educoder.dao.impl.BaseDao

public static boolean operUpdate(String sql, List<Object> p) {
        Connection conn = null;
        PreparedStatement pste = null;
        int res = 0;
        conn = getConn();
        try {
            pste = conn.prepareStatement(sql);
            if (p != null) {
                for (int i = 0; i < p.size(); i++) {
                    pste.setObject(i + 1, p.get(i));
                }
            }
            res = pste.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            releaseAll(null, pste, conn);
        }
        return res > 0;//
    }

购物车相关信息介绍

MYSQL用户名MYSQL密码驱动URL
root123123com.mysql.jdbc.Driverjdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true

com.educoder.entity.Goods字段及方法;

字段描述类型get方法set方法
goodsId商品IdStringgetGoodsId()setGoodsId(String goodsId)
goodsName商品名StringgetGoodsName()setGoodsName(String goodsName)
goodsImg展示于主页的图StringgetGoodsImg() setGoodsImg(String goodsImg)
goodsPrice价格BigDecimalgetGoodsPrice()setGoodsPrice(BigDecimal goodsPrice)
goodsNum库存数量IntegergetGoodsNum()setGoodsNum(Integer goodsNum)
salesNum销售数量IntegergetSalesNum()setSalesNum(Integer salesNum)
goodsSize商品规格StringgetGoodsSize()setGoodsSize(String goodsSize)
goodsFrom商品产地StringgetGoodsFrom()setGoodsFrom(String goodsFrom)
goodsTime保质期StringgetGoodsTime()setGoodsTime(String goodsTime)
goodsSaveCondition存储条件StringgetGoodsSaveCondition()setGoodsSaveCondition(String goodsSaveCondition)
goodsDescribe商品描述介绍StringgetGoodsDescribe()setGoodsDescribe(String goodsDescribe)
goodsExplain对商品简短说明StringgetGoodsExplain()setGoodsExplain(String goodsExplain)
goodsClass所属类别StringgetGoodsClass()setGoodsClass(String goodsClass)
goodsDiscount折扣BigDecimalgetGoodsDiscount()setGoodsDiscount(BigDecimal goodsDiscount)
discountStartTime优惠起始时间DategetDiscountStartTime()setDiscountStartTime(Date discountStartTime)
discountEndTime优惠截止时间DategetDiscountEndTime()setDiscountEndTime(Date discountEndTime)

注意:Cart类冗余信息是需要通过和t_goods表关联查询出来的,不会存在下面的t_cart表里。

表和类对应表;

库名表名类名
online_shopt_cartCart

注意:类字段和对应的表字段名称一致,这里不再重复列出了。

编程要求

根据提示,在右侧编辑器补充doCartHandle方法代码。

接口请求参数说明:

  • userId 用户Id

  • goodsId 商品Id

  • buyNum 添加或修改数量,当为null,表示删除;

  • oper 如果存在,添加buyNum;如果不存在,修改为buyNum

测试输入:123456 list2 1 2

预期输出:插入成功 userId:123456 goodsId:list2 buyNum:1 oper:2

实现代码

package com.educoder.service.impl;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import javax.servlet.http.HttpServletRequest;
    import com.educoder.dao.impl.BaseDao;
    import com.educoder.entity.Cart;
    import com.educoder.entity.User;
    import com.educoder.service.CartService;
    public class CartServiceImpl implements CartService {
        // 查询购物车列表
        public List<Cart> getGoodsByUserId(HttpServletRequest request) {
            /********* Begin *********/
            User user = (User)request.getSession().getAttribute("user");
            String userId = user.getUserId();
            String sql = "select * from t_cart as a, t_goods as b where a.goodsId = b.goodsId and a.userId = ?";
            List<Cart> cartList = null;
            List<Object> parameters = new ArrayList<Object>();
            parameters.add(userId);
            try {
                cartList = BaseDao.operQuery(sql, parameters, Cart.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return cartList;
            /********* End *********/
        }
        // 购物车操作接口
        @Override
        public void doCartHandle(String userId, String goodsId, String buyNum, String oper) {
            /********* Begin *********/
            String deletesql = "delete from t_cart where userId=? and goodsId=?";
            String querysql = "select * from t_cart where userId = ? and goodsId = ?";
            String updatesql = "update t_cart set buyNum=? where userId=? and goodsId=?";
            String addsql = "insert into t_cart(userId, goodsId, buyNum, addTime) values(?, ?, ?, ?)";
            List<Object> parameters = new ArrayList<Object>();
            //删除
            if(buyNum == null) {
                parameters.add(userId);
                parameters.add(goodsId);
                BaseDao.operUpdate(deletesql, parameters);
            }
            else{
                //进行修改和添加
                List<Cart> goodsList = null;
                parameters.add(userId);
                parameters.add(goodsId);
                try {
                    goodsList = BaseDao.operQuery(querysql, parameters, Cart.class);
                    parameters.clear();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //进行添加
                if(goodsList.isEmpty()) {
                    parameters.add(userId);
                    parameters.add(goodsId);
                    parameters.add(buyNum);
                    parameters.add(new Date());
                    BaseDao.operUpdate(addsql, parameters);
                }
                else {
                    //进行修改
                    if(oper != null) {
                        buyNum += goodsList.get(0).getBuyNum();
                        parameters.add(buyNum);
                        parameters.add(userId);
                        parameters.add(goodsId);
                        BaseDao.operUpdate(updatesql, parameters);
                    }
                }
            }
            /********* End *********/
        }
    }

六、下单

本关任务

上一关已经完成了购物车操作功能开发,现在我们就可以编写下单接口进行购买商品了,本关需要借助JDBC,在t_ordert_order_child表中存储用户订单信息。

下单相关信息介绍;

MYSQL用户名MYSQL密码驱动URL
root123123com.mysql.jdbc.Driverjdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true

com.educoder.entity.Order字段及方法;

字段描述类型get方法set方法
orderId订单编号StringgetOrderId()setOrderId(String orderId)
userId用户IdStringgetUserId()setUserId(String userId)
orderTime订单时间DategetOrderTime()setOrderTime(Date orderTime)
addressId订单地址StringgetAddressId()setAddressId()(String addressId)

com.educoder.entity.Order冗余信息字段及方法;

字段描述类型get方法set方法
goodsId商品IdStringgetGoodsId()setGoodsId(String goodsId)
goodsName商品名称StringgetGoodsName()setGoodsName(String goodsName)
goodsImg商品图片StringgetGoodsImg()setGoodsImg(String goodsImg)
goodsPrice下单价格BigDecimalgetGoodsPrice()setGoodsPrice(BigDecimal goodsPrice)

注意:Order类冗余信息是需要通过关联查询出来的,不会存在下面的t_order表里。

com.educoder.entity.OrderChildTable字段及方法;

字段描述类型get方法set方法
id订单商品主键IntegergetId()setId(Integer id)
orderId订单IdStringgetOrderId()setOrderId(String orderId)
goodsId商品IdStringgetGoodsId()setGoodsId(String goodsId)
buyNum购买数量IntegergetBuyNum()setBuyNum()(Integer buyNum)

表和类对应表;

库名表名类名
online_shopt_orderOrder
online_shopt_order_childOrderChildTable

注意:类字段和对应的表字段名称一致,这里不再重复列出了。

编程要求

在右侧编辑器补充submitOrder方法代码,并返回Order类。

接口请求参数说明:

  • userId 用户Id

  • addressId 地址Id

  • goodsBuyNum 数组,购物车选中的商品数量;

  • chooseGoodId 数组,购物车选中的商品Id

逻辑说明:

  1. 下单时orderId需要唯一,可以使用UUID

  2. 表分为t_order订单表和t_order_child订单子表,因为下单商品有可能多个;

  3. 在下单时,需要调用上一关的购物车操作接口,进行购物车数据清空。

测试输入:123456 d01e153c-fc1f-4326-9956-cbf9582a9df7 1,1 list3,list6

预期输出:

清空购物车成功
订单存储信息: userId:123456 addressId:d01e153c-fc1f-4326-9956-cbf9582a9df7
订单商品存储信息:[{"buyNum":1,"goodsId":"list3","id":53},{"buyNum":1,"goodsId":"list6","id":54}]

实现代码

package com.educoder.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import com.educoder.dao.impl.BaseDao;
import com.educoder.entity.Order;
import com.educoder.service.OrderService;
public class OrderServiceImpl implements OrderService {
     private CartServiceImpl catService = new CartServiceImpl();
    // 下单
    public Order submitOrder(String userId, String addressId, String[] goodsBuyNum,
            String[] chooseGoodId) {
        /********* Begin *********/
        Order order = new Order();
        String ordersql = "insert into t_order(orderId, userId, orderTime, addressId) values(?, ?, ?, ?)";
        String child_order_sql = "insert into t_order_child (orderId, goodsId, buyNum) values( ?, ?, ?) ";
        String orderId = UUID.randomUUID().toString();
        List<Object> parameters = new ArrayList<Object>();
        parameters.add(orderId);
        parameters.add(userId);
        parameters.add(new Date());
        parameters.add(addressId);
        BaseDao.operUpdate(ordersql, parameters);
        for(int n = 0 ; n < chooseGoodId.length; n++) {
            parameters.clear();
            parameters.add(orderId);
            parameters.add(chooseGoodId[n]);
            parameters.add(goodsBuyNum[n]);
            BaseDao.operUpdate(child_order_sql, parameters);
            //下单后,需要清空购物车
            catService.doCartHandle(userId, chooseGoodId[n], null, null);
        }
        //返回带有订单id的订单
        order.setOrderId(orderId);
        return order;
        /********* End *********/
    }
    // 订单查询
    public List<Order> getOrderByUserId(String userId) {
        /********* Begin *********/
        String sql = "select A.orderId, A.userId, B.userName, A.orderTime, C.address, E.goodsId, E.goodsName, D.buyNum, E.goodsPrice from " +
                "t_order as A, t_user as B, t_address as C, t_order_child as D, t_goods as E " +
                "where A.userId=? and A.orderId=D.orderId and A.userId=B.userId and A.addressId=C.addressId and D.goodsId=E.goodsId " +
                "order by orderTime desc";
        List<Object> parameters = new ArrayList<Object>();
        parameters.add(userId);
        List<Order> orderList = null;
        try {
            orderList = BaseDao.operQuery(sql, parameters, Order.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return orderList;
        /********* End *********/
    }
}

七、订单查询

本关任务

上一关已经完成下单接口,本关需要完成查询订单列表,本关需要借助JDBCt_ordert_usert_addresst_order_child表中查询订单信息。

订单查询相关信息介绍;

MYSQL用户名MYSQL密码驱动URL
root123123com.mysql.jdbc.Driverjdbc:mysql://127.0.0.1:3306/online_shop?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true

com.educoder.entity.Order字段及方法;

字段描述类型get方法set方法
orderId订单编号StringgetOrderId()setOrderId(String orderId)
userId用户IdStringgetUserId()setUserId(String userId)
orderTime订单时间DategetOrderTime()setOrderTime(Date orderTime)
addressId订单地址StringgetAddressId()setAddressId()(String addressId)

com.educoder.entity.Order冗余信息字段及方法;

字段描述类型get方法set方法
goodsId商品IdStringgetGoodsId()setGoodsId(String goodsId)
goodsName商品名称StringgetGoodsName()setGoodsName(String goodsName)
goodsImg商品图片StringgetGoodsImg()setGoodsImg(String goodsImg)
goodsPrice下单价格BigDecimalgetGoodsPricesetGoodsPrice(BigDecimal goodsPrice)

注意:Order类冗余信息是需要通过关联查询出来的,不会存在下面的t_order表里。

com.educoder.entity.OrderChildTable字段及方法;

字段描述类型get方法set方法
id订单商品主键IntegergetId()setId(Integer id)
orderId订单IdStringgetOrderId()setOrderId(String orderId)
goodsId商品IdStringgetGoodsId()setGoodsId(String goodsId)
buyNum购买数量IntegergetBuyNum()setBuyNum()(Integer buyNum)

com.educoder.entity.Address字段及方法;

字段描述类型get方法set方法
addressId地址IdStringgetAddressId()setAddressId(String addressId)
userId用户IdStringgetUserId()setUserId(String userId)
userName收货姓名StringgetUserName()setUserName(String userName)
userTel收货电话StringgetUserTel()setUserTel()(String addressId)
address收货地址StringgetAddress()setAddress()(String addressId)

表和类对应表;

库名表名类名
online_shopt_orderOrder
online_shopt_order_childOrderChildTable
online_shopt_addressAddress

注意:类字段和对应的表字段名称一致,这里不再重复列出了。

页面初始效果图:

最终页面效果图:

编程要求

在右侧编辑器补充getOrderByUserId方法代码,并返回Goods列表。

接口请求参数说明:

  • userId 用户Id

测试说明

测试输入:123456

预期输出:

[{"address":"测试地址","buyNum":1,"goodsId":"list1","goodsName":"雪域牛乳芝士","goodsPrice":98.00,"orderId":"ab25ca41-2230-4af1-81f7-6cfe8872d6b0","orderTime":1543220250000,"userId":"123456","userName":"test"},{“address":"测试地址","buyNum":1,"goodsId":"list2","goodsName":"哈!蜜瓜蛋糕 Hey Melon","goodsPrice":99.00,"orderId":"ab25ca41-2230-4af1-81f7-6cfe8872d6b0","orderTime":1543220250000,"userId":"123456","userName":"test"}]

实现代码

package com.educoder.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import com.educoder.dao.impl.BaseDao;
import com.educoder.entity.Order;
import com.educoder.service.OrderService;
public class OrderServiceImpl implements OrderService {
     private CartServiceImpl catService = new CartServiceImpl();
    // 下单
    public Order submitOrder(String userId, String addressId, String[] goodsBuyNum,
            String[] chooseGoodId) {
        /********* Begin *********/
        Order order = new Order();
        String ordersql = "insert into t_order(orderId, userId, orderTime, addressId) values(?, ?, ?, ?)";
        String child_order_sql = "insert into t_order_child (orderId, goodsId, buyNum) values( ?, ?, ?) ";
        String orderId = UUID.randomUUID().toString();
        List<Object> parameters = new ArrayList<Object>();
        parameters.add(orderId);
        parameters.add(userId);
        parameters.add(new Date());
        parameters.add(addressId);
        BaseDao.operUpdate(ordersql, parameters);
        for(int n = 0 ; n < chooseGoodId.length; n++) {
            parameters.clear();
            parameters.add(orderId);
            parameters.add(chooseGoodId[n]);
            parameters.add(goodsBuyNum[n]);
            BaseDao.operUpdate(child_order_sql, parameters);
            //下单后,需要清空购物车
            catService.doCartHandle(userId, chooseGoodId[n], null, null);
        }
        //返回带有订单id的订单
        order.setOrderId(orderId);
        return order;
        /********* End *********/
    }
    // 订单查询
    public List<Order> getOrderByUserId(String userId) {
        /********* Begin *********/
        String sql = "select A.orderId, A.userId, B.userName, A.orderTime, C.address, E.goodsId, E.goodsName, D.buyNum, E.goodsPrice from " +
                "t_order as A, t_user as B, t_address as C, t_order_child as D, t_goods as E " +
                "where A.userId=? and A.orderId=D.orderId and A.userId=B.userId and A.addressId=C.addressId and D.goodsId=E.goodsId " +
                "order by orderTime desc";
        List<Object> parameters = new ArrayList<Object>();
        parameters.add(userId);
        List<Order> orderList = null;
        try {
            orderList = BaseDao.operQuery(sql, parameters, Order.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return orderList;
        /********* End *********/
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/15473.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

WizardKM:Empowering Large Language Models to Follow Complex Instructions

WizardKM:Empowering Large Language Models to Follow Complex Instructions Introduction参考 Introduction 作者表明当前nlp社区的指令数据比较单一&#xff0c;大部分都是总结、翻译的任务&#xff0c;但是在真实场景中&#xff0c;人们有各式各样的需求&#xff0c;这限制…

程序员阿里三面无理由挂了,被HR一句话噎死,网友:这可是阿里啊

进入互联网大厂一般都是“过五关斩六将”&#xff0c;难度堪比西天取经&#xff0c;但当你真正面对这些大厂的面试时&#xff0c;有时候又会被其中的神操作弄的很是蒙圈。 近日&#xff0c;某位程序员发帖称&#xff0c;自己去阿里面试&#xff0c;三面都过了&#xff0c;却被…

CH32F203RCT6 pin2pin兼容STM32F103RCT6

32位大容量通用型Cortex-M3单片机 CH32F203是基于Cortex-M3内核设计的工业级大容量通用微控制器&#xff0c;此系列主频高达144MHz&#xff0c;独立了GPIO电压&#xff08;与系统供电分离&#xff09;。资源同比增加了随机数单元&#xff0c;4组运放比较器&#xff1b;提高串口…

Python进阶项目--只因博客(bootstrap+flask+mysql)

前言 1.全民制作人们大家好&#xff0c;我是练习时长两年半的个人练习生只因坤坤&#xff0c; 喜欢唱&#xff0c;跳&#xff0c;rap&#xff0c;篮球&#xff0c;music...... 在今后的节目中&#xff0c;我还准备了很多我自己作词、作曲、编舞的原创作品&#xff0c; 期待的话…

Docker compose 制作 LNMP 镜像

目录 第一章.Nginx镜像 1.1安装环境部署 1.2.nginx镜像容器的配置 第二章.php镜像的安装部署 2.1.文件配置 第三章.mysql镜像的安装部署 3.1.文件配置 第四章.配置网页 4.1.进入容器mysql 4.2.浏览器访问&#xff1a; 第一章.Nginx镜像 1.1安装环境部署 systemctl s…

亚科转债,鹿山转债上市价格预测

亚科转债 基本信息 转债名称&#xff1a;亚科转债&#xff0c;评级&#xff1a;AA&#xff0c;发行规模&#xff1a;11.59亿元。 正股名称&#xff1a;亚太科技&#xff0c;今日收盘价&#xff1a;5.58元&#xff0c;转股价格&#xff1a;6.46元。 当前转股价值 转债面值 / 转…

新来一00后,给我卷崩溃了..

2022年已经结束结束了&#xff0c;最近内卷严重&#xff0c;各种跳槽裁员&#xff0c;相信很多小伙伴也在准备今年的金三银四的面试计划。 在此展示一套学习笔记 / 面试手册&#xff0c;年后跳槽的朋友可以好好刷一刷&#xff0c;还是挺有必要的&#xff0c;它几乎涵盖了所有的…

记录一次在x86 软件中使用dpdk 的历程(Makefile gcc改成g++)

我们一台服务器上原本是用grub下预留内存的方式, 然后把物理地址在板卡上的配置文件中传给L1. 但是在客户的环境上服务器windriver上不是能预留内存的. 所以服务器上需要在testMxx程序中用dpdk的方式分配出内存, 然后, 把物理地址通过sdp虚拟的网口&#xff0c; 用socket 传…

日撸 Java 三百行day38

文章目录 说明day381.Dijkstra 算法思路分析2.Prim 算法思路分析3.对比4.代码 说明 闵老师的文章链接&#xff1a; 日撸 Java 三百行&#xff08;总述&#xff09;_minfanphd的博客-CSDN博客 自己也把手敲的代码放在了github上维护&#xff1a;https://github.com/fulisha-ok/…

接口测试入门必会知识总结(学习笔记)

目录 什么是接口&#xff1f; 内部接口 外部接口 接口的本质 什么是接口测试&#xff1f; 反向测试 为什么说接口测试如此重要&#xff1f; 越接近底层的 Bug&#xff0c;影响用户范围越广 目前流行的测试模型 接口测试的优越性 不同协议形式的测试 接口测试工作场景…

HTB靶机03-Shocker-WP

Shocker scan 2023-03-30 23:22 ┌──(xavier㉿xavier)-[~/Desktop/Inbox] └─$ sudo nmap -sSV -T4 -F 10.10.10.56 Starting Nmap 7.91 ( https://nmap.org ) at 2023-03-30 23:22 HKT Nmap scan report for 10.10.10.56 Host is up (0.40s latency). Not shown: 99 clos…

WindowsGUI自动化测试项目实战+辛酸过程+经验分享

WindowsGUI自动化测试项目实战辛酸过程经验分享 一、前言⚜ 起因⚜ 项目要求⚜ 预研过程⚜⚜ 框架选型⚜⚜ 关于UIaotumation框架 ⚜ 预研成果 二、项目介绍&#x1f493; 测试对象&#x1f493; 技术栈&#x1f493; 项目框架说明 三、项目展示&#x1f923; 界面实现效果&…

Nuxt3 布局layouts和NuxtLayout的使用

Nuxt3是基于Vue3的一个开发框架&#xff0c;基于服务器端渲染SSR&#xff0c;可以更加方便的用于Vue的SEO优化。 用Nuxt3 SSR模式开发出来的网站&#xff0c;渲染和运行速度非常快&#xff0c;性能也非常高&#xff0c;而且可SEO。 接下来我主要给大家讲解下Nuxt3的layouts布…

半监督目标检测

有监督目标检测&#xff1a; 拥有大规模带标签的数据&#xff0c;包括完整的实例级别的标注&#xff0c;即包含坐标和类别信息&#xff1b;弱监督目标检测&#xff1a; 数据集中的标注仅包含类别信息&#xff0c;不包含坐标信息&#xff0c;如图一 b 所示&#xff1b;弱半监督目…

漫谈大数据 - 数据湖认知篇

导语&#xff1a;数据湖是目前比较热的一个概念&#xff0c;许多企业都在构建或者准备构建自己的数据湖。但是在计划构建数据湖之前&#xff0c;搞清楚什么是数据湖&#xff0c;明确一个数据湖项目的基本组成&#xff0c;进而设计数据湖的基本架构&#xff0c;对于数据湖的构建…

Figma导出源文件的方法,用这个方法快速转换其它格式

市场上设计工具层出不穷&#xff0c;Sketch、AdobeXD、Axure、InVision、Figma、Pixso等都是优秀的设计工具&#xff0c;设计师经常面临如何从设计工具中导出文件的问题。 Figma软件的导出功能非常强大&#xff0c;因为轻量化体验受到很多设计师的喜爱。如何保存导出Figma源文…

【c语言】enum枚举类型的定义格式 | 基本用法

创作不易&#xff0c;本篇文章如果帮助到了你&#xff0c;还请点赞支持一下♡>&#x16966;<)!! 主页专栏有更多知识&#xff0c;如有疑问欢迎大家指正讨论&#xff0c;共同进步&#xff01; 给大家跳段街舞感谢支持&#xff01;ጿ ኈ ቼ ዽ ጿ ኈ ቼ ዽ ጿ ኈ ቼ ዽ ጿ…

研读Rust圣经解析——Rust learn-16(高级trait,宏)

研读Rust圣经解析——Rust learn-16&#xff08;高级trait&#xff0c;宏&#xff09; 高级trait关联类型Type为什么不用泛型而是Type 运算符重载&#xff08;重要等级不高&#xff09;重名方法消除歧义never typecontinue 的值是 ! 返回闭包 宏自定义宏&#xff08;声明宏&…

(04)基础强化:接口,类型转换cast/convert,异常处理,传参params/ref/out,判断同一对象

一、复习 1、New的截断是指什么&#xff1f; new除了新开空间创建初始化对象外&#xff0c;还有一个隐藏父类同名方法的作用。 当子类想要隐藏父类同名的方法时用new&#xff0c;用了new后父类同名方法将到此为止&#xff0c;后面 继承的…

【Java基础 1】Java 环境搭建

&#x1f34a; 欢迎加入社区&#xff0c;寒冬更应该抱团学习&#xff1a;Java社区 &#x1f4c6; 最近更新&#xff1a;2023年4月22日 文章目录 1 java发展史及特点1.1 发展史1.2 Java 特点1.2.1 可以做什么&#xff1f;1.2.2 特性 2 Java 跨平台原理2.1 两种核心机制2.2 JVM…