当前位置:网站首页>Seckill system 3- product list and product details
Seckill system 3- product list and product details
2022-07-03 15:21:00 【You are my forever bug】
1、 First, add data in the database
INSERT INTO `t_goods` VALUES (1, 'Iphone 12 64G', 'Iphone 12 64G', '/img/iphone12.png', 'Iphone 12 64G', 5299.00, 100);
INSERT INTO `t_goods` VALUES (2, 'Iphone12Pro128G', 'Iphone12Pro128G', '/img/iphone12pro.png', 'Iphone12Pro128G', 6299.00, 100);
INSERT INTO `t_seckill_goods` VALUES (1, 1, 4299.00, 10, '2022-06-15 00:00:00', '2022-07-15 00:00:00');
INSERT INTO `t_seckill_goods` VALUES (2, 2, 5299.00, 10, '2022-06-15 00:00:00', '2022-07-15 00:00:00');
2、 according to Mybatis-plus Reverse engineering generates corresponding files from database tables 
3、 Get List of goods
package com.example.seckill.controller;
import com.example.seckill.common.RespBean;
import com.example.seckill.controller.parm.LoginRequestParam;
import com.example.seckill.pojo.User;
import com.example.seckill.service.IGoodsService;
import com.example.seckill.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@RequestMapping("/goods")
@Controller
@Slf4j
public class GoodsController {
@Autowired
IGoodsService goodsService;
@Autowired
IUserService userService;
/** * Jump to product page * @param * @param model * @param * @return */
@RequestMapping("/toList")
public String toList(Model model,User user){
// Put user information To the front page
model.addAttribute("user",user);
model.addAttribute("goodsList",goodsService.findGoodsList());
return "goodsList";
}
}
package com.example.seckill.service.impl;
import com.example.seckill.controller.outPutParm.GoodsListOutPut;
import com.example.seckill.pojo.Goods;
import com.example.seckill.mapper.GoodsMapper;
import com.example.seckill.service.IGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/** * <p> * Commodity list Service implementation class * </p> * * @author jobob * @since 2022-06-14 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService {
@Autowired(required = false)
GoodsMapper goodsMapper;
/** * Get a list of products * @return */
@Override
public List<GoodsListOutPut> findGoodsList() {
List<GoodsListOutPut> goodsList= goodsMapper.findGoodsList();
return goodsList;
}
}
<select id="findGoodsList" resultType="com.example.seckill.controller.outPutParm.GoodsListOutPut">
SELECT g.id,
g.goods_name,
g.goods_title,
g.goods_img,
g.goods_price,
g.goods_stock,
sg.seckill_price,
sg.stock_count,
sg.start_date,
sg.end_date
FROM t_goods g
LEFT JOIN t_seckill_goods sg on g.id = sg.goods_id
</select>
And the front-end product list page
<!DOCTYPE html>
<html lang="en"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title> List of goods </title>
<!-- jquery -->
<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
<!-- bootstrap -->
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap/css/bootstrap.min.css}"/>
<script type="text/javascript" th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
<!-- layer -->
<script type="text/javascript" th:src="@{/layer/layer.js}"></script>
<!-- common.js -->
<script type="text/javascript" th:src="@{/js/common.js}"></script>
</head>
<body>
<div class="panel panel-default">
<div class="panel-heading"> Second kill commodity list </div>
<table class="table" id="goodslist">
<tr>
<td> Name of commodity </td>
<td> Commodity images </td>
<td> The original price of the goods </td>
<td> price spike </td>
<td> Inventory quantity </td>
<td> details </td>
</tr>
<tr th:each="goods,goodsStat : ${goodsList}">
<td th:text="${goods.goodsName}"></td>
<td><img th:src="@{${goods.goodsImg}}" width="100" height="100"/></td>
<td th:text="${goods.goodsPrice}"></td>
<td th:text="${goods.seckillPrice}"></td>
<td th:text="${goods.stockCount}"></td>
<td><a th:href="'/goodsDetail.html?goodsId='+${goods.id}"> details </a></td>
</tr>
</table>
</div>
</body>
</html>
function :
边栏推荐
- 【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
- Jvm-09 byte code introduction
- GCC cannot find the library file after specifying the link library path
- 什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
- 什么是Label encoding?one-hot encoding ,label encoding两种编码该如何区分和使用?
- Popular understanding of linear regression (II)
- Detailed comments on MapReduce instance code on the official website
- Global and Chinese markets for infrared solutions (for industrial, civil, national defense and security applications) 2022-2028: Research Report on technology, participants, trends, market size and sh
- 整形和浮点型是如何在内存中的存储
- Visual upper system design and development (Halcon WinForm) -5 camera
猜你喜欢

函数栈帧的创建和销毁

Halcon与Winform学习第一节

qt使用QZxing生成二维码

【可能是全中文网最全】pushgateway入门笔记

Dataframe returns the whole row according to the value

Visual upper system design and development (Halcon WinForm) -1 Process node design
![[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University](/img/83/922efb4f88843f1b7feaccf2b515b9.jpg)
[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University
![[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer](/img/9b/6ca8375ef8689a80d437665909ae30.png)
[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer

第04章_逻辑架构

Jvm-05-object, direct memory, string constant pool
随机推荐
Stress test WebService with JMeter
Markdown file titles are all reduced by one level
Visual host system design and development (Halcon WinForm)
视觉上位系统设计开发(halcon-winform)-5.相机
Basic SQL tutorial
Global and Chinese markets for indoor HDTV antennas 2022-2028: Research Report on technology, participants, trends, market size and share
Didi off the shelf! Data security is national security
视觉上位系统设计开发(halcon-winform)-6.节点与宫格
Global and Chinese market of air cargo logistics 2022-2028: Research Report on technology, participants, trends, market size and share
Kubernetes - yaml file interpretation
Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
[pytorch learning notes] datasets and dataloaders
[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University
Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
Tensorflow realizes verification code recognition (II)
Jvm-04-runtime data area heap, method area
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
Visual upper system design and development (Halcon WinForm) -6 Nodes and grids
redis单线程问题强制梳理门外汉扫盲
Detailed comments on MapReduce instance code on the official website