Swiper轮播图后端接口实现

2024-01-25 01:36

本文主要是介绍Swiper轮播图后端接口实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

mybatis-plus:global-config:db-config:id-type: auto #id生成规则:数据库id自增configuration:map-underscore-to-camel-case: false  # 开启驼峰功能auto-mapping-behavior: full # 自动映射任何复杂的结果log-impl: org.apache.ibatis.logging.stdout.StdOutImplmapper-locations: classpath:mybatis/mapper/*.xml

产品表

/*
SQLyog Ultimate v11.33 (64 bit)
MySQL - 5.7.18-log 
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;create table `t_product` (`id` int (11),`name` varchar (300),`price` Decimal (10),`stock` int (11),`proPic` varchar (765),`isHot` bit (1),`isSwiper` bit (1),`swiperPic` varchar (765),`swiperSort` int (11),`typeId` int (11),`hotDateTime` datetime ,`productIntroImgs` varchar (6000),`productParaImgs` varchar (6000),`description` varchar (6000)
); 
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('1','小米电视大师 82英寸','10999.00','3451','21.png','','','2.jpg','3','14','2021-11-26 21:36:34','\"\"','\"\"','\"\"');
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('4','Xiaomi 11','3799.00','3232','6.png','','','default.jpg','0','2','2021-07-28 21:36:34','<img width=\'100%\' src=\'http://192.168.0.116/image/productIntroImgs/11.jpg\'></img>','<img width=\'100%\' src=\'http://192.168.0.116/image/productParaImgs/11.jpg\'></img>','「全版本领券立减200元,券后价3299元起;享至高24期免息;赠手机保护壳*1;【全款支付套装】赠果冻包」');
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('5','Redmi K40 游戏增强版','2299.00','2005','11.png','','','1.jpg','1','39',NULL,'\"\"','\"\"','\"\"');
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('6','Xiaomi 11 Pro','4499.00','2343','1.png','','','default.jpg','0','2','2021-09-28 21:36:34','\"\"',NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('7','Xiaomi MIX FOLD折叠屏手机','7999.00','2222','2.png','','','default.jpg','0','3','2021-10-28 21:36:34','\"\"',NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('8','Note 9 5G','1199.00','1111','3.png','','','default.jpg','0','40','2021-09-28 21:36:34','\"\"',NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('9','Xiaomi 10S','2999.00','1111','4.png','','','default.jpg','0','2','2021-12-28 21:36:34','\"\"',NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('10','Note 9 Pro 5G','1399.00','2222','5.png','','','default.jpg','0','40','2021-11-28 21:36:34','\"\"',NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('11','黑鲨4','2499.00','3322','7.png','','','default.jpg','0','41','2021-11-28 21:36:34','\"\"',NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('12','Redmi  K40 Pro 系列','2499.00','3244','8.png','','','default.jpg','0','39','2021-11-28 21:36:34',NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('14','Xiaomi Civi','2599.00','4444','9.png','','','default.jpg','0','1',NULL,'<img width=\'100%\' src=\'http://192.168.0.116/image/productIntroImgs/1.jpg\'></img><img width=\'100%\' src=\'http://192.168.0.116/image/productIntroImgs/2.jpg\'></img><img width=\'100%\' src=\'http://192.168.0.116/image/productIntroImgs/3.jpg\'></img>','<img width=\'100%\' src=\'http://192.168.0.116/image/productParaImgs/1.jpg\'></img><img width=\'100%\' src=\'http://192.168.0.116/image/productParaImgs/2.jpg\'></img>','「购机至高享24期免息;赠Redmi AirDots 2真无线蓝牙耳机;赠Keep会员7天体验卡;+110元得Air2 SE蓝牙耳机」');
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('15','Xiaomi 11 Ultra','5499.00','4444','10.png','','','default.jpg','0','2',NULL,NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('16','小米平板5','1999.00','444','13.png','','','default.jpg','0','5',NULL,'<img src=\'http://192.168.0.116/image/productIntroImgs/111.jpg\'></img><img width=\'100%\' src=\'http://192.168.0.116/image/productIntroImgs/222.jpg\'></img><img width=\'100%\' src=\'http://192.168.0.116/image/productIntroImgs/333.jpg\'></img>','<img width=\'100%\' src=\'http://192.168.0.116/image/productParaImgs/111.jpg\'></img>','11英寸大屏 2.5K超清显示 120Hz高刷新率');
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('17','小米平板5 Pro','2499.00','444','14.png','','','default.jpg','0','5',NULL,NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('19','RedmiBook Pro 15 增强版','5299.00','444','15.png','','','default.jpg','0','6',NULL,NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('20','Redmi G 2021','6499.00','1999','16.png','','','3.jpg','2','6',NULL,NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('21','Redmi G 2021 锐龙版','7499.00','2000','17.png','','','default.jpg','0','6',NULL,NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('22','RedmiBook Pro 14 增强版','4999.00','777','18.png','','','default.jpg','0','6',NULL,NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('23','小米笔记本 Pro 14 锐龙版','5499.00','666','19.png','','','default.jpg','0','7',NULL,NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('24','小米笔记本 Pro 14 增强版','5499.00','666','20.png','','','default.jpg','0','7',NULL,NULL,NULL,NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('26','1','1.00','1','default.jpg','','','default.jpg','0','6',NULL,'1','1',NULL);
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('27','1','2.00','3','default.jpg','','','default.jpg','0','6',NULL,'5','6','4');
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('28','2','3.00','4','default.jpg','','','default.jpg','0','6',NULL,'6','7','5');
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('29','1','1.00','1','default.jpg','','','default.jpg','0','11',NULL,'1','1','1');
insert into `t_product` (`id`, `name`, `price`, `stock`, `proPic`, `isHot`, `isSwiper`, `swiperPic`, `swiperSort`, `typeId`, `hotDateTime`, `productIntroImgs`, `productParaImgs`, `description`) values('30','223335552','322.00','22355','default.jpg','','','default.jpg','0','6',NULL,'22333522','22333544442','22333511');
package com.java1234.entity;import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;import java.math.BigDecimal;
import java.util.Date;/*** 商品* @author java1234_小锋* @site www.java1234.com* @company 南通小锋网络科技有限公司* @create 2021-11-22 22:13*/
@TableName("t_product")
@Data
public class Product {private Integer id; // 编号private String name; // 名称private BigDecimal price; // 价格private String productIntroImgs; // 商品介绍图片private String productParaImgs;  // 商品规格参数图片private Integer stock; // 库存private String proPic="default.jpg"; // 商品图片private boolean isHot=false; // 是否热门推荐商品private boolean isSwiper=false; // 是否轮播图片商品private Integer swiperSort=0; // 轮播排序private String swiperPic="default.jpg"; // 商品轮播图片private String description; // 描述@JsonSerialize(using=CustomDateTimeSerializer.class)private Date hotDateTime; // 设置热门推荐日期时间}
package com.java1234.entity;import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;/*** 自定义返回JSON 数据格式中日期格式化处理* @author java1234 小锋 老师**/
public class CustomDateTimeSerializer extends JsonSerializer<Date>{@Overridepublic void serialize(Date value, JsonGenerator gen, SerializerProvider serializers)throws IOException {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));gen.writeString(sdf.format(value));  }}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.java1234.mapper.ProductMapper"></mapper>
package com.java1234.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.java1234.entity.Product;public interface ProductMapper extends BaseMapper<Product> {
}
package com.java1234.service.impl;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.java1234.entity.Product;
import com.java1234.mapper.ProductMapper;
import com.java1234.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;/**** 商品Service实现类*/
@Service("productService")
public class IProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {@Autowiredprivate ProductMapper productMapper;
}
package com.java1234.service;import com.baomidou.mybatisplus.extension.service.IService;
import com.java1234.entity.Product;/*** 商品Service接口*/
public interface IProductService extends IService<Product> {
}
package com.java1234.controller;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.java1234.entity.Product;
import com.java1234.entity.R;
import com.java1234.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.HashMap;
import java.util.List;
import java.util.Map;/*** 商品Controller*/
@RestController
@RequestMapping("/product")
public class ProductController {@Autowiredprivate IProductService productService;/*** 查询轮播商品* @return*/@GetMapping("/findSwiper")public R findSwiper(){List<Product> swiperProductList = productService.list(new QueryWrapper<Product>().eq("isSwiper", true).orderByAsc("swiperSort"));Map<String,Object> map=new HashMap<>();map.put("message",swiperProductList);return R.ok(map);}
}

