当前位置:网站首页>商品管理系统——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
边栏推荐
猜你喜欢

c++11-17 模板核心知识(二)—— 类模板

几行代码轻松实现跨系统传递 traceId,再也不用担心对不上日志了!

写时复制集合 —— CopyOnWriteArrayList

老大问我:“建表为啥还设置个自增 id ?用流水号当主键不正好么?”

2.计算机硬件简介

SAP S/4HANA 2020安装实录

Web上的分享(Share)API

Windows环境下如何进行线程Dump分析

SaaS: another manifestation of platform commercialization capability

The vowels in the inverted string of leetcode
随机推荐
C++之异常捕获和处理
File queue in Bifrost (1)
leetcode之反转字符串中的元音字母
如何通过Sidecar自定义资源减少Istio代理资源消耗
20201108 programming exercise exercise 3
1. What does the operating system do?
Have you ever thought about why the transaction and refund have to be split into different tables
WordPress Import 上传的文件尺寸超过php.ini中定义的upload_max_filesize值--&gt;解决方法。
Windows环境下如何进行线程Dump分析
B. protocal has 7000eth assets in one week!
2 普通模式
How does pipedrive support quality publishing with 50 + deployments per day?
python生日贺卡制作以及细节问题的解决最后把python项目发布为exe可执行程序过程
Natural language processing (NLP) roadmap - KDnuggets
Why don't we use graphql? - Wundergraph
Several common playing methods of sub database and sub table and how to solve the problem of cross database query
链表
23张图,带你入门推荐系统
C + + adjacency matrix
2.计算机硬件简介