秒杀项目之秒杀商品操作
一、秒杀商品显示
1、使用生成器生成对应的表
记得在每个mapper类加入注解供spring扫描:
@Repository
2、后端写得到秒杀商品的方法
①、建实体类vo
用于连表查询,得到商品名字
package com.example.seckill.vo;import com.example.seckill.pojo.SeckillGoods;
import lombok.Data;@Data
public class SeckillGoodsVo extends SeckillGoods {private String goodsName;
}
②、在SexkillGoodsMapper.xml文件中定义sql
<?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.example.seckill.mapper.SeckillGoodsMapper"><select id="queryAll" resultType="com.example.seckill.vo.SeckillGoodsVo">select sg.*,g.goods_namefrom t_seckill_goods sg,t_goods gwhere sg.goods_id = g.gid;</select>
</mapper>
③、在mapper中定义
package com.example.seckill.mapper;import com.example.seckill.pojo.SeckillGoods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.seckill.vo.SeckillGoodsVo;
import org.springframework.stereotype.Repository;import java.util.List;/*** <p>* 秒杀商品信息表 Mapper 接口* </p>** @author lv* @since 2022-03-19*/
@Repository
public interface SeckillGoodsMapper extends BaseMapper<SeckillGoods> {List<SeckillGoodsVo> queryAll();
}
④、service层与controller层
service:
ISeckillGoodsService:
package com.example.seckill.service;import com.example.seckill.pojo.SeckillGoods;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.seckill.util.response.ResponseResult;
import com.example.seckill.vo.SeckillGoodsVo;import java.util.List;/*** <p>* 秒杀商品信息表 服务类* </p>** @author lv* @since 2022-03-19*/
public interface ISeckillGoodsService extends IService<SeckillGoods> {ResponseResult<List<SeckillGoodsVo>> queryAll();
}
SeckillGoodsServiceImpl:
package com.example.seckill.service.impl;import com.example.seckill.pojo.SeckillGoods;
import com.example.seckill.mapper.SeckillGoodsMapper;
import com.example.seckill.service.ISeckillGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.seckill.util.response.ResponseResult;
import com.example.seckill.vo.SeckillGoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;/*** <p>* 秒杀商品信息表 服务实现类* </p>** @author lv* @since 2022-03-19*/
@Service
public class SeckillGoodsServiceImpl extends ServiceImpl<SeckillGoodsMapper, SeckillGoods> implements ISeckillGoodsService {@Autowiredprivate SeckillGoodsMapper seckillGoodsMapper;@Overridepublic ResponseResult<List<SeckillGoodsVo>> queryAll() {List<SeckillGoodsVo> list= seckillGoodsMapper.queryAll();return ResponseResult.success(list);}
}
controller:
SeckillGoodsController:
package com.example.seckill.controller;import com.example.seckill.service.ISeckillGoodsService;
import com.example.seckill.util.response.ResponseResult;
import com.example.seckill.vo.SeckillGoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.List;/*** <p>* 秒杀商品信息表 前端控制器* </p>** @author lv* @since 2022-03-19*/
@RestController
@RequestMapping("/seckillGoods")
public class SeckillGoodsController {@Autowiredprivate ISeckillGoodsService seckillGoodsService;@RequestMapping("/queryAll")public ResponseResult<List<SeckillGoodsVo>> queryAll(){return seckillGoodsService.queryAll();}}
得到秒杀商品数据:
3、前端显示数据
①、编辑跳转秒杀界面
goodList.ftl:
<!DOCTYPE html>
<html lang="en">
<head><#include "../common/head.ftl"><style>.layui-this{background: deepskyblue !important;}</style></head>
<body class="layui-container layui-bg-orange">
<div class="layui-tab"><ul class="layui-tab-title"><li class="layui-this">普通商品</li><li>秒杀商品</li></ul><#-- 普通商品--><div class="layui-tab-content"><div class="layui-tab-item layui-show"><div class="layui-form-item"><label class="layui-form-label">搜索栏</label><div class="layui-input-inline"><input type="text" id="normal_name" name="text" placeholder="请输入搜索内容" class="layui-input"></div><div class="layui-input-inline"><button class="layui-btn layui-btn-primary" id="normal_search">
秒杀项目之秒杀商品操作相关推荐
- 秒杀项目之秒杀商品展示及商品秒杀
目录 前言 一.登录方式调整 二.生成秒杀订单 2.1 绑定秒杀商品 2.2 查看秒杀商品 2.3 订单秒杀 2.3.1 移除seata相关(方便测压) 2.3.2 生成秒杀订单 2.3.3 前端页面 ...
- 秒杀项目之商品展示及商品秒杀
目录 登录方式调整 生成秒杀订单 绑定秒杀商品 查看秒杀商品 订单秒杀 移除seata相关 生成秒杀订单 前端页面秒杀测试 登录方式调整 第1步:从zmall-common的pom.xml中移除spr ...
- 电商项目实战之商品秒杀
电商项目实战之商品秒杀 定时任务 corn表达式 实现方式 基于注解 基于接口 实战 秒杀系统 秒杀系统关注问题 秒杀架构设计 商品上架 获取当前秒杀商品 获取当前商品的秒杀信息 秒杀最终处理 参考链 ...
- api商品分享源码_SSM框架高并发和商品秒杀项目高并发秒杀API源码免费分享
前言: 一个整合SSM框架的高并发和商品秒杀项目,学习目前较流行的Java框架组合实现高并发秒杀API 源码获取:关注头条号转发文章之后私信[秒杀]查看源码获取方式! 项目的来源 项目的来源于国内IT ...
- 微服务项目【秒杀商品展示及商品秒杀】
登录方式调整 第1步:从zmall-common的pom.xml中移除spring-session-data-redis依赖 注意: 1)本次不采用spring-session方式,改用redis直接 ...
- batocera中文整合包_分享一个整合 SSM 框架的高并发和商品秒杀项目
点击上方"Java基基",选择"设为星标" 做积极的人,而不是积极废人! 源码精品专栏 中文详细注释的开源项目 RPC 框架 Dubbo 源码解析 网络应用框架 ...
- 从前慢-项目小型秒杀系统
秒杀系统 1 秒杀系统 1.1 秒杀场景 电商抢购限量商品 卖周董演唱会的门票 火车票抢座 12306 .......... 1.2 为什么要做个系统 如果你的项目流量非常小,完全不用担心有并发的购买 ...
- 秒杀项目05-页面优化技术
秒杀项目05-页面优化技术 1. 页面缓存+URL缓存+对象缓存 1.1 页面缓存 1.2 URL缓存 1.3 对象缓存(更细粒度的缓存) 2. 页面静态化,前后端分离 1. 常用技术AngularJ ...
- SpringBoot学习+秒杀项目
目录一 ~ 六来源:GitHub 一.项目简介 1.商品列表页获取秒杀商品列表 2.进入商品详情页获取秒杀商品详情 3.秒杀开始后进入下单确认页下单并支付成功 二.应用springboot完成基础项目 ...
最新文章
- 计算机网络的性能指标和非性能特征
- 随笔-tomcat的日志文件按日期每天生成
- SpringBoot升级到2.3.x后返回message为空
- Java 中常见的异常和自定义异常
- 简单理解线程同步上下文
- [资源分享] 吴恩达最新《机器学习训练秘籍》中文版可以免费下载了
- 哈工大未来计算机院士,2017年中国高校新增工程院院士名单出炉,哈工大依然很强!...
- 从北京77元房租,说说关于房子的事
- 实际返回的行数超出请求的行数_代码行数越少越好?
- 如何缩小图片大小kb?
- 个人朋友圈时代过去了,企业微信朋友圈开辟营销新思路
- Linux 发展史小览
- 智能家居系统解决方案
- (二)安装SVN服务器,web管理界面
- 华侨大学教务系统评教脚本----一键评教
- OpenCV--0016:图像ROI与ROI操作
- 小巧易用的分区工具——MiniTool Partition Wizard
- 卡巴斯基管理服务器地址更新
- 关于 MATLAB 你首先要会的基础(权且可当做期末复习备考)
- 供应链金融操作过程中难点解析
热门文章