当前位置:网站首页>商品管理系统——SPU检索功能
商品管理系统——SPU检索功能
2020-11-09 07:35:00 【osc_c67q27vg】
一 API分析
1 请求
GET /product/spuinfo/list
2 请求参数
{
page: 1, //当前页码
limit: 10, //每页记录数
sidx: 'id', //排序字段
order: 'asc/desc', //排序方式
key: '华为', //检索关键字
catelogId: 6, //三级分类id
brandId: 1, //品牌id
status: 0, //商品状态
}
3 响应
{
"msg": "success",
"code": 0,
"page": {
"totalCount": 0,
"pageSize": 10,
"totalPage": 0,
"currPage": 1,
"list": [{
"brandId": 0, //品牌id
"brandName": "品牌名字",
"catalogId": 0, //分类id
"catalogName": "分类名字",
"createTime": "2019-11-13T16:07:32.877Z", //创建时间
"id": 0, //商品id
"publishStatus": 0, //发布状态
"spuDescription": "string", //商品描述
"spuName": "string", //商品名字
"updateTime": "2019-11-13T16:07:32.877Z", //更新时间
"weight": 0 //重量
}]
}
}
二 控制器
/**
* 功能描述:按条件查询SPU信息
*
* @param params 过滤条件
* @return R 返回给前端的数据
* @author cakin
* @date 2020/11/8
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = spuInfoService.queryPageByCondition(params);
return R.ok().put("page", page);
}
三 服务层
/**
* 功能描述:按条件进行分页查询
*
* @param params 过滤条件
* @return PageUtils 分页信息
* @author cakin
* @date 2020/11/8
*/
@Override
public PageUtils queryPageByCondition(Map<String, Object> params) {
QueryWrapper<SpuInfoEntity> wrapper = new QueryWrapper<>();
String key = (String) params.get("key");
// 关键字查询
if (!StringUtils.isEmpty(key)) {
wrapper.and((w) -> {
w.eq("id", key).or().like("spu_name", key);
});
}
// 拼接 status
String status = (String) params.get("status");
if (!StringUtils.isEmpty(status)) {
wrapper.eq("publish_status", status);
}
// 拼接 brandId
String brandId = (String) params.get("brandId");
if (!StringUtils.isEmpty(brandId) && !"0".equalsIgnoreCase(brandId)) {
wrapper.eq("brand_id", brandId);
}
// 拼接 catelogId
String catelogId = (String) params.get("catelogId");
if (!StringUtils.isEmpty(catelogId) && !"0".equalsIgnoreCase(catelogId)) {
wrapper.eq("catalog_id", catelogId);
}
// 分页条件和其他复合条件拼接后的查询
IPage<SpuInfoEntity> page = this.page(new Query<SpuInfoEntity>().getPage(params), wrapper);
return new PageUtils(page);
}
四 测试

版权声明
本文为[osc_c67q27vg]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4301161/blog/4708491
边栏推荐
- 图节点分类与消息传递 - 知乎
- Adding OpenGL form to MFC dialog
- 平台商业化能力的另一种表现形式SAAS
- How does semaphore, a thread synchronization tool that uses an up counter, look like?
- 教你如何 分析 Android ANR 问题
- 首次开通csdn,这篇文章送给过去的自己和正在发生的你
- A solution to the problem that color picker (palette) cannot use shortcut keys in sublime Text3 plug-in
- A bunch of code forgot to indent? Shortcut teach you carefree!
- centos7下安装iperf时出现 make: *** No targets specified and no makefile found. Stop.的解决方案
- 基于链表的有界阻塞队列 —— LinkedBlockingQueue
猜你喜欢

操作系统之bios

基于链表的有界阻塞队列 —— LinkedBlockingQueue

How to reduce the resource consumption of istio agent through sidecar custom resource

App crashed inexplicably. At first, it thought it was the case of the name in the header. Finally, it was found that it was the fault of the container!

Concurrent linked queue: a non blocking unbounded thread safe queue

20201108编程练习——练习3

A few lines of code can easily transfer traceid across systems, so you don't have to worry about losing the log!

LeetCode-15:三数之和

首次开通csdn,这篇文章送给过去的自己和正在发生的你

《MFC dialog中加入OpenGL窗体》
随机推荐
你有没有想过为什么交易和退款要拆开不同的表
非阻塞的无界线程安全队列 —— ConcurrentLinkedQueue
Linked blocking queue based on linked list
GDI 及OPENGL的区别
老大问我:“建表为啥还设置个自增 id ?用流水号当主键不正好么?”
Save code
Android emulator error: x86 emulation currently requires hardware acceleration solution
Programmers should know the URI, a comprehensive understanding of the article
首次开通csdn,这篇文章送给过去的自己和正在发生的你
老大问我:“建表为啥还设置个自增 id ?用流水号当主键不正好么?”
A solution to the problem that color picker (palette) cannot use shortcut keys in sublime Text3 plug-in
使用递增计数器的线程同步工具 —— 信号量,它的原理是什么样子的?
Share API on the web
2020,Android开发者打破寒冬的利器是什么?
Execution of SQL statement
服务器性能监控神器nmon使用介绍
After Android solves the setrequested orientation, the rotation of the mobile phone screen does not trigger the onconfigurationchanged method
教你如何 分析 Android ANR 问题
简单介绍c#通过代码开启或关闭防火墙示例
Leetcode-11: container with the most water