当前位置:网站首页>Commodity management system -- the search function of SPU
Commodity management system -- the search function of SPU
2020-11-09 07:35:00 【I'm sorry.】
One API analysis
1 request
GET /product/spuinfo/list
2 Request parameters
{
page: 1, // The current page number
limit: 10, // Records per page
sidx: 'id', // Sort field
order: 'asc/desc', // sort order
key: ' Huawei ', // Search keywords
catelogId: 6, // Three levels of classification id
brandId: 1, // brand id
status: 0, // Goods state
}
3 Respond to
{
"msg": "success",
"code": 0,
"page": {
"totalCount": 0,
"pageSize": 10,
"totalPage": 0,
"currPage": 1,
"list": [{
"brandId": 0, // brand id
"brandName": " Brand name ",
"catalogId": 0, // classification id
"catalogName": " Category name ",
"createTime": "2019-11-13T16:07:32.877Z", // Creation time
"id": 0, // goods id
"publishStatus": 0, // Release status
"spuDescription": "string", // Commodity Description
"spuName": "string", // Commodity name
"updateTime": "2019-11-13T16:07:32.877Z", // Update time
"weight": 0 // weight
}]
}
}
Two controller
/**
* Function description : Query by criteria SPU Information
*
* @param params Filter conditions
* @return R Data returned to the front end
* @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);
}
3、 ... and Service layer
/**
* Function description : Pagination query by condition
*
* @param params Filter conditions
* @return PageUtils Paging information
* @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");
// Keyword query
if (!StringUtils.isEmpty(key)) {
wrapper.and((w) -> {
w.eq("id", key).or().like("spu_name", key);
});
}
// Splicing status
String status = (String) params.get("status");
if (!StringUtils.isEmpty(status)) {
wrapper.eq("publish_status", status);
}
// Splicing brandId
String brandId = (String) params.get("brandId");
if (!StringUtils.isEmpty(brandId) && !"0".equalsIgnoreCase(brandId)) {
wrapper.eq("brand_id", brandId);
}
// Splicing catelogId
String catelogId = (String) params.get("catelogId");
if (!StringUtils.isEmpty(catelogId) && !"0".equalsIgnoreCase(catelogId)) {
wrapper.eq("catalog_id", catelogId);
}
// Pagination conditions and other composite conditions after splicing query
IPage<SpuInfoEntity> page = this.page(new Query<SpuInfoEntity>().getPage(params), wrapper);
return new PageUtils(page);
}
Four test

版权声明
本文为[I'm sorry.]所创,转载请带上原文链接,感谢
边栏推荐
- Android emulator error: x86 emulation currently requires hardware acceleration solution
- Tips in Android Development: requires permission android.permission write_ Settings solution
- leetcode之反转字符串中的元音字母
- 上线1周,B.Protocal已有7000ETH资产!
- 2. Introduction to computer hardware
- 服务器性能监控神器nmon使用介绍
- Chapter 5 programming
- Installation record of SAP s / 4hana 2020
- Have you ever thought about why the transaction and refund have to be split into different tables
- 商品管理系统——SPU检索功能
猜你喜欢
随机推荐
Investigation of solutions to rabbitmq cleft brain problem
How does FC game console work?
服务器性能监控神器nmon使用介绍
14. Introduction to kubenetes
梁老师小课堂|谈谈模板方法模式
Installation record of SAP s / 4hana 2020
Service grid is still difficult - CNCF
WordPress Import 上传的文件尺寸超过php.ini中定义的upload_max_filesize值--&gt;解决方法。
几行代码轻松实现跨系统传递 traceId,再也不用担心对不上日志了!
Several rolling captions based on LabVIEW
OpenGL ES 框架详细解析(八) —— OpenGL ES 设计指南
RabbitMQ脑裂问题解决方案调查
File queue in Bifrost (1)
简单介绍c#通过代码开启或关闭防火墙示例
Leetcode-15: sum of three numbers
分库分表的几种常见玩法及如何解决跨库查询等问题
Exception capture and handling in C + +
Apache Iceberg 中三种操作表的方式
A solution to the problem that color picker (palette) cannot use shortcut keys in sublime Text3 plug-in
图节点分类与消息传递 - 知乎






