当前位置:网站首页>Second kill system 3 - list of items and item details
Second kill system 3 - list of items and item details
2022-07-03 15:20:00 【Tu es mon bogue éternel】
1、Ajouter d'abord des données à la base de données
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、Selon Mybatis-plus La rétroingénierie génère les tables de base de données dans les fichiers appropriés
3、 Obtenir dans l'interface Liste des produits
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;
/** * Page de l'article de saut * @param * @param model * @param * @return */
@RequestMapping("/toList")
public String toList(Model model,User user){
// Mettre les informations de l'utilisateur Aller à la page avant
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> * Liste des produits Classe de mise en œuvre du Service * </p> * * @author jobob * @since 2022-06-14 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService {
@Autowired(required = false)
GoodsMapper goodsMapper;
/** * Obtenir la liste des produits * @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>
Et la page de la liste des produits de première ligne
<!DOCTYPE html>
<html lang="en"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Liste des produits</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">Liste des articles</div>
<table class="table" id="goodslist">
<tr>
<td>Nom commercial</td>
<td>Image du produit</td>
<td>Prix d'origine des marchandises</td>
<td>Deuxième prix</td>
<td>Quantité en stock</td>
<td>Détails</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}">Détails</a></td>
</tr>
</table>
</div>
</body>
</html>
Exécution:
边栏推荐
- Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
- Kubernetes vous emmène du début à la fin
- GCC cannot find the library file after specifying the link library path
- Influxdb2 sources add data sources
- Tensorflow realizes verification code recognition (II)
- [daily training] 395 Longest substring with at least k repeated characters
- Redis cache penetration, cache breakdown, cache avalanche solution
- [pytorch learning notes] datasets and dataloaders
- Using TCL (tool command language) to manage Tornado (for VxWorks) can start the project
- 【Transform】【实践】使用Pytorch的torch.nn.MultiheadAttention来实现self-attention
猜你喜欢
【Transform】【实践】使用Pytorch的torch.nn.MultiheadAttention来实现self-attention
【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer
el-switch 赋值后状态不变化
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
Didi off the shelf! Data security is national security
秒杀系统1-登录功能
Digital image processing -- popular understanding of corrosion and expansion
[cloud native training camp] module 7 kubernetes control plane component: scheduler and controller
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
Visual upper system design and development (Halcon WinForm) -5 camera
随机推荐
Kubernetes - yaml file interpretation
Tensorflow realizes verification code recognition (II)
Introduction, use and principle of synchronized
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)
Jvm-05-object, direct memory, string constant pool
Kubernetes - YAML文件解读
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
如何使用 @NotNull等注解校验 并全局异常处理
leetcode_ Power of Four
视觉上位系统设计开发(halcon-winform)-4.通信管理
[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer
Kubernetes带你从头到尾捋一遍
求字符串函数和长度不受限制的字符串函数的详解
Using Tengine to solve the session problem of load balancing
Visual upper system design and development (Halcon WinForm) -1 Process node design
C语言刷题~Leetcode与牛客网简单题
Reentrantlock usage and source code analysis
Tensorflow realizes verification code recognition (III)
Leetcode the smallest number of the rotation array of the offer of the sword (11)
Global and Chinese market of iron free motors 2022-2028: Research Report on technology, participants, trends, market size and share