这篇关于Swiper轮播图后端接口实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/641686

相关文章

Java实现检查多个时间段是否有重合

《Java实现检查多个时间段是否有重合》这篇文章主要为大家详细介绍了如何使用Java实现检查多个时间段是否有重合,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录流程概述步骤详解China编程步骤1:定义时间段类步骤2:添加时间段步骤3:检查时间段是否有重合步骤4:输出结果示例代码结语作

使用C++实现链表元素的反转

《使用C++实现链表元素的反转》反转链表是链表操作中一个经典的问题,也是面试中常见的考题,本文将从思路到实现一步步地讲解如何实现链表的反转,帮助初学者理解这一操作,我们将使用C++代码演示具体实现,同... 目录问题定义思路分析代码实现带头节点的链表代码讲解其他实现方式时间和空间复杂度分析总结问题定义给定

Java覆盖第三方jar包中的某一个类的实现方法

《Java覆盖第三方jar包中的某一个类的实现方法》在我们日常的开发中,经常需要使用第三方的jar包,有时候我们会发现第三方的jar包中的某一个类有问题,或者我们需要定制化修改其中的逻辑,那么应该如何... 目录一、需求描述二、示例描述三、操作步骤四、验证结果五、实现原理一、需求描述需求描述如下:需要在

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

