记得上下班打卡 | git大法好,push需谨慎

Commit 9a9cbd37 authored by zhengfuxin's avatar zhengfuxin

修改bug、支持商铺模糊搜索

parent f625bba0
......@@ -112,8 +112,8 @@ public class GoblinFrontController {
}
@GetMapping("getStoreGoodes")
@ApiOperation("获得店铺商品")
public ResponseDto<List<GoblinGoodsInfoVo>> getStoreGoodes(@RequestParam(name = "storeId", required = true)String storeId,@RequestParam(name = "categoryId", required = true)String categoryId) throws ParseException {
return ResponseDto.success( goblinFrontService.getStoreGoodes(storeId,categoryId));
public ResponseDto<List<GoblinGoodsInfoVo>> getStoreGoodes(@RequestParam(name = "storeId", required = true)String storeId,@RequestParam(name = "categoryId", required = true)String categoryId,@RequestParam(name = "name", required = true)String name) throws ParseException {
return ResponseDto.success( goblinFrontService.getStoreGoodes(storeId,categoryId,name));
}
@GetMapping("searchGoodesName")
@ApiOperation("搜索商品名字")
......
......@@ -30,6 +30,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Pattern;
@Service
@Slf4j
......@@ -353,17 +354,21 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
public List<GoblinGoodsInfoVo> searchGoodesName(String name){
return null;
}
public List<GoblinGoodsInfoVo> getStoreGoodes(String storeId,String categoryId){
public List<GoblinGoodsInfoVo> getStoreGoodes(String storeId,String categoryId,String name){
//
Query query = new Query();
query.addCriteria(Criteria.where("storeId").is(storeId));
if(StringUtil.isNotBlank(categoryId)){
query.addCriteria(new Criteria().orOperator(
Criteria.where("cateFid").is(categoryId),
Criteria.where("cateSid").is(categoryId),
Criteria.where("cateTid").is(categoryId)
Criteria.where("storeCateFid").is(categoryId),
Criteria.where("storeCateSid").is(categoryId),
Criteria.where("storeCateTid").is(categoryId)
));
}
if(StringUtil.isNotBlank(name)){
Pattern pattern = Pattern.compile("^.*"+name+".*$", Pattern.CASE_INSENSITIVE);
query.addCriteria(Criteria.where("name").regex(pattern));
}
// 查询总数
List<GoblinGoodsInfoVo> list = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
if(list.size()>0){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment