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

相关文章

C#借助Spire.XLS for .NET实现在Excel中添加文档属性

《C#借助Spire.XLSfor.NET实现在Excel中添加文档属性》在日常的数据处理和项目管理中,Excel文档扮演着举足轻重的角色,本文将深入探讨如何在C#中借助强大的第三方库Spire.... 目录为什么需要程序化添加Excel文档属性使用Spire.XLS for .NET库实现文档属性管理Sp

Python+FFmpeg实现视频自动化处理的完整指南

《Python+FFmpeg实现视频自动化处理的完整指南》本文总结了一套在Python中使用subprocess.run调用FFmpeg进行视频自动化处理的解决方案,涵盖了跨平台硬件加速、中间素材处理... 目录一、 跨平台硬件加速:统一接口设计1. 核心映射逻辑2. python 实现代码二、 中间素材处

Java数组动态扩容的实现示例

《Java数组动态扩容的实现示例》本文主要介绍了Java数组动态扩容的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录1 问题2 方法3 结语1 问题实现动态的给数组添加元素效果,实现对数组扩容,原始数组使用静态分配

Python实现快速扫描目标主机的开放端口和服务

《Python实现快速扫描目标主机的开放端口和服务》这篇文章主要为大家详细介绍了如何使用Python编写一个功能强大的端口扫描器脚本,实现快速扫描目标主机的开放端口和服务,感兴趣的小伙伴可以了解下... 目录功能介绍场景应用1. 网络安全审计2. 系统管理维护3. 网络故障排查4. 合规性检查报错处理1.

Python轻松实现Word到Markdown的转换

《Python轻松实现Word到Markdown的转换》在文档管理、内容发布等场景中,将Word转换为Markdown格式是常见需求,本文将介绍如何使用FreeSpire.DocforPython实现... 目录一、工具简介二、核心转换实现1. 基础单文件转换2. 批量转换Word文件三、工具特性分析优点局

Springboot3统一返回类设计全过程(从问题到实现)

《Springboot3统一返回类设计全过程(从问题到实现)》文章介绍了如何在SpringBoot3中设计一个统一返回类,以实现前后端接口返回格式的一致性,该类包含状态码、描述信息、业务数据和时间戳,... 目录Spring Boot 3 统一返回类设计:从问题到实现一、核心需求:统一返回类要解决什么问题?

Java使用Spire.Doc for Java实现Word自动化插入图片

《Java使用Spire.DocforJava实现Word自动化插入图片》在日常工作中,Word文档是不可或缺的工具,而图片作为信息传达的重要载体,其在文档中的插入与布局显得尤为关键,下面我们就来... 目录1. Spire.Doc for Java库介绍与安装2. 使用特定的环绕方式插入图片3. 在指定位

Java使用Spire.Barcode for Java实现条形码生成与识别

《Java使用Spire.BarcodeforJava实现条形码生成与识别》在现代商业和技术领域,条形码无处不在,本教程将引导您深入了解如何在您的Java项目中利用Spire.Barcodefor... 目录1. Spire.Barcode for Java 简介与环境配置2. 使用 Spire.Barco

Java利用Spire.Doc for Java实现在模板的基础上创建Word文档

《Java利用Spire.DocforJava实现在模板的基础上创建Word文档》在日常开发中,我们经常需要根据特定数据动态生成Word文档,本文将深入探讨如何利用强大的Java库Spire.Do... 目录1. Spire.Doc for Java 库介绍与安装特点与优势Maven 依赖配置2. 通过替换

Android使用java实现网络连通性检查详解

《Android使用java实现网络连通性检查详解》这篇文章主要为大家详细介绍了Android使用java实现网络连通性检查的相关知识,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录NetCheck.Java(可直接拷贝)使用示例(Activity/Fragment 内)权限要求