当前位置:网站首页>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 :
边栏推荐
- [combinatorics] permutation and combination (set permutation, step-by-step processing example)
- 视觉上位系统设计开发(halcon-winform)-3.图像控件
- Popular understanding of ovo and ovr
- 秒杀系统1-登录功能
- Unity hierarchical bounding box AABB tree
- What is label encoding? How to distinguish and use one hot encoding and label encoding?
- Final review points of human-computer interaction
- Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
- Explanation of time complexity and space complexity
- App全局异常捕获
猜你喜欢
解决pushgateway数据多次推送会覆盖的问题
什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
秒杀系统2-Redis解决分布式Session问题
Idea does not specify an output path for the module
Halcon与Winform学习第二节
Popular understanding of ovo and ovr
【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer
Jvm-03-runtime data area PC, stack, local method stack
Summary of concurrent full knowledge points
随机推荐
Dataframe returns the whole row according to the value
Influxdb2 sources add data sources
基于SVN分支开发模式流程浅析
Tensorflow realizes verification code recognition (I)
Search in the two-dimensional array of leetcode sword offer (10)
在MapReduce中利用MultipleOutputs输出多个文件
详解指针进阶2
Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
Construction of operation and maintenance system
【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
Digital image processing -- popular Canny edge detection
socket.io搭建分布式Web推送服务器
阿特拉斯atlas扭矩枪 USB通讯教程基于MTCOM
【可能是全中文网最全】pushgateway入门笔记
App全局异常捕获
XWiki安装使用技巧
Kubernetes vous emmène du début à la fin
SQL server installation location cannot be changed
Can‘t connect to MySQL server on ‘localhost‘
Chapter 04_ Logical architecture