如何通过Python实现一个消息队列

《如何通过Python实现一个消息队列》这篇文章主要为大家详细介绍了如何通过Python实现一个简单的消息队列,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录如何通过 python 实现消息队列如何把 http 请求放在队列中执行1. 使用 queue.Queue 和 reque

Python如何实现PDF隐私信息检测

《Python如何实现PDF隐私信息检测》随着越来越多的个人信息以电子形式存储和传输,确保这些信息的安全至关重要,本文将介绍如何使用Python检测PDF文件中的隐私信息,需要的可以参考下... 目录项目背景技术栈代码解析功能说明运行结php果在当今,数据隐私保护变得尤为重要。随着越来越多的个人信息以电子形

使用 sql-research-assistant进行 SQL 数据库研究的实战指南(代码实现演示)

《使用sql-research-assistant进行SQL数据库研究的实战指南(代码实现演示)》本文介绍了sql-research-assistant工具,该工具基于LangChain框架,集... 目录技术背景介绍核心原理解析代码实现演示安装和配置项目集成LangSmith 配置(可选)启动服务应用场景

使用Python快速实现链接转word文档

《使用Python快速实现链接转word文档》这篇文章主要为大家详细介绍了如何使用Python快速实现链接转word文档功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 演示代码展示from newspaper import Articlefrom docx import

前端原生js实现拖拽排课效果实例

《前端原生js实现拖拽排课效果实例》:本文主要介绍如何实现一个简单的课程表拖拽功能,通过HTML、CSS和JavaScript的配合,我们实现了课程项的拖拽、放置和显示功能,文中通过实例代码介绍的... 目录1. 效果展示2. 效果分析2.1 关键点2.2 实现方法3. 代码实现3.1 html部分3.2