admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.yeshi.fanli.dao.goods.jd;
 
import java.util.ArrayList;
import java.util.List;
 
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
 
import com.yeshi.common.MongodbBaseDao;
import com.yeshi.fanli.entity.goods.jd.NYouHuiGoods;
 
@Repository
public class NYouHuiGoodsDao extends MongodbBaseDao<NYouHuiGoods> {
 
    /**
     * 
     * @Title: selectByName
     * @Description: 根据名字查询
     * @param name
     * @return 
     * NYouHuiGoods 返回类型
     * @throws
     */
    public NYouHuiGoods selectByName(String name) {
        Query query = new Query();
        query.addCriteria(Criteria.where("name").is(name));
        List<Order> orders = new ArrayList<>();
        orders.add(new Order(Direction.DESC, "updateTime"));
        query.with(new Sort(orders));
        query.limit(1);
        return mongoTemplate.findOne(query, NYouHuiGoods.class);
    }
 
    /**
     * 
     * @Title: list
     * @Description: 查询列表
     * @param start
     * @param count
     * @return 
     * List<NYouHuiGoods> 返回类型
     * @throws
     */
    public List<NYouHuiGoods> list(int start, int count) {
        Query query = new Query();
        List<Order> orders = new ArrayList<>();
        orders.add(new Order(Direction.DESC, "updateTime"));
        query.with(new Sort(orders));
        query.skip(start);
        query.limit(count);
        return mongoTemplate.find(query, NYouHuiGoods.class);
    }
 
    /**
     * 
     * @Title: count
     * @Description: 查询数量
     * @return 
     * long 返回类型
     * @throws
     */
    public long count() {
        Query query = new Query();
        return mongoTemplate.count(query, NYouHuiGoods.class);
    }
 
}