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

Commit 3ecc01f2 authored by zhengfuxin's avatar zhengfuxin

修改分页搜索;

parent c8da9f79
package com.liquidnet.service.goblin.dto.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@ApiModel(value = "GoblinGoodsInfoListVo", description = "商品SPU List")
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class GoblinGoodsInfoListVoo implements Serializable, Cloneable {
private List<GoblinGoodsInfoListVo> list;
@ApiModelProperty(position = 55, value = "数量")
private long count;
private static final GoblinGoodsInfoListVoo obj = new GoblinGoodsInfoListVoo();
public static GoblinGoodsInfoListVoo getNew() {
try {
return (GoblinGoodsInfoListVoo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinGoodsInfoListVoo();
}
}
/* public int compareTo(GoblinGoodsInfoVo arg0) {
return this.getCount().compareTo(arg0.getCount());
}*/
}
package com.liquidnet.service.goblin.controller; package com.liquidnet.service.goblin.controller;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.StringUtil; import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinFrontHotWord; import com.liquidnet.service.goblin.entity.GoblinFrontHotWord;
import com.liquidnet.service.goblin.service.GoblinFrontService;
import com.liquidnet.service.goblin.service.impl.GoblinFrontServiceImpl; import com.liquidnet.service.goblin.service.impl.GoblinFrontServiceImpl;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -134,9 +131,9 @@ public class GoblinFrontController { ...@@ -134,9 +131,9 @@ public class GoblinFrontController {
@GetMapping("searchGoodesName") @GetMapping("searchGoodesName")
@ApiOperation("搜索商品名字、或商铺名字") @ApiOperation("搜索商品名字、或商铺名字")
public ResponseDto<List<GoblinGoodsInfoListVo>> searchGoodesName(@RequestParam(name = "name", required = true) String name) throws ParseException { public ResponseDto<GoblinGoodsInfoListVoo> searchGoodesName(@RequestParam(name = "name", required = true) String name,@RequestParam(name = "page", required = true) int page,@RequestParam(name = "pageSize", required = true) int pageSize) throws ParseException {
if (StringUtil.isNotBlank(name)) { if (StringUtil.isNotBlank(name)) {
return ResponseDto.success(goblinFrontService.searchGoodesName(name)); return ResponseDto.success(goblinFrontService.searchGoodesName(name,page,pageSize));
} }
return ResponseDto.success(null); return ResponseDto.success(null);
} }
......
...@@ -463,7 +463,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -463,7 +463,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
} }
public List<GoblinGoodsInfoListVo> searchGoodesName(String name) { public GoblinGoodsInfoListVoo searchGoodesName(String name,int page,int pageSize) {
List<String> listStore = mongoUtils.getStoreInfoVoRegexName(name); List<String> listStore = mongoUtils.getStoreInfoVoRegexName(name);
Pattern pattern = Pattern.compile("^.*" + name + ".*$", Pattern.CASE_INSENSITIVE); Pattern pattern = Pattern.compile("^.*" + name + ".*$", Pattern.CASE_INSENSITIVE);
Query query = new Query(); Query query = new Query();
...@@ -475,11 +475,14 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -475,11 +475,14 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
), ),
new Criteria().orOperator(Criteria.where("spuType").exists(false), (Criteria.where("spuType").is(0))) new Criteria().orOperator(Criteria.where("spuType").exists(false), (Criteria.where("spuType").is(0)))
)); ));
query.with(PageRequest.of(0, 20)).with(Sort.by( query.with(PageRequest.of(page, pageSize)).with(Sort.by(
//Sort.Order.desc("count"), //Sort.Order.desc("count"),
Sort.Order.desc("shelvesAt") Sort.Order.desc("shelvesAt")
)); ));
List<GoblinGoodsInfoVo> list = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()); List<GoblinGoodsInfoVo> list = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
long count = mongoTemplate.count(query, GoblinGoodsInfoVo.class.getSimpleName());
GoblinGoodsInfoListVoo goblinGoodsInfoListVoo=GoblinGoodsInfoListVoo.getNew();
goblinGoodsInfoListVoo.setCount(count);
ArrayList<GoblinGoodsInfoListVo> list1 = ObjectUtil.getGoblinGoodsInfoListVo(); ArrayList<GoblinGoodsInfoListVo> list1 = ObjectUtil.getGoblinGoodsInfoListVo();
//遍历 //遍历
for (GoblinGoodsInfoVo goblinGoodsInfoVo : list) { for (GoblinGoodsInfoVo goblinGoodsInfoVo : list) {
...@@ -507,7 +510,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -507,7 +510,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
list1.add(goblinGoodsInfoListVo); list1.add(goblinGoodsInfoListVo);
} }
} }
return list1; goblinGoodsInfoListVoo.setList(list1);
return goblinGoodsInfoListVoo;
//return list1;
} }
public GoblinFrontCategoryListVo getStoreGoodes(String storeId, String categoryId, String name) { public GoblinFrontCategoryListVo getStoreGoodes(String storeId, String categoryId, String name) {
......
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