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.fanli.dao.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);
|
}
|
|
}
|