当前位置:网站首页>Product name fuzzy search:
Product name fuzzy search:
2022-07-27 18:50:00 【Fantasia of the cat】
Process analysis :

Interface development :
Fuzzy query
sql:(productMapper)
/**
* Fuzzy search for product information based on keywords
* @param keyword
* @param start
* @param limit
* @return
*/
public List<ProductVO> selectProductByKeyword(@Param("kw") String keyword,
@Param("start") int start,
@Param("limit") int limit);The mapping file :
<select id="selectProductByKeyword" resultMap="ProductVOMap2">
select product_id,
product_name,
category_id,
root_category_id,
sold_num,
product_status,
content,
create_time,
update_time
from product
where product_name like #{kw}
limit #{start},#{limit}
</select>service Realization :
public R searchProduct(String kw,int pageNum,int limit);@Override
public R searchProduct(String kw, int pageNum, int limit) {
//1. Query search results
kw = "%"+kw+"%";
int start = (pageNum - 1)*limit;
List<ProductVO> productVOS = productMapper.selectProductByKeyword(kw, start, limit);
//2. Total number of records queried
Example example = new Example(Product.class);
Example.Criteria criteria = example.createCriteria();
criteria.andLike("productName",kw);
int count = productMapper.selectCountByExample(example);
//3. Calculate the total number of records
int pageCount = count%limit==0? count/limit:count/limit+1;
//4. encapsulation , Return the data
PageHelper<ProductVO> pageHelper = new PageHelper<>(count,pageCount,productVOS);
R r = new R(ResStatus.OK,"success",pageHelper);
return r;
}controller Realization :
// Query commodity interface by keyword
@GetMapping("/listbykeyword")
public R searchProducts(String keyword,int pageNum,int pageSize){
return productService.searchProduct(keyword, pageNum, pageSize);
}Query the brand of the corresponding product according to the keyword :
sql:

Database implementation :productMapper:
/**
* Query the brand list of related products according to the search keywords
* @param kw
* @return
*/
public List<String> selectBrandByKeyword(String kw);The mapping file :
<select id="selectBrandByKeyword" resultSets="java.util.List" resultType="String">
select Distinct brand
from product_params
where product_id in (
select product_id
from product
where product_name like #{kw}
)
</select>service Realization :
public R listBrandsByKeyword(String kw);@Override
public R listBrandsByKeyword(String kw) {
kw = "%"+kw+"%";
List<String> strings = productMapper.selectBrandByKeyword(kw);
return new R(ResStatus.OK,"success",strings);
}controller Realization :
// Query the commodity brand interface according to keywords
@GetMapping("/listbrandsByKeyword")
public R getBrandsByKeyword(String keyword){
return productService.listBrandsByKeyword(keyword);
}边栏推荐
- nacos显示服务注册地址错误
- 迷你洗衣机触摸芯片-DLT8MA12TS-杰力科创
- Openstack login dashboard prompt authentication error
- 家用静音驱蚊灯芯片-DLTAP703SD-杰力科创
- 怎么会不喜欢呢,CI/CD中轻松发送邮件
- 机器学习分类任务效果评估指标大全(包含ROC和AUC)
- Why don't you like it? It's easy to send mail in ci/cd
- 2021.8.1 Notes database design
- Knowledge map pyhanlp realizes named body recognition (with named body recognition code)
- Have you ever stumbled on MySQL's order by
猜你喜欢

机器学习分类任务效果评估指标大全(包含ROC和AUC)

20000 words + 30 pictures | what's the use of chatting about MySQL undo log, redo log and binlog?

音乐律动七彩渐变灯芯片--DLT8S04A-杰力科创

Complete set of machine learning classification task effect evaluation indicators (including ROC and AUC)

订单的提交

2021.8.1 notes DBA

Jianmu continuous integration platform v2.5.2 release

Generate PDM file from Navicat export table

mysql基础语句

Login page tablelayout
随机推荐
浅谈JVM(面试常考)
家用静音驱蚊灯芯片-DLTAP703SD-杰力科创
电动加热护颈枕芯片-DLTAP703SC
2021.8.1 Notes database design
如何实现Word、PDF、TXT文件的全文内容检索?
Mode= "widthfix" attribute in image tag
Commodity comment information and comment information classification
使用jieba、pyhanlp工具实现关键字词句的提取
JDBC learning day1:jdbc
Openstack login dashboard prompt authentication error
2021.7.22 note constraints
浴室带除雾化妆镜触摸芯片-DLT8T10S
建木持续集成平台v2.5.2发布
多功能无线遥控艾灸仪芯片-DLTAP703SD
Pandas' to_ SQL function usage
ridis命令笔记
Ant privacy computing innovation tee technology has won academic recognition
XML learning Day1: XML / jsup parser / selector /xpath selector
2021.7.17 notes MySQL other commands
Machine learning -- error caused by only one kind of label data in SVM training set