yujian
2020-06-29 ec60e757d358636dcac1589c44a66f3e276fe58c
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
36
37
38
39
40
41
42
43
44
45
package com.yeshi.fanli.dao.goods;
 
import java.util.Date;
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.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;
 
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.goods.FreeGoodsCoupon;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
 
@Repository
public class FreeGoodsCouponDao extends MongodbBaseDao<FreeGoodsCoupon> {
 
 
    /**
     * 查询免单商品-更新在前
     * @param start
     * @param count
     * @param goodsType
     * @return
     */
    public List<FreeGoodsCoupon> listByType(int start,int count, Integer goodsType) {
        Query query = new Query();
        if (goodsType != null)
            query.addCriteria(Criteria.where("goodsType").is(goodsType));
        query.with(new Sort(Sort.Direction.DESC, "updateTime"));
        query.skip(start).limit(count);
        return mongoTemplate.find(query, getEntityClass());
    }
 
    public long countByType(Integer goodsType) {
        Query query = new Query();
        if (goodsType != null)
            query.addCriteria(Criteria.where("goodsType").is(goodsType));
        return mongoTemplate.count(query, getEntityClass());
    }
 
    
    
}