yj
2020-03-14 a4e4101f3e68aaaeea3e280ad89b20818f40f534
fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java
@@ -12,6 +12,8 @@
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import com.mongodb.BasicDBObject;
import com.mongodb.QueryOperators;
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
import com.yeshi.fanli.util.StringUtil;
@@ -65,8 +67,9 @@
    * 
    * @return
    */
   public List<GoodsEvaluate> query(int start, int count, String key, Integer state) {
   public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType) {
      Query query = new Query();
      query.addCriteria(Criteria.where("dynamicType").is(dynamicType));
      if (state != null) {
         query.addCriteria(Criteria.where("state").is(state));
      }
@@ -79,8 +82,10 @@
      return mongoTemplate.find(query, GoodsEvaluate.class);
   }
   public long count(String key, Integer state) {
   public long count(String key, Integer state, int dynamicType) {
      Query query = new Query();
      query.addCriteria(Criteria.where("dynamicType").is(dynamicType));
      if (state != null) {
         query.addCriteria(Criteria.where("state").is(state));
      }
@@ -97,9 +102,10 @@
    * @param key
    * @return
    */
   public List<GoodsEvaluate> queryValid(int start, int count) {
   public List<GoodsEvaluate> queryValid(int start, int count, int dynamicType) {
      Date now = new Date();
      Query query = new Query();
      query.addCriteria(Criteria.where("dynamicType").is(dynamicType));
      query.addCriteria(Criteria.where("state").is(1));
      query.addCriteria(Criteria.where("startTime").lte(now));
      query.addCriteria(Criteria.where("endTime").gte(now));
@@ -113,13 +119,47 @@
    * @param key
    * @return
    */
   public long countValid() {
   public long countValid(int dynamicType) {
      Date now = new Date();
      Query query = new Query();
      query.addCriteria(Criteria.where("dynamicType").is(dynamicType));
      query.addCriteria(Criteria.where("state").is(1));
      query.addCriteria(Criteria.where("startTime").lte(now));
      query.addCriteria(Criteria.where("endTime").gte(now));
      return mongoTemplate.count(query, GoodsEvaluate.class);
   }
   /**
    * 查询有效
    * @param start
    * @param count
    * @param key
    * @return
    */
   public List<GoodsEvaluate> querySingleExist() {
      Query query = new Query();
      query.addCriteria(Criteria.where("dynamicType").is(1));
      query.addCriteria(Criteria.where("state").is(1));
      query.addCriteria(Criteria.where("goods.goodsType").is(1));
      return mongoTemplate.find(query, GoodsEvaluate.class);
   }
   /**
    * 查询有效
    * @param start
    * @param count
    * @param key
    * @return
    */
   public List<GoodsEvaluate> queryExist(int goodsType, Long goodsId) {
      Query query = new Query();
      query.addCriteria(Criteria.where("dynamicType").is(1));
      query.addCriteria(Criteria.where("state").is(1));
      query.addCriteria(Criteria.where("imgList.goods.goodsId").is(goodsId));
      query.addCriteria(Criteria.where("imgList.goods.goodsType").is(goodsType));
      return mongoTemplate.find(query, GoodsEvaluate.class);
   }
}