当前位置:网站首页>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.]所创,转载请带上原文链接,感谢
边栏推荐
- STC转STM32第一次开发
- 老大问我:“建表为啥还设置个自增 id ?用流水号当主键不正好么?”
- 代码保存
- 分库分表的几种常见玩法及如何解决跨库查询等问题
- A few lines of code can easily transfer traceid across systems, so you don't have to worry about losing the log!
- File queue in Bifrost (1)
- Natural language processing (NLP) roadmap - KDnuggets
- RabbitMQ脑裂问题解决方案调查
- 1. What does the operating system do?
- Detailed analysis of OpenGL es framework (8) -- OpenGL es Design Guide
猜你喜欢
几行代码轻松实现跨系统传递 traceId,再也不用担心对不上日志了!
如何通过Sidecar自定义资源减少Istio代理资源消耗
Combine theory with practice to understand CORS thoroughly
Apache Iceberg 中三种操作表的方式
A few lines of code can easily transfer traceid across systems, so you don't have to worry about losing the log!
1.操作系统是干什么的?
Five design patterns frequently used in development
Concurrent linked queue: a non blocking unbounded thread safe queue
Introduction to nmon
23 pictures, take you to the recommended system
随机推荐
Web上的分享(Share)API
How to do thread dump analysis in Windows Environment
Share API on the web
Depth first search and breadth first search
leetcode之反转字符串中的元音字母
无法启动此程序,因为计算机中丢失 MSVCP120.dll。尝试安装该程序以解决此问题
EasyNTS上云网关设备在雪亮工程项目中的实战应用
你有没有想过为什么交易和退款要拆开不同的表
Oschina plays disorderly on Monday
How to reduce the resource consumption of istio agent through sidecar custom resource
架构中台图
2. Introduction to computer hardware
centos7下安装iperf时出现 make: *** No targets specified and no makefile found. Stop.的解决方案
After Android solves the setrequested orientation, the rotation of the mobile phone screen does not trigger the onconfigurationchanged method
2 普通模式
Salesforce connect & external object
salesforce零基础学习(九十八)Salesforce Connect & External Object
Review of API knowledge
Get the first cover image of video through canvas
python生日贺卡制作以及细节问题的解决最后把python项目发布为exe可执行程序过程