New file |
| | |
| | | package com.yeshi.fanli.dao.taobao;
|
| | |
|
| | | 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.taobao.TLJBuyGoods;
|
| | |
|
| | | @Repository
|
| | | public class TLJBuyGoodsDao extends MongodbBaseDao<TLJBuyGoods> {
|
| | | |
| | |
|
| | | public List<TLJBuyGoods> listByDayOrderByUpdateTime(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, TLJBuyGoods.class);
|
| | | }
|
| | |
|
| | | public void deleteByGoodsId(Long goodsId) {
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("goods.auctionId").is(goodsId);
|
| | | query.addCriteria(ca);
|
| | |
|
| | | List<TLJBuyGoods> list = mongoTemplate.find(query, TLJBuyGoods.class);
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | |
|
| | | for (TLJBuyGoods TLJBuyGoods : list) {
|
| | | mongoTemplate.remove(TLJBuyGoods);
|
| | | }
|
| | | }
|
| | |
|
| | | public List<TLJBuyGoods> listByAuctionId(Long auctionid) {
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("goods.auctionId").is(auctionid);
|
| | | query.addCriteria(ca);
|
| | | return mongoTemplate.find(query, TLJBuyGoods.class);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 减红包个数
|
| | | * |
| | | * @param id
|
| | | */
|
| | | public void subHongBaoCount(String id, int count) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("id").is(id).andOperator(Criteria.where("leftHongBaoCount").gt(count - 1)));
|
| | | org.springframework.data.mongodb.core.query.Update update = new org.springframework.data.mongodb.core.query.Update();
|
| | | update = update.inc("leftHongBaoCount", 0 - count);
|
| | | mongoTemplate.updateFirst(query, update, TLJBuyGoods.class);
|
| | | }
|
| | |
|
| | | public TLJBuyGoods selectByAuctionIdAndDay(Long 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, TLJBuyGoods.class);
|
| | | }
|
| | |
|
| | | }
|