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

Commit 02bfee45 authored by zhengfuxin's avatar zhengfuxin

分类列表

parent 14591028
...@@ -10,6 +10,9 @@ import lombok.Data; ...@@ -10,6 +10,9 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
@ApiModel(value = "GoblinGoodsInfoVo", description = "商品SPU详情[不包含具体SKU,SKU详情参见'GoblinGoobsSkuInfoVo']") @ApiModel(value = "GoblinGoodsInfoVo", description = "商品SPU详情[不包含具体SKU,SKU详情参见'GoblinGoobsSkuInfoVo']")
...@@ -104,6 +107,8 @@ public class GoblinGoodsInfoVo implements Serializable, Cloneable { ...@@ -104,6 +107,8 @@ public class GoblinGoodsInfoVo implements Serializable, Cloneable {
private List<GoblinGoodsExtagVo> extagVoList; private List<GoblinGoodsExtagVo> extagVoList;
@ApiModelProperty(position = 55, value = "活动Id") @ApiModelProperty(position = 55, value = "活动Id")
private String marketId; private String marketId;
@ApiModelProperty(position = 56, value = "销量")
private Integer count;
@ApiModelProperty(position = 55, value = "SPU包含的SKU_ID列表") @ApiModelProperty(position = 55, value = "SPU包含的SKU_ID列表")
private List<String> skuIdList; private List<String> skuIdList;
...@@ -117,4 +122,29 @@ public class GoblinGoodsInfoVo implements Serializable, Cloneable { ...@@ -117,4 +122,29 @@ public class GoblinGoodsInfoVo implements Serializable, Cloneable {
return new GoblinGoodsInfoVo(); return new GoblinGoodsInfoVo();
} }
} }
/* public int compareTo(GoblinGoodsInfoVo arg0) {
return this.getCount().compareTo(arg0.getCount());
}*/
public static void main(String[] args) {
GoblinGoodsInfoVo goblinGoodsInfoVo=new GoblinGoodsInfoVo();
goblinGoodsInfoVo.setCount(1);
GoblinGoodsInfoVo goblinGoodsInfoVo1=new GoblinGoodsInfoVo();
goblinGoodsInfoVo1.setCount(12);
GoblinGoodsInfoVo goblinGoodsInfoVo2=new GoblinGoodsInfoVo();
goblinGoodsInfoVo2.setCount(12);
List<GoblinGoodsInfoVo> list=new ArrayList<>();
list.add(goblinGoodsInfoVo1);
list.add(goblinGoodsInfoVo);
list.add(goblinGoodsInfoVo2);
Collections.sort(list, new Comparator<GoblinGoodsInfoVo>() {
public int compare(GoblinGoodsInfoVo arg0, GoblinGoodsInfoVo arg1) {
return -(arg0.getCount().compareTo(arg1.getCount()));
}});
for(GoblinGoodsInfoVo goblinGoodsInfoVo3:list){
System.out.println(goblinGoodsInfoVo3.getCount());
}
}
} }
...@@ -86,6 +86,11 @@ public class GoblinFrontController { ...@@ -86,6 +86,11 @@ public class GoblinFrontController {
public ResponseDto getCube() throws ParseException { public ResponseDto getCube() throws ParseException {
return ResponseDto.success( goblinFrontService.getCube()); return ResponseDto.success( goblinFrontService.getCube());
} }
@GetMapping("getCategory")
@ApiOperation("获取分类")
public ResponseDto getCategory(String type,String categoryId) throws ParseException {
return ResponseDto.success( goblinFrontService.getCube());
}
......
...@@ -17,6 +17,9 @@ import com.mongodb.BasicDBObject; ...@@ -17,6 +17,9 @@ import com.mongodb.BasicDBObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
...@@ -259,6 +262,42 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -259,6 +262,42 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return goblinFrontCubeVo; return goblinFrontCubeVo;
} }
/**
* 获取分类列表
* 1、销量优先、2、新品优先、3、价格降序、4、价格升序
*/
public void getCategoryList(String type,String categoryId,int page,int pageSize){
//
Query query = new Query();
//Criteria.where("cateSid").is(categoryId)
query.addCriteria(new Criteria().andOperator(
Criteria.where("cateSid").is(categoryId),
Criteria.where("cateTid").is(categoryId)
));
Pageable pageable=null;
//
boolean isRe=false;
if(type.equals("1")){
isRe=true;
}else if(type.equals("2")){
pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Direction.DESC, "shelvesAt"));
}else if(type.equals("3")){
pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Direction.DESC, "priceGe"));
}else if(type.equals("4")){
pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Direction.ASC, "priceGe"));
}
// 排序 分页
// Query query = Query.query(Criteria.where("status").ne(1).and("status").ne(0));
// 查询总数
long count = mongoTemplate.count(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
if(!isRe){
query.with(pageable);
}
List<GoblinGoodsInfoVo> list = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
}
/** /**
* @author zhangfuxin * @author zhangfuxin
......
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