| | |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | |
| | | @Repository |
| | | public class TLJFreeBuyGoodsDao extends MongodbBaseDao<TLJFreeBuyGoods> { |
| | | |
| | | public List<TLJFreeBuyGoods> listByDay(String day, int page, int pageSize) { |
| | | Query query = new Query(); |
| | | Criteria ca = Criteria.where("day").is(day); |
| | | query.addCriteria(ca); |
| | | query.limit(pageSize); |
| | | query.skip((page - 1) * pageSize).with(new Sort(Sort.Direction.DESC, "updateTime")); |
| | | return mongoTemplate.find(query, TLJFreeBuyGoods.class); |
| | | } |
| | | public List<TLJFreeBuyGoods> listByDay(String day, int page, int pageSize) { |
| | | Query query = new Query(); |
| | | Criteria ca = Criteria.where("day").is(day); |
| | | query.addCriteria(ca); |
| | | query.limit(pageSize); |
| | | query.skip((page - 1) * pageSize).with(new Sort(Sort.Direction.DESC, "updateTime")); |
| | | return mongoTemplate.find(query, TLJFreeBuyGoods.class); |
| | | } |
| | | |
| | | public long countByDay(String day) { |
| | | Query query = new Query(); |
| | | Criteria ca = Criteria.where("day").is(day); |
| | | query.addCriteria(ca); |
| | | return mongoTemplate.count(query, TLJFreeBuyGoods.class); |
| | | } |
| | | public long countByDay(String day) { |
| | | Query query = new Query(); |
| | | Criteria ca = Criteria.where("day").is(day); |
| | | query.addCriteria(ca); |
| | | return mongoTemplate.count(query, TLJFreeBuyGoods.class); |
| | | } |
| | | |
| | | |
| | | public List<TLJFreeBuyGoods> listByGoodsId(String auctionid) { |
| | | Query query = new Query(); |
| | | Criteria ca = Criteria.where("goods.auctionId").is(auctionid); |
| | | query.addCriteria(ca); |
| | | return mongoTemplate.find(query, TLJFreeBuyGoods.class); |
| | | } |
| | | |
| | | public TLJFreeBuyGoods selectByAuctionIdAndDay(String auctionId, String day) { |
| | | Query query = new Query(); |
| | | Criteria ca = Criteria.where("goods.auctionId").is(auctionId).and("day").is(day); |
| | | query.addCriteria(ca); |
| | | return mongoTemplate.findOne(query, TLJFreeBuyGoods.class); |
| | | } |
| | | public List<TLJFreeBuyGoods> listByGoodsId(String auctionid) { |
| | | Query query = new Query(); |
| | | query.addCriteria(TaoBaoUtil.getAuctionIdEqualCriteria("goods.auctionId",auctionid)); |
| | | |
| | | /** |
| | | * 根据商品ID删除 |
| | | * |
| | | * @param auctionId |
| | | */ |
| | | public void deleteByGoodsId(String auctionId) { |
| | | Query query = new Query(); |
| | | Criteria ca = Criteria.where("goods.auctionId").is(auctionId); |
| | | query.addCriteria(ca); |
| | | mongoTemplate.findAndRemove(query, TLJFreeBuyGoods.class); |
| | | } |
| | | return mongoTemplate.find(query, TLJFreeBuyGoods.class); |
| | | } |
| | | |
| | | public TLJFreeBuyGoods selectByAuctionIdAndDay(String auctionId, String day) { |
| | | Query query = new Query(); |
| | | query.addCriteria(TaoBaoUtil.getAuctionIdEqualCriteria("goods.auctionId",auctionId).and("day").is(day)); |
| | | return mongoTemplate.findOne(query, TLJFreeBuyGoods.class); |
| | | } |
| | | |
| | | /** |
| | | * 根据商品ID删除 |
| | | * |
| | | * @param auctionId |
| | | */ |
| | | public void deleteByGoodsId(String auctionId) { |
| | | Query query = new Query(); |
| | | query.addCriteria(TaoBaoUtil.getAuctionIdEqualCriteria("goods.auctionId",auctionId)); |
| | | mongoTemplate.findAndRemove(query, TLJFreeBuyGoods.class); |
| | | } |
| | | |
| | | } |