admin
2019-09-17 5eab2b71f0749e9f61fc83d9d7e03553e9fa75ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.yeshi.fanli.dao.brand;
 
import java.util.List;
 
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
 
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
 
@Repository
public class BrandGoodsCaheDao extends MongodbBaseDao<BrandGoodsCahe> {
    
    /**
     * 查询商品列表
     * @param count
     * @param brandId
     * @return
     */
    public List<BrandGoodsCahe> getByBrandId(int start, int count, Long brandId){
        if (brandId == null) 
            return null;
        
        Query query = new Query();
        query.addCriteria(Criteria.where("brandId").is(brandId));
        //分页
        query.skip(start).limit(count);
        //排序
        query.with(new Sort(Sort.Direction.DESC,"weight"));
        
        return mongoTemplate.find(query, BrandGoodsCahe.class);
    }